This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH 3/3] Move pthread types to <sys/_pthreadtypes.h>


This makes it possible provide operating system specific types for
<pthread.h>.  It is in line with the FreeBSD header file structure and
allows a future cleanup of <pthread.h> to not expose unrelated things
via <sys/types.h> and <unistd.h>.  Glibc uses the similar
<bits/pthreadtypes.h> for this purpose.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 newlib/libc/include/pthread.h                     |   8 +-
 newlib/libc/include/sys/_pthreadtypes.h           | 233 ++++++++++++++++++++++
 newlib/libc/include/sys/types.h                   | 227 +--------------------
 newlib/libc/sys/rtems/include/sys/_pthreadtypes.h | 211 ++++++++++++++++++++
 winsup/cygwin/include/machine/types.h             |  46 -----
 winsup/cygwin/include/sys/_pthreadtypes.h         |  59 ++++++
 6 files changed, 508 insertions(+), 276 deletions(-)
 create mode 100644 newlib/libc/include/sys/_pthreadtypes.h
 create mode 100644 newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
 create mode 100644 winsup/cygwin/include/sys/_pthreadtypes.h

diff --git a/newlib/libc/include/pthread.h b/newlib/libc/include/pthread.h
index 8206855..abba3d9 100644
--- a/newlib/libc/include/pthread.h
+++ b/newlib/libc/include/pthread.h
@@ -73,7 +73,7 @@ int	_EXFUN(pthread_mutex_destroy, (pthread_mutex_t *__mutex));
     pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
  */
 
-#define PTHREAD_MUTEX_INITIALIZER  ((pthread_mutex_t) 0xFFFFFFFF)
+#define PTHREAD_MUTEX_INITIALIZER _PTHREAD_MUTEX_INITIALIZER
 
 /*  Locking and Unlocking a Mutex, P1003.1c/Draft 10, p. 93
     NOTE: P1003.4b/D8 adds pthread_mutex_timedlock(), p. 29 */
@@ -116,7 +116,7 @@ int	_EXFUN(pthread_cond_destroy, (pthread_cond_t *__mutex));
     pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
  */
  
-#define PTHREAD_COND_INITIALIZER  ((pthread_cond_t) 0xFFFFFFFF)
+#define PTHREAD_COND_INITIALIZER _PTHREAD_COND_INITIALIZER
  
 /* Broadcasting and Signaling a Condition, P1003.1c/Draft 10, p. 101 */
  
@@ -286,7 +286,7 @@ int	_EXFUN(pthread_getconcurrency, (void));
   
     NOTE:  This is named inconsistently -- it should be INITIALIZER.  */
  
-#define PTHREAD_ONCE_INIT  { 1, 0 }  /* is initialized and not run */
+#define PTHREAD_ONCE_INIT _PTHREAD_ONCE_INIT
  
 int	_EXFUN(pthread_once,
 	(pthread_once_t *__once_control, void (*__init_routine)(void)));
@@ -413,7 +413,7 @@ int	_EXFUN(pthread_spin_unlock, (pthread_spinlock_t *__spinlock));
     pthread_mutex_t mutex = PTHREAD_RWLOCK_INITIALIZER;
  */
 
-#define PTHREAD_RWLOCK_INITIALIZER  ((pthread_rwlock_t) 0xFFFFFFFF)
+#define PTHREAD_RWLOCK_INITIALIZER _PTHREAD_RWLOCK_INITIALIZER
 
 int	_EXFUN(pthread_rwlockattr_init, (pthread_rwlockattr_t *__attr));
 int	_EXFUN(pthread_rwlockattr_destroy, (pthread_rwlockattr_t *__attr));
