[PATCH v2 1/5] Introduce <machine/_user_types.h>

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Apr 20 13:29:49 UTC 2016


Introduce <machine/_user_types.h> for <sys/types.h>.  Newlib targets may
provide an own version of <machine/_user_types.h> in their machine
directory to add custom user types for <sys/types.h>.

Signed-off-by: Sebastian Huber <sebastian.huber at embedded-brains.de>
---
 newlib/libc/include/machine/_user_types.h   |   7 ++
 newlib/libc/include/sys/types.h             |  10 +-
 winsup/cygwin/include/cygwin/types.h        | 129 ++------------------------
 winsup/cygwin/include/machine/_user_types.h | 137 ++++++++++++++++++++++++++++
 4 files changed, 154 insertions(+), 129 deletions(-)
 create mode 100644 newlib/libc/include/machine/_user_types.h
 create mode 100644 winsup/cygwin/include/machine/_user_types.h

diff --git a/newlib/libc/include/machine/_user_types.h b/newlib/libc/include/machine/_user_types.h
new file mode 100644
index 0000000..a5a64e6
--- /dev/null
+++ b/newlib/libc/include/machine/_user_types.h
@@ -0,0 +1,7 @@
+/*
+ * Newlib targets may provide an own version of this file in their machine
+ * directory to add custom user types for <sys/types.h>.
+ */
+#ifndef _SYS_TYPES_H
+#error "must be included via <sys/types.h>"
+#endif /* !_SYS_TYPES_H */
diff --git a/newlib/libc/include/sys/types.h b/newlib/libc/include/sys/types.h
index dbd6f2b..325fedc 100644
--- a/newlib/libc/include/sys/types.h
+++ b/newlib/libc/include/sys/types.h
@@ -253,7 +253,7 @@ typedef	__int64_t	sbintime_t;
  * pointers rather than structs to ensure maximum binary compatability with
  * previous releases.
  * This means that we don't use the types defined here, but rather in
- * <cygwin/types.h>
+ * <machine/_user_types.h>
  */
 #if defined(_POSIX_THREADS) && !defined(__CYGWIN__)
 
@@ -438,11 +438,7 @@ typedef struct {
   int   is_initialized;  /* is this structure initialized? */
   int   init_executed;   /* has the initialization routine been run? */
 } pthread_once_t;       /* dynamic package initialization */
-#else
-#if defined (__CYGWIN__)
-#include <cygwin/types.h>
-#endif
-#endif /* defined(_POSIX_THREADS) */
+#endif /* defined(_POSIX_THREADS) && !defined(__CYGWIN__) */
 
 /* POSIX Barrier Types */
 
