From 529aa781b65f8020f93551fc4989147f489395ba Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 1 Aug 2011 17:22:18 +0000 Subject: [PATCH] 2011-08-01 Sebastian Huber * libc/include/sys/types.h: XML and RTEMS define _UNIX98_THREAD_MUTEX_ATTRIBUTES and can use the standard definitions. This avoids redefinition warnings. --- newlib/ChangeLog | 6 +++ newlib/libc/include/sys/types.h | 72 +++++++++++++++++---------------- 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 3d75a16af..5d2053183 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,9 @@ +2011-08-01 Sebastian Huber + + * libc/include/sys/types.h: XML and RTEMS define + _UNIX98_THREAD_MUTEX_ATTRIBUTES and can use the standard + definitions. This avoids redefinition warnings. + 2011-07-26 Ralf Corsépius * libc/sys/rtems/sys/dirent.h (scandir): diff --git a/newlib/libc/include/sys/types.h b/newlib/libc/include/sys/types.h index a8fee93ab..9723d92d3 100644 --- a/newlib/libc/include/sys/types.h +++ b/newlib/libc/include/sys/types.h @@ -301,39 +301,6 @@ typedef __uint32_t pthread_t; /* identify a thread */ #define PTHREAD_CREATE_DETACHED 0 #define PTHREAD_CREATE_JOINABLE 1 -#if defined(__XMK__) || defined(__rtems__) -/* 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 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 - -/* 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 3 - -/* 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 4 - -#endif /* defined(__XMK__) || defined(__rtems__) */ - #if defined(__XMK__) typedef struct pthread_attr_s { int contentionscope; @@ -391,12 +358,49 @@ typedef struct { /* 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 +#endif /* !defined(_UNIX98_THREAD_MUTEX_ATTRIBUTES) */ #if defined(__XMK__) typedef unsigned int pthread_mutex_t; /* identify a mutex */