Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
_mutex-pthread.h
Go to the documentation of this file.
1
33#if defined (_RWSTD_EDG_ECCP) && defined (_RWSTD_OS_LINUX) \
34 && defined (_RWSTD_NO_LONG_LONG)
35 // disable error #450-D: the type "long long" is nonstandard
36 // when using the vanilla EDG eccp in strict mode (i.e., w/o
37 // long long support)
38# pragma diag_suppress 450
39#endif // EDG eccp on Linux
40
41// LinuxThreads man page:
42// "Variables of type pthread_mutex_t can also be initialized
43// statically, using the constants PTHREAD_MUTEX_INITIALIZER
44// (for fast mutexes), PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
45// (for recursive mutexes), and PTHREAD_ERRORCHECK_MUTEX_INI-
46// TIALIZER_NP (for error checking mutexes)."
47// ...
48// "Attempting to initialize an already initialized mutex results
49// in undefined behavior."
50
51#include <pthread.h>
52
53#define _RWSTD_MUTEX_INIT(mutex) pthread_mutex_init (&mutex, 0)
54#define _RWSTD_MUTEX_DESTROY(mutex) pthread_mutex_destroy (&mutex)
55#define _RWSTD_MUTEX_LOCK(mutex) pthread_mutex_lock (&mutex)
56#define _RWSTD_MUTEX_UNLOCK(mutex) pthread_mutex_unlock (&mutex)
57#define _RWSTD_MUTEX_T pthread_mutex_t
58
59#if defined (__GNUG__) && defined (__osf__)
60 // prevent g++ warnings about missing initializers
61 // see <pthread.h> for explanation of _PTHREAD_NOMETER_STATIC
62# ifndef _PTHREAD_NOMETER_STATIC
63# define _RWSTD_MUTEX_INITIALIZER \
64 { _PTHREAD_MSTATE_SLOW, _PTHREAD_MVALID | _PTHREAD_MVF_STA, \
65 0, 0, 0, 0, 0, 0 }
66# else // if defined (_PTHREAD_NOMETER_STATIC)
67# define _RWSTD_MUTEX_INITIALIZER
68 { 0, _PTHREAD_MVALID | _PTHREAD_MVF_STA, 0, 0, 0, 0, 0, 0 }
69# endif // _PTHREAD_NOMETER_STATIC
70#elif defined (__GNUG__) && defined (__sgi__)
71 // prevent g++ warnings about a partly bracketed initializer
72# define _RWSTD_MUTEX_INITIALIZER { PTHREAD_MUTEX_INITIALIZER }
73#else
74# define _RWSTD_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
75#endif