diff --git a/newlib/libc/include/sys/_pthreadtypes.h b/newlib/libc/include/sys/_pthreadtypes.h
new file mode 100644
index 0000000..19742fc
--- /dev/null
+++ b/newlib/libc/include/sys/_pthreadtypes.h
@@ -0,0 +1,233 @@
+/*
+ *  Written by Joel Sherrill <joel.sherrill@OARcorp.com>.
+ *
+ *  COPYRIGHT (c) 1989-2013, 2015.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  Permission to use, copy, modify, and distribute this software for any
+ *  purpose without fee is hereby granted, provided that this entire notice
+ *  is included in all copies of any software which is or includes a copy
+ *  or modification of this software.
+ *
+ *  THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ *  WARRANTY.  IN PARTICULAR,  THE AUTHOR MAKES NO REPRESENTATION
+ *  OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
+ *  SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+ */
+
+#ifndef _SYS__PTHREADTYPES_H_
+#define	_SYS__PTHREADTYPES_H_
+
+#if defined(_POSIX_THREADS)
+
+#include <sys/sched.h>
+
+/*
+ *  2.5 Primitive System Data Types,  P1003.1c/D10, p. 19.
+ */
+
+#if defined(__XMK__)
+typedef unsigned int pthread_t;          /* identify a thread */
+#else
+typedef __uint32_t pthread_t;            /* identify a thread */
+#endif
+
+/* P1003.1c/D10, p. 118-119 */
+#define PTHREAD_SCOPE_PROCESS 0
+#define PTHREAD_SCOPE_SYSTEM  1
+
+/* P1003.1c/D10, p. 111 */
+#define PTHREAD_INHERIT_SCHED  1      /* scheduling policy and associated */
+                                      /*   attributes are inherited from */
+                                      /*   the calling thread. */
+#define PTHREAD_EXPLICIT_SCHED 2      /* set from provided attribute object */
+
+/* P1003.1c/D10, p. 141 */
+#define PTHREAD_CREATE_DETACHED 0
+#define PTHREAD_CREATE_JOINABLE  1
+
+#if defined(__XMK__)
+typedef struct pthread_attr_s {
+  int contentionscope;
+  struct sched_param schedparam;
+  int  detachstate;
+  void *stackaddr;
+  size_t stacksize;
+} pthread_attr_t;
+
+#define PTHREAD_STACK_MIN       200
+
+#else /* !defined(__XMK__) */
+typedef struct {
+  int is_initialized;
+  void *stackaddr;
+  int stacksize;
+  int contentionscope;
+  int inheritsched;
+  int schedpolicy;
+  struct sched_param schedparam;
+
+  /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute.  */
+#if defined(_POSIX_THREAD_CPUTIME)
+  int  cputime_clock_allowed;  /* see time.h */
+#endif
+  int  detachstate;
+} pthread_attr_t;
+
+#endif /* !defined(__XMK__) */
+
+#if defined(_POSIX_THREAD_PROCESS_SHARED)
+/* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared.  */
+
+#define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */
+#define PTHREAD_PROCESS_SHARED  1 /* visible too all processes with access to */
+                                  /*   the memory where the resource is */
+                                  /*   located */
+#endif
+
+#if defined(_POSIX_THREAD_PRIO_PROTECT)
+/* Mutexes */
+
+/* Values for blocking protocol. */
+
+#define PTHREAD_PRIO_NONE    0
+#define PTHREAD_PRIO_INHERIT 1
+#define PTHREAD_PRIO_PROTECT 2
+#endif
+
+#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
+
+/* Values for mutex type */
+
+/* The following defines are part of the X/Open System Interface (XSI). */
+
+/*
+ * This type of mutex does not detect deadlock. A thread attempting to
+ * relock this mutex without first unlocking it shall deadlock. Attempting
+ * to unlock a mutex locked by a different thread results in undefined
+ * behavior.  Attempting to unlock an unlocked mutex results in undefined
+ * behavior.
+ */
+#define PTHREAD_MUTEX_NORMAL     0
+
+/*
+ * A thread attempting to relock this mutex without first unlocking
+ * it shall succeed in locking the mutex.  The relocking deadlock which
+ * can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with
+ * this type of mutex.  Multiple locks of this mutex shall require the
+ * same number of unlocks to release the mutex before another thread can
+ * acquire the mutex. A thread attempting to unlock a mutex which another
+ * thread has locked shall return with an error.  A thread attempting to
+ * unlock an unlocked mutex shall return with an error.
+ */
+#define PTHREAD_MUTEX_RECURSIVE  1
+
+/* 
+ * This type of mutex provides error checking. A thread attempting
+ * to relock this mutex without first unlocking it shall return with an
+ * error. A thread attempting to unlock a mutex which another thread has
+ * locked shall return with an error. A thread attempting to unlock an
+ * unlocked mutex shall return with an error.
+ */
+#define PTHREAD_MUTEX_ERRORCHECK 2
+
+/*
+ * Attempting to recursively lock a mutex of this type results
+ * in undefined behavior. Attempting to unlock a mutex of this type
+ * which was not locked by the calling thread results in undefined
+ * behavior. Attempting to unlock a mutex of this type which is not locked
+ * results in undefined behavior. An implementation may map this mutex to
+ * one of the other mutex types.
+ */
+#define PTHREAD_MUTEX_DEFAULT    3
+
+#endif /* !defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) */
+
+#if defined(__XMK__)
+typedef unsigned int pthread_mutex_t;    /* identify a mutex */
+
+typedef struct {
+  int type;
+} pthread_mutexattr_t;
+
+#else /* !defined(__XMK__) */
+typedef __uint32_t pthread_mutex_t;      /* identify a mutex */
+
+typedef struct {
+  int   is_initialized;
+#if defined(_POSIX_THREAD_PROCESS_SHARED)
+  int   process_shared;  /* allow mutex to be shared amongst processes */
+#endif
+#if defined(_POSIX_THREAD_PRIO_PROTECT)
+  int   prio_ceiling;
+  int   protocol;
+#endif
+#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
+  int type;
+#endif
+  int   recursive;
+} pthread_mutexattr_t;
+#endif /* !defined(__XMK__) */
+
+#define _PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) 0xFFFFFFFF)
+
+/* Condition Variables */
+
+typedef __uint32_t pthread_cond_t;       /* identify a condition variable */
+
+#define _PTHREAD_COND_INITIALIZER ((pthread_cond_t) 0xFFFFFFFF)
+
+typedef struct {
+  int      is_initialized;
+  clock_t  clock;             /* specifiy clock for timeouts */
+#if defined(_POSIX_THREAD_PROCESS_SHARED)
+  int      process_shared;    /* allow this to be shared amongst processes */
+#endif
+} pthread_condattr_t;         /* a condition attribute object */
+
+/* Keys */
+
+typedef __uint32_t pthread_key_t;        /* thread-specific data keys */
+
+typedef struct {
+  int   is_initialized;  /* is this structure initialized? */
+  int   init_executed;   /* has the initialization routine been run? */
+} pthread_once_t;       /* dynamic package initialization */
+
+#define _PTHREAD_ONCE_INIT  { 1, 0 }  /* is initialized and not run */
+#endif /* defined(_POSIX_THREADS) */
+
+/* POSIX Barrier Types */
+
+#if defined(_POSIX_BARRIERS)
+typedef __uint32_t pthread_barrier_t;        /* POSIX Barrier Object */
+typedef struct {
+  int   is_initialized;  /* is this structure initialized? */
+#if defined(_POSIX_THREAD_PROCESS_SHARED)
+  int   process_shared;       /* allow this to be shared amongst processes */
+#endif
+} pthread_barrierattr_t;
+#endif /* defined(_POSIX_BARRIERS) */
+
+/* POSIX Spin Lock Types */
+
+#if defined(_POSIX_SPIN_LOCKS)
+typedef __uint32_t pthread_spinlock_t;        /* POSIX Spin Lock Object */
+#endif /* defined(_POSIX_SPIN_LOCKS) */
+
+/* POSIX Reader/Writer Lock Types */
+
+#if defined(_POSIX_READER_WRITER_LOCKS)
+typedef __uint32_t pthread_rwlock_t;         /* POSIX RWLock Object */
+
+#define _PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) 0xFFFFFFFF)
+
+typedef struct {
+  int   is_initialized;       /* is this structure initialized? */
+#if defined(_POSIX_THREAD_PROCESS_SHARED)
+  int   process_shared;       /* allow this to be shared amongst processes */
+#endif
+} pthread_rwlockattr_t;
+#endif /* defined(_POSIX_READER_WRITER_LOCKS) */
+
+#endif /* ! _SYS__PTHREADTYPES_H_ */
diff --git a/newlib/libc/include/sys/types.h b/newlib/libc/include/sys/types.h
index 379b755..65ff520 100644
--- a/newlib/libc/include/sys/types.h
+++ b/newlib/libc/include/sys/types.h
@@ -236,232 +236,7 @@ typedef	__suseconds_t	suseconds_t;
 typedef	__int64_t	sbintime_t;
 
 #include <sys/features.h>