@@ -476,6 +472,8 @@ typedef struct {
 #endif /* defined(_POSIX_READER_WRITER_LOCKS) */
 #endif /* __CYGWIN__ */
 
+#include <machine/_user_types.h>
+
 #endif  /* !__need_inttypes */
 
 #undef __need_inttypes
diff --git a/winsup/cygwin/include/cygwin/types.h b/winsup/cygwin/include/cygwin/types.h
index faf08bd..1268693 100644
--- a/winsup/cygwin/include/cygwin/types.h
+++ b/winsup/cygwin/include/cygwin/types.h
@@ -1,4 +1,4 @@
-/* types.h
+/* cygwin/types.h
 
    Copyright 2001, 2002, 2003, 2005, 2006, 2010, 2011, 2012, 2015 Red Hat Inc.
    Written by Robert Collins <rbtcollins at hotmail.com>
@@ -12,128 +12,11 @@ details. */
 #ifndef _CYGWIN_TYPES_H
 #define _CYGWIN_TYPES_H
 
-#ifdef __cplusplus
-extern "C"
-{
-#endif
+/*
+ * This file is provided for backward compatibility.  It is no longer used in
+ * Newlib.  Do not add new things to it.
+ */
 
-#include <sys/_stdint.h>
-#include <endian.h>
-#include <bits/wordsize.h>
-#include <sys/_timespec.h>
-
-#ifndef __timespec_t_defined
-#define __timespec_t_defined
-typedef struct timespec timespec_t;
-#endif /*__timespec_t_defined*/
-
-#ifndef __timestruc_t_defined
-#define __timestruc_t_defined
-typedef struct timespec timestruc_t;
-#endif /*__timestruc_t_defined*/
-
-typedef __loff_t loff_t;
-
-#if defined (__INSIDE_CYGWIN__) && !defined (__x86_64__)
-struct __flock32 {
-	short	 l_type;	/* F_RDLCK, F_WRLCK, or F_UNLCK */
-	short	 l_whence;	/* flag to choose starting offset */
-	_off_t	 l_start;	/* relative offset, in bytes */
-	_off_t	 l_len;		/* length, in bytes; 0 means lock to EOF */
-	short	 l_pid;		/* returned with F_GETLK */
-	short	 l_xxx;		/* reserved for future use */
-};
-#endif
-
-struct flock {
-	short	 l_type;	/* F_RDLCK, F_WRLCK, or F_UNLCK */
-	short	 l_whence;	/* flag to choose starting offset */
-	off_t	 l_start;	/* relative offset, in bytes */
-	off_t	 l_len;		/* length, in bytes; 0 means lock to EOF */
-	pid_t	 l_pid;		/* returned with F_GETLK */
-};
-
-#ifndef __BIT_TYPES_DEFINED
-#define __BIT_TYPES_DEFINED__ 1
-
-#ifndef __vm_offset_t_defined
-#define __vm_offset_t_defined
-typedef unsigned long vm_offset_t;
-#endif /*__vm_offset_t_defined*/
-
-#ifndef __vm_size_t_defined
-#define __vm_size_t_defined
-typedef unsigned long vm_size_t;
-#endif /*__vm_size_t_defined*/
-
-#ifndef __vm_object_t_defined
-#define __vm_object_t_defined
-typedef void *vm_object_t;
-#endif /* __vm_object_t_defined */
-
-#ifndef __register_t_defined
-#define __register_t_defined
-typedef __int32_t register_t;
-#endif
-
-#ifndef __addr_t_defined
-#define __addr_t_defined
-typedef char *addr_t;
-#endif
-
-#endif /*__BIT_TYPES_DEFINED*/
-
-#if !defined(__INSIDE_CYGWIN__) || !defined(__cplusplus)
-
-typedef struct __pthread_t {char __dummy;} *pthread_t;
-typedef struct __pthread_mutex_t {char __dummy;} *pthread_mutex_t;
-
-typedef struct __pthread_key_t {char __dummy;} *pthread_key_t;
-typedef struct __pthread_attr_t {char __dummy;} *pthread_attr_t;
-typedef struct __pthread_mutexattr_t {char __dummy;} *pthread_mutexattr_t;
-typedef struct __pthread_condattr_t {char __dummy;} *pthread_condattr_t;
-typedef struct __pthread_cond_t {char __dummy;} *pthread_cond_t;
-typedef struct __pthread_barrierattr_t {char __dummy;} *pthread_barrierattr_t;
-typedef struct __pthread_barrier_t {char __dummy;} *pthread_barrier_t;
-
-  /* These variables are not user alterable. This means you!. */
-typedef struct
-{
-  pthread_mutex_t mutex;
-  int state;
-}
-pthread_once_t;
-typedef struct __pthread_spinlock_t {char __dummy;} *pthread_spinlock_t;
-typedef struct __pthread_rwlock_t {char __dummy;} *pthread_rwlock_t;
-typedef struct __pthread_rwlockattr_t {char __dummy;} *pthread_rwlockattr_t;
-
-#else
-
-/* pthreads types */
-
-typedef class pthread *pthread_t;
-typedef class pthread_mutex *pthread_mutex_t;
-typedef class pthread_key *pthread_key_t;
-typedef class pthread_attr *pthread_attr_t;
-typedef class pthread_mutexattr *pthread_mutexattr_t;
-typedef class pthread_condattr *pthread_condattr_t;
-typedef class pthread_cond *pthread_cond_t;
-typedef class pthread_barrier *pthread_barrier_t;
-typedef class pthread_barrierattr *pthread_barrierattr_t;
-typedef class pthread_once pthread_once_t;
-typedef class pthread_spinlock *pthread_spinlock_t;
-typedef class pthread_rwlock *pthread_rwlock_t;
-typedef class pthread_rwlockattr *pthread_rwlockattr_t;
-
-/* semaphores types */
-typedef class semaphore *sem_t;
-#endif /* __INSIDE_CYGWIN__ */
-
-/* this header needs the dev_t typedef */
-#include <sys/sysmacros.h>
-
-#ifdef __cplusplus
-}
-#endif
+#include <sys/types.h>
 
 #endif /* _CYGWIN_TYPES_H */
diff --git a/winsup/cygwin/include/machine/_user_types.h b/winsup/cygwin/include/machine/_user_types.h
new file mode 100644
index 0000000..2e0cf92
--- /dev/null
+++ b/winsup/cygwin/include/machine/_user_types.h
@@ -0,0 +1,137 @@
+/* machine/_user_types.h
+
+   Copyright 2001, 2002, 2003, 2005, 2006, 2010, 2011, 2012, 2015 Red Hat Inc.
+   Written by Robert Collins <rbtcollins at hotmail.com>
+
+This file is part of Cygwin.
+
+This software is a copyrighted work licensed under the terms of the
+Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
+details. */
+
+#ifndef _SYS_TYPES_H
+#error "must be included via <sys/types.h>"
+#endif /* !_SYS_TYPES_H */
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include <endian.h>
+#include <bits/wordsize.h>
+#include <sys/_timespec.h>
+
+#ifndef __timespec_t_defined
+#define __timespec_t_defined
+typedef struct timespec timespec_t;
+#endif /*__timespec_t_defined*/
+
+#ifndef __timestruc_t_defined
+#define __timestruc_t_defined
+typedef struct timespec timestruc_t;
+#endif /*__timestruc_t_defined*/
+
+typedef __loff_t loff_t;
+
+#if defined (__INSIDE_CYGWIN__) && !defined (__x86_64__)
+struct __flock32 {
+	short	 l_type;	/* F_RDLCK, F_WRLCK, or F_UNLCK */
+	short	 l_whence;	/* flag to choose starting offset */
+	_off_t	 l_start;	/* relative offset, in bytes */
+	_off_t	 l_len;		/* length, in bytes; 0 means lock to EOF */
+	short	 l_pid;		/* returned with F_GETLK */
+	short	 l_xxx;		/* reserved for future use */
+};
+#endif
+
+struct flock {
+	short	 l_type;	/* F_RDLCK, F_WRLCK, or F_UNLCK */
+	short	 l_whence;	/* flag to choose starting offset */
+	off_t	 l_start;	/* relative offset, in bytes */
+	off_t	 l_len;		/* length, in bytes; 0 means lock to EOF */
+	pid_t	 l_pid;		/* returned with F_GETLK */
+};
+
+#ifndef __BIT_TYPES_DEFINED
+#define __BIT_TYPES_DEFINED__ 1
+
+#ifndef __vm_offset_t_defined
+#define __vm_offset_t_defined
+typedef unsigned long vm_offset_t;
+#endif /*__vm_offset_t_defined*/
+
+#ifndef __vm_size_t_defined
+#define __vm_size_t_defined
+typedef unsigned long vm_size_t;
+#endif /*__vm_size_t_defined*/
+
+#ifndef __vm_object_t_defined
+#define __vm_object_t_defined
+typedef void *vm_object_t;
+#endif /* __vm_object_t_defined */
+
+#ifndef __register_t_defined
+#define __register_t_defined
+typedef __int32_t register_t;
+#endif
+
+#ifndef __addr_t_defined
+#define __addr_t_defined
+typedef char *addr_t;
+#endif
+
+#endif /*__BIT_TYPES_DEFINED*/
+
+#if !defined(__INSIDE_CYGWIN__) || !defined(__cplusplus)
+
+typedef struct __pthread_t {char __dummy;} *pthread_t;
+typedef struct __pthread_mutex_t {char __dummy;} *pthread_mutex_t;
+
+typedef struct __pthread_key_t {char __dummy;} *pthread_key_t;
+typedef struct __pthread_attr_t {char __dummy;} *pthread_attr_t;
+typedef struct __pthread_mutexattr_t {char __dummy;} *pthread_mutexattr_t;
+typedef struct __pthread_condattr_t {char __dummy;} *pthread_condattr_t;
+typedef struct __pthread_cond_t {char __dummy;} *pthread_cond_t;
+typedef struct __pthread_barrierattr_t {char __dummy;} *pthread_barrierattr_t;
+typedef struct __pthread_barrier_t {char __dummy;} *pthread_barrier_t;
+
+  /* These variables are not user alterable. This means you!. */
+typedef struct
+{
+  pthread_mutex_t mutex;
+  int state;
+}
+pthread_once_t;
+typedef struct __pthread_spinlock_t {char __dummy;} *pthread_spinlock_t;
+typedef struct __pthread_rwlock_t {char __dummy;} *pthread_rwlock_t;
+typedef struct __pthread_rwlockattr_t {char __dummy;} *pthread_rwlockattr_t;
+
+#else
+
+/* pthreads types */
+
+typedef class pthread *pthread_t;
+typedef class pthread_mutex *pthread_mutex_t;
+typedef class pthread_key *pthread_key_t;
+typedef class pthread_attr *pthread_attr_t;
+typedef class pthread_mutexattr *pthread_mutexattr_t;
+typedef class pthread_condattr *pthread_condattr_t;
+typedef class pthread_cond *pthread_cond_t;
+typedef class pthread_barrier *pthread_barrier_t;
+typedef class pthread_barrierattr *pthread_barrierattr_t;
+typedef class pthread_once pthread_once_t;
+typedef class pthread_spinlock *pthread_spinlock_t;
+typedef class pthread_rwlock *pthread_rwlock_t;
+typedef class pthread_rwlockattr *pthread_rwlockattr_t;
+
+/* semaphores types */
+typedef class semaphore *sem_t;
+#endif /* __INSIDE_CYGWIN__ */
+
+/* this header needs the dev_t typedef */
+#include <sys/sysmacros.h>
+
+#ifdef __cplusplus
+}
+#endif
-- 
1.8.4.5



More information about the devel mailing list