[PATCH v2 04/18] Define mode_t via __mode_t
Sebastian Huber
sebastian.huber at embedded-brains.de
Fri Apr 15 11:44:15 UTC 2016
Use __uint32_t to avoid the use of GCC-specific _ST_INT32.
Signed-off-by: Sebastian Huber <sebastian.huber at embedded-brains.de>
---
newlib/libc/include/sys/_types.h | 16 +++++++++
newlib/libc/include/sys/types.h | 50 ++++----------------------
newlib/libc/sys/rtems/include/machine/_types.h | 2 +-
winsup/cygwin/include/cygwin/types.h | 4 ---
4 files changed, 23 insertions(+), 49 deletions(-)
diff --git a/newlib/libc/include/sys/_types.h b/newlib/libc/include/sys/_types.h
index 869c6a2..9514289 100644
--- a/newlib/libc/include/sys/_types.h
+++ b/newlib/libc/include/sys/_types.h
@@ -56,6 +56,22 @@ typedef unsigned short __ino_t;
#endif
#endif
+#ifndef __machine_mode_t_defined
+#if defined(__i386__) && (defined(GO32) || defined(__MSDOS__))
+typedef int __mode_t;
+#else
+#if defined(__sparc__) && !defined(__sparc_v9__)
+#ifdef __svr4__
+typedef unsigned long __mode_t;
+#else
+typedef unsigned short __mode_t;
+#endif
+#else
+typedef __uint32_t __mode_t;
+#endif
+#endif
+#endif
+
#ifndef __machine_off64_t_defined
__extension__ typedef long long _off64_t;
#endif
diff --git a/newlib/libc/include/sys/types.h b/newlib/libc/include/sys/types.h
index 2bf9eb5..e48c2f2 100644
--- a/newlib/libc/include/sys/types.h
+++ b/newlib/libc/include/sys/types.h
@@ -59,27 +59,8 @@ typedef quad_t * qaddr_t;
#include <sys/_types.h>
#include <sys/_stdint.h>
-#ifdef __i386__
-#if defined (GO32) || defined (__MSDOS__)
-#define __MS_types__
-#endif
-#endif
-
# include <stddef.h>
-/* To ensure the stat struct's layout doesn't change when sizeof(int), etc.
- changes, we assume sizeof short and long never change and have all types
- used to define struct stat use them and not int where possible.
- Where not possible, _ST_INTxx are used. It would be preferable to not have
- such assumptions, but until the extra fluff is necessary, it's avoided.
- No 64 bit targets use stat yet. What to do about them is postponed
- until necessary. */
-#ifdef __GNUC__
-#define _ST_INT32 __attribute__ ((__mode__ (__SI__)))
-#else
-#define _ST_INT32
-#endif
-
#if __BSD_VISIBLE
#include <sys/select.h>
# define physadr physadr_t
@@ -144,7 +125,8 @@ typedef __ino_t ino_t; /* inode number */
#define _INO_T_DECLARED
#endif
-#ifdef __MS_types__
+#if defined(__i386__) && (defined(GO32) || defined(__MSDOS__))
+typedef char * addr_t;
typedef unsigned long vm_offset_t;
typedef unsigned long vm_size_t;
@@ -159,7 +141,7 @@ typedef unsigned int u_int32_t;
typedef long long int64_t;
typedef unsigned long long u_int64_t;
typedef int32_t register_t;
-#endif /* __MS_types__ */
+#endif /* __i386__ && (GO32 || __MSDOS__) */
/*
* All these should be machine specific - right now they are all broken.
@@ -190,10 +172,6 @@ typedef __pid_t pid_t; /* process id */
#define _PID_T_DECLARED
#endif
-#if defined(__rtems__)
-typedef _mode_t mode_t;
-#endif
-
#ifndef _KEY_T_DECLARED
typedef __key_t key_t; /* IPC key */
#define _KEY_T_DECLARED
@@ -204,29 +182,13 @@ typedef _ssize_t ssize_t;
#define _SSIZE_T_DECLARED
#endif
-#if !defined(__CYGWIN__) && !defined(__rtems__)
-#ifdef __MS_types__
-typedef char * addr_t;
-typedef int mode_t;
-#else
-#if defined (__sparc__) && !defined (__sparc_v9__)
-#ifdef __svr4__
-typedef unsigned long mode_t;
-#else
-typedef unsigned short mode_t;
+#ifndef _MODE_T_DECLARED
+typedef __mode_t mode_t; /* permissions */
+#define _MODE_T_DECLARED
#endif
-#else
-typedef unsigned int mode_t _ST_INT32;
-#endif
-#endif /* ! __MS_types__ */
-#endif /*__CYGWIN__*/
typedef unsigned short nlink_t;
-#undef __MS_types__
-#undef _ST_INT32
-
-
#ifndef __clockid_t_defined
typedef _CLOCKID_T_ clockid_t;
#define __clockid_t_defined
diff --git a/newlib/libc/sys/rtems/include/machine/_types.h b/newlib/libc/sys/rtems/include/machine/_types.h
index 76a6841..15de3ce 100644
--- a/newlib/libc/sys/rtems/include/machine/_types.h
+++ b/newlib/libc/sys/rtems/include/machine/_types.h
@@ -22,7 +22,7 @@ typedef _off_t _fpos_t;
typedef unsigned long __ino_t;
#define __machine_ino_t_defined
-typedef __uint32_t _mode_t;
+typedef __uint32_t __mode_t;
#define __machine_mode_t_defined
#endif /* _MACHINE__TYPES_H */
diff --git a/winsup/cygwin/include/cygwin/types.h b/winsup/cygwin/include/cygwin/types.h
index c785fb2..2a9580e 100644
--- a/winsup/cygwin/include/cygwin/types.h
+++ b/winsup/cygwin/include/cygwin/types.h
@@ -104,10 +104,6 @@ typedef __int32_t register_t;
typedef char *addr_t;
#endif
-#ifndef __mode_t_defined
-#define __mode_t_defined
-typedef unsigned mode_t;
-#endif
#endif /*__BIT_TYPES_DEFINED*/
#if !defined(__INSIDE_CYGWIN__) || !defined(__cplusplus)
--
1.8.4.5
More information about the devel
mailing list