summaryrefslogtreecommitdiffstats
path: root/newlib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc')
-rw-r--r--newlib/libc/include/sys/_types.h15
-rw-r--r--newlib/libc/include/sys/types.h4
2 files changed, 17 insertions, 2 deletions
diff --git a/newlib/libc/include/sys/_types.h b/newlib/libc/include/sys/_types.h
index 6a2c94dd6..06ddd8329 100644
--- a/newlib/libc/include/sys/_types.h
+++ b/newlib/libc/include/sys/_types.h
@@ -119,6 +119,21 @@ typedef _off64_t _fpos64_t;
#endif
#endif
+/* Defined by GCC provided <stddef.h> */
+#undef __size_t
+
+#ifndef __machine_size_t_defined
+#ifdef __SIZE_TYPE__
+typedef __SIZE_TYPE__ __size_t;
+#else
+#if defined(__INT_MAX__) && __INT_MAX__ == 2147483647
+typedef int __size_t;
+#else
+typedef long __size_t;
+#endif
+#endif
+#endif
+
#ifndef __machine_ssize_t_defined
#ifdef __SIZE_TYPE__
/* If __SIZE_TYPE__ is defined (gcc) we define ssize_t based on size_t.
diff --git a/newlib/libc/include/sys/types.h b/newlib/libc/include/sys/types.h
index 57b74ef4b..31f765e3e 100644
--- a/newlib/libc/include/sys/types.h
+++ b/newlib/libc/include/sys/types.h
@@ -56,11 +56,11 @@ typedef quad_t * qaddr_t;
#ifndef __need_inttypes
#define _SYS_TYPES_H
+/* <stddef.h> must be before <sys/_types.h> for __size_t considerations */
+#include <stddef.h>
#include <sys/_types.h>
#include <sys/_stdint.h>
-# include <stddef.h>
-
#if __BSD_VISIBLE
#include <machine/endian.h>
#include <sys/select.h>