-
-
-/*
- * Cygwin is using a complete distinct implementation of pthread objects and
- * pointers rather than structs.  This means we can't use the types defined
- * here, but rather in <machine/types.h>.
- */
-#if !defined(__CYGWIN__)
-
-#if defined(_POSIX_THREADS)
-
-#include <sys/sched.h>
-
-/*
- *  2.5 Primitive System Data Types,  P1003.1c/D10, p. 19.
- */
-
-#if defined(__XMK__)
-typedef unsigned int pthread_t;          /* identify a thread */
-#else
-typedef __uint32_t pthread_t;            /* identify a thread */
-#endif
-
-/* P1003.1c/D10, p. 118-119 */
-#define PTHREAD_SCOPE_PROCESS 0
-#define PTHREAD_SCOPE_SYSTEM  1
-
-/* P1003.1c/D10, p. 111 */
-#define PTHREAD_INHERIT_SCHED  1      /* scheduling policy and associated */
-                                      /*   attributes are inherited from */
-                                      /*   the calling thread. */
-#define PTHREAD_EXPLICIT_SCHED 2      /* set from provided attribute object */
-
-/* P1003.1c/D10, p. 141 */
-#define PTHREAD_CREATE_DETACHED 0
-#define PTHREAD_CREATE_JOINABLE  1
-
-#if defined(__rtems__)
-  #include <sys/cpuset.h>
-#endif
-
-#if defined(__XMK__)
-typedef struct pthread_attr_s {
-  int contentionscope;
-  struct sched_param schedparam;
-  int  detachstate;
-  void *stackaddr;
-  size_t stacksize;
-} pthread_attr_t;
-
-#define PTHREAD_STACK_MIN       200
-
-#else /* !defined(__XMK__) */
-typedef struct {
-  int is_initialized;
-  void *stackaddr;
-  int stacksize;
-  int contentionscope;
-  int inheritsched;
-  int schedpolicy;
-  struct sched_param schedparam;
-#if defined(__rtems__)
-  size_t guardsize;
-#endif
-
-  /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute.  */
-#if defined(_POSIX_THREAD_CPUTIME)
-  int  cputime_clock_allowed;  /* see time.h */
-#endif
-  int  detachstate;
-#if defined(__rtems__)
-  size_t affinitysetsize;
-  cpu_set_t *affinityset;
-  cpu_set_t affinitysetpreallocated;
-#endif
-} pthread_attr_t;
-
-#endif /* !defined(__XMK__) */
-
-#if defined(_POSIX_THREAD_PROCESS_SHARED)
-/* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared.  */
-
-#define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */
-#define PTHREAD_PROCESS_SHARED  1 /* visible too all processes with access to */
-                                  /*   the memory where the resource is */
-                                  /*   located */
-#endif
-
-#if defined(_POSIX_THREAD_PRIO_PROTECT)
-/* Mutexes */
-
-/* Values for blocking protocol. */
-
-#define PTHREAD_PRIO_NONE    0
-#define PTHREAD_PRIO_INHERIT 1
-#define PTHREAD_PRIO_PROTECT 2
-#endif
-
-#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
-
-/* Values for mutex type */
-
-/* The following defines are part of the X/Open System Interface (XSI). */
-
-/*
- * This type of mutex does not detect deadlock. A thread attempting to
- * relock this mutex without first unlocking it shall deadlock. Attempting
- * to unlock a mutex locked by a different thread results in undefined
- * behavior.  Attempting to unlock an unlocked mutex results in undefined
- * behavior.
- */
-#define PTHREAD_MUTEX_NORMAL     0
-
-/*
- * A thread attempting to relock this mutex without first unlocking
- * it shall succeed in locking the mutex.  The relocking deadlock which
- * can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with
- * this type of mutex.  Multiple locks of this mutex shall require the
- * same number of unlocks to release the mutex before another thread can
- * acquire the mutex. A thread attempting to unlock a mutex which another
- * thread has locked shall return with an error.  A thread attempting to
- * unlock an unlocked mutex shall return with an error.
- */
-#define PTHREAD_MUTEX_RECURSIVE  1
-
-/* 
- * This type of mutex provides error checking. A thread attempting
- * to relock this mutex without first unlocking it shall return with an
- * error. A thread attempting to unlock a mutex which another thread has
- * locked shall return with an error. A thread attempting to unlock an
- * unlocked mutex shall return with an error.
- */
-#define PTHREAD_MUTEX_ERRORCHECK 2
-
-/*
- * Attempting to recursively lock a mutex of this type results
- * in undefined behavior. Attempting to unlock a mutex of this type
- * which was not locked by the calling thread results in undefined
- * behavior. Attempting to unlock a mutex of this type which is not locked
- * results in undefined behavior. An implementation may map this mutex to
- * one of the other mutex types.
- */
-#define PTHREAD_MUTEX_DEFAULT    3
-
-#endif /* !defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) */
-
-#if defined(__XMK__)
-typedef unsigned int pthread_mutex_t;    /* identify a mutex */
-
-typedef struct {
-  int type;
-} pthread_mutexattr_t;
-
-#else /* !defined(__XMK__) */
-typedef __uint32_t pthread_mutex_t;      /* identify a mutex */
-
-typedef struct {
-  int   is_initialized;
-#if defined(_POSIX_THREAD_PROCESS_SHARED)
-  int   process_shared;  /* allow mutex to be shared amongst processes */
-#endif
-#if defined(_POSIX_THREAD_PRIO_PROTECT)
-  int   prio_ceiling;
-  int   protocol;
-#endif
-#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
-  int type;
-#endif
-  int   recursive;
-} pthread_mutexattr_t;
-#endif /* !defined(__XMK__) */
-
-/* Condition Variables */
-
-typedef __uint32_t pthread_cond_t;       /* identify a condition variable */
-
-typedef struct {
-  int      is_initialized;
-  clock_t  clock;             /* specifiy clock for timeouts */
-#if defined(_POSIX_THREAD_PROCESS_SHARED)
-  int      process_shared;    /* allow this to be shared amongst processes */
-#endif
-} pthread_condattr_t;         /* a condition attribute object */
-
-/* Keys */
-
-typedef __uint32_t pthread_key_t;        /* thread-specific data keys */
-
-typedef struct {
-  int   is_initialized;  /* is this structure initialized? */
-  int   init_executed;   /* has the initialization routine been run? */
-} pthread_once_t;       /* dynamic package initialization */
-#endif /* defined(_POSIX_THREADS) */
-
-/* POSIX Barrier Types */
-
-#if defined(_POSIX_BARRIERS)
-typedef __uint32_t pthread_barrier_t;        /* POSIX Barrier Object */
-typedef struct {
-  int   is_initialized;  /* is this structure initialized? */
-#if defined(_POSIX_THREAD_PROCESS_SHARED)
-  int   process_shared;       /* allow this to be shared amongst processes */
-#endif
-} pthread_barrierattr_t;
-#endif /* defined(_POSIX_BARRIERS) */
-
-/* POSIX Spin Lock Types */
-
-#if defined(_POSIX_SPIN_LOCKS)
-typedef __uint32_t pthread_spinlock_t;        /* POSIX Spin Lock Object */
-#endif /* defined(_POSIX_SPIN_LOCKS) */
-
-/* POSIX Reader/Writer Lock Types */
-
-#if defined(_POSIX_READER_WRITER_LOCKS)
-typedef __uint32_t pthread_rwlock_t;         /* POSIX RWLock Object */
-typedef struct {
-  int   is_initialized;       /* is this structure initialized? */
-#if defined(_POSIX_THREAD_PROCESS_SHARED)
-  int   process_shared;       /* allow this to be shared amongst processes */
-#endif
-} pthread_rwlockattr_t;
-#endif /* defined(_POSIX_READER_WRITER_LOCKS) */
-
-#endif /* __CYGWIN__ */
-
+#include <sys/_pthreadtypes.h>
 #include <machine/types.h>
 
 #endif  /* !__need_inttypes */
diff --git a/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h b/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
new file mode 100644
index 0000000..f82c537
--- /dev/null
+++ b/newlib/libc/sys/rtems/include/sys/_pthreadtypes.h
@@ -0,0 +1,211 @@
+/*
+ *  Written by Joel Sherrill <joel.sherrill@OARcorp.com>.
+ *
+ *  COPYRIGHT (c) 1989-2013, 2015.
+ *  On-Line Applications Research Corporation (OAR).
+ *
+ *  Permission to use, copy, modify, and distribute this software for any
+ *  purpose without fee is hereby granted, provided that this entire notice
+ *  is included in all copies of any software which is or includes a copy
+ *  or modification of this software.
+ *
+ *  THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ *  WARRANTY.  IN PARTICULAR,  THE AUTHOR MAKES NO REPRESENTATION
+ *  OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
+ *  SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+ */
+
+#ifndef _SYS__PTHREADTYPES_H_
+#define	_SYS__PTHREADTYPES_H_
+
+#if defined(_POSIX_THREADS)
+
+#include <sys/sched.h>
+#include <sys/cpuset.h>
+
+/*
+ *  2.5 Primitive System Data Types,  P1003.1c/D10, p. 19.
+ */
+
+typedef __uint32_t pthread_t;            /* identify a thread */
+
+/* P1003.1c/D10, p. 118-119 */
+#define PTHREAD_SCOPE_PROCESS 0
+#define PTHREAD_SCOPE_SYSTEM  1
+
+/* P1003.1c/D10, p. 111 */
+#define PTHREAD_INHERIT_SCHED  1      /* scheduling policy and associated */
+                                      /*   attributes are inherited from */
+                                      /*   the calling thread. */
+#define PTHREAD_EXPLICIT_SCHED 2      /* set from provided attribute object */
+
+/* P1003.1c/D10, p. 141 */
+#define PTHREAD_CREATE_DETACHED 0
+#define PTHREAD_CREATE_JOINABLE  1
+
+typedef struct {
+  int is_initialized;
+  void *stackaddr;
+  int stacksize;
+  int contentionscope;
+  int inheritsched;
+  int schedpolicy;
+  struct sched_param schedparam;
+  size_t guardsize;
+
+  /* P1003.4b/D8, p. 54 adds cputime_clock_allowed attribute.  */
+#if defined(_POSIX_THREAD_CPUTIME)
+  int  cputime_clock_allowed;  /* see time.h */
+#endif
+  int  detachstate;
+  size_t affinitysetsize;
+  cpu_set_t *affinityset;
+  cpu_set_t affinitysetpreallocated;
+} pthread_attr_t;
+
+#if defined(_POSIX_THREAD_PROCESS_SHARED)
+/* NOTE: P1003.1c/D10, p. 81 defines following values for process_shared.  */
+
+#define PTHREAD_PROCESS_PRIVATE 0 /* visible within only the creating process */
+#define PTHREAD_PROCESS_SHARED  1 /* visible too all processes with access to */
+                                  /*   the memory where the resource is */
+                                  /*   located */
+#endif
+
+#if defined(_POSIX_THREAD_PRIO_PROTECT)
+/* Mutexes */
+
+/* Values for blocking protocol. */
+
+#define PTHREAD_PRIO_NONE    0
+#define PTHREAD_PRIO_INHERIT 1
+#define PTHREAD_PRIO_PROTECT 2
+#endif
+
+#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
+
+/* Values for mutex type */
+
+/* The following defines are part of the X/Open System Interface (XSI). */
+
+/*
+ * This type of mutex does not detect deadlock. A thread attempting to
+ * relock this mutex without first unlocking it shall deadlock. Attempting
+ * to unlock a mutex locked by a different thread results in undefined
+ * behavior.  Attempting to unlock an unlocked mutex results in undefined
+ * behavior.
+ */
+#define PTHREAD_MUTEX_NORMAL     0
+
+/*
+ * A thread attempting to relock this mutex without first unlocking
+ * it shall succeed in locking the mutex.  The relocking deadlock which
+ * can occur with mutexes of type PTHREAD_MUTEX_NORMAL cannot occur with
+ * this type of mutex.  Multiple locks of this mutex shall require the
+ * same number of unlocks to release the mutex before another thread can
+ * acquire the mutex. A thread attempting to unlock a mutex which another
+ * thread has locked shall return with an error.  A thread attempting to
+ * unlock an unlocked mutex shall return with an error.
+ */
+#define PTHREAD_MUTEX_RECURSIVE  1
+
+/* 
+ * This type of mutex provides error checking. A thread attempting
+ * to relock this mutex without first unlocking it shall return with an
+ * error. A thread attempting to unlock a mutex which another thread has
+ * locked shall return with an error. A thread attempting to unlock an
+ * unlocked mutex shall return with an error.
+ */
+#define PTHREAD_MUTEX_ERRORCHECK 2
+
+/*
+ * Attempting to recursively lock a mutex of this type results
+ * in undefined behavior. Attempting to unlock a mutex of this type
+ * which was not locked by the calling thread results in undefined
+ * behavior. Attempting to unlock a mutex of this type which is not locked
+ * results in undefined behavior. An implementation may map this mutex to
+ * one of the other mutex types.
+ */
+#define PTHREAD_MUTEX_DEFAULT    3
+
+#endif /* !defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) */
+
+typedef __uint32_t pthread_mutex_t;      /* identify a mutex */
+
+#define _PTHREAD_MUTEX_INITIALIZER ((pthread_mutex_t) 0xFFFFFFFF)
+
+typedef struct {
+  int   is_initialized;
+#if defined(_POSIX_THREAD_PROCESS_SHARED)
+  int   process_shared;  /* allow mutex to be shared amongst processes */
+#endif
+#if defined(_POSIX_THREAD_PRIO_PROTECT)
+  int   prio_ceiling;
+  int   protocol;
+#endif
+#if defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES)
+  int type;
+#endif
+  int   recursive;
+} pthread_mutexattr_t;
+
+/* Condition Variables */
+
+typedef __uint32_t pthread_cond_t;       /* identify a condition variable */
+
+#define _PTHREAD_COND_INITIALIZER ((pthread_cond_t) 0xFFFFFFFF)
+
+typedef struct {
+  int      is_initialized;
+  clock_t  clock;             /* specifiy clock for timeouts */
+#if defined(_POSIX_THREAD_PROCESS_SHARED)
+  int      process_shared;    /* allow this to be shared amongst processes */
+#endif
+} pthread_condattr_t;         /* a condition attribute object */
+
+/* Keys */
+
+typedef __uint32_t pthread_key_t;        /* thread-specific data keys */
+
+typedef struct {
+  int   is_initialized;  /* is this structure initialized? */
+  int   init_executed;   /* has the initialization routine been run? */
+} pthread_once_t;       /* dynamic package initialization */
+
+#define _PTHREAD_ONCE_INIT  { 1, 0 }  /* is initialized and not run */
+#endif /* defined(_POSIX_THREADS) */
+
+/* POSIX Barrier Types */
+
+#if defined(_POSIX_BARRIERS)
+typedef __uint32_t pthread_barrier_t;        /* POSIX Barrier Object */
+typedef struct {
+  int   is_initialized;  /* is this structure initialized? */
+#if defined(_POSIX_THREAD_PROCESS_SHARED)
+  int   process_shared;       /* allow this to be shared amongst processes */
+#endif
+} pthread_barrierattr_t;
+#endif /* defined(_POSIX_BARRIERS) */
+
+/* POSIX Spin Lock Types */
+
+#if defined(_POSIX_SPIN_LOCKS)
+typedef __uint32_t pthread_spinlock_t;        /* POSIX Spin Lock Object */
+#endif /* defined(_POSIX_SPIN_LOCKS) */
+
+/* POSIX Reader/Writer Lock Types */
+
+#if defined(_POSIX_READER_WRITER_LOCKS)
+typedef __uint32_t pthread_rwlock_t;         /* POSIX RWLock Object */
+
+#define _PTHREAD_RWLOCK_INITIALIZER ((pthread_rwlock_t) 0xFFFFFFFF)
+
+typedef struct {
+  int   is_initialized;       /* is this structure initialized? */
+#if defined(_POSIX_THREAD_PROCESS_SHARED)
+  int   process_shared;       /* allow this to be shared amongst processes */
+#endif
+} pthread_rwlockattr_t;
+#endif /* defined(_POSIX_READER_WRITER_LOCKS) */
+
+#endif /* ! _SYS__PTHREADTYPES_H_ */
diff --git a/winsup/cygwin/include/machine/types.h b/winsup/cygwin/include/machine/types.h
index 065696a..54b4acf 100644
--- a/winsup/cygwin/include/machine/types.h
+++ b/winsup/cygwin/include/machine/types.h
@@ -76,52 +76,6 @@ typedef char *addr_t;
 
 #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>
 
diff --git a/winsup/cygwin/include/sys/_pthreadtypes.h b/winsup/cygwin/include/sys/_pthreadtypes.h
new file mode 100644
index 0000000..3063e83
--- /dev/null
+++ b/winsup/cygwin/include/sys/_pthreadtypes.h
@@ -0,0 +1,59 @@
+/* machine/types.h
+   Written by Robert Collins <rbtcollins@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__PTHREADTYPES_H_
+#define	_SYS__PTHREADTYPES_H_
+
+#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__ */
+
+#endif /* ! _SYS__PTHREADTYPES_H_ */
-- 
1.8.4.5


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]