00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #if !defined( SEMAPHORE_H )
00040 #define SEMAPHORE_H
00041
00042 #undef PTW32_LEVEL
00043
00044 #if defined(_POSIX_SOURCE)
00045 #define PTW32_LEVEL 0
00046
00047 #endif
00048
00049 #if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199309
00050 #undef PTW32_LEVEL
00051 #define PTW32_LEVEL 1
00052
00053 #endif
00054
00055 #if defined(INCLUDE_NP)
00056 #undef PTW32_LEVEL
00057 #define PTW32_LEVEL 2
00058
00059 #endif
00060
00061 #define PTW32_LEVEL_MAX 3
00062
00063 #if !defined(PTW32_LEVEL)
00064 #define PTW32_LEVEL PTW32_LEVEL_MAX
00065
00066 #endif
00067
00068 #if __GNUC__ && ! defined (__declspec)
00069 # error Please upgrade your GNU compiler to one that supports __declspec.
00070 #endif
00071
00072
00073
00074
00075
00076
00077
00078 #ifndef PTW32_STATIC_LIB
00079 # ifdef PTW32_BUILD
00080 # define PTW32_DLLPORT __declspec (dllexport)
00081 # else
00082 # define PTW32_DLLPORT __declspec (dllimport)
00083 # endif
00084 #else
00085 # define PTW32_DLLPORT
00086 #endif
00087
00088
00089
00090
00091
00092
00093 #ifndef PTW32_CONFIG_H
00094 # if defined(WINCE)
00095 # define NEED_ERRNO
00096 # define NEED_SEM
00097 # endif
00098 # if defined(_UWIN) || defined(__MINGW32__)
00099 # define HAVE_MODE_T
00100 # endif
00101 #endif
00102
00103
00104
00105
00106
00107 #if PTW32_LEVEL >= PTW32_LEVEL_MAX
00108 #ifdef NEED_ERRNO
00109 #include "need_errno.h"
00110 #else
00111 #include <errno.h>
00112 #endif
00113 #endif
00114
00115 #define _POSIX_SEMAPHORES
00116
00117 #ifdef __cplusplus
00118 extern "C"
00119 {
00120 #endif
00121
00122 #ifndef HAVE_MODE_T
00123 typedef unsigned int mode_t;
00124 #endif
00125
00126
00127 typedef struct sem_t_ * sem_t;
00128
00129 PTW32_DLLPORT int __cdecl sem_init (sem_t * sem,
00130 int pshared,
00131 unsigned int value);
00132
00133 PTW32_DLLPORT int __cdecl sem_destroy (sem_t * sem);
00134
00135 PTW32_DLLPORT int __cdecl sem_trywait (sem_t * sem);
00136
00137 PTW32_DLLPORT int __cdecl sem_wait (sem_t * sem);
00138
00139 PTW32_DLLPORT int __cdecl sem_timedwait (sem_t * sem,
00140 const struct timespec * abstime);
00141
00142 PTW32_DLLPORT int __cdecl sem_post (sem_t * sem);
00143
00144 PTW32_DLLPORT int __cdecl sem_post_multiple (sem_t * sem,
00145 int count);
00146
00147 PTW32_DLLPORT int __cdecl sem_open (const char * name,
00148 int oflag,
00149 mode_t mode,
00150 unsigned int value);
00151
00152 PTW32_DLLPORT int __cdecl sem_close (sem_t * sem);
00153
00154 PTW32_DLLPORT int __cdecl sem_unlink (const char * name);
00155
00156 PTW32_DLLPORT int __cdecl sem_getvalue (sem_t * sem,
00157 int * sval);
00158
00159 #ifdef __cplusplus
00160 }
00161 #endif
00162
00163 #undef PTW32_LEVEL
00164 #undef PTW32_LEVEL_MAX
00165
00166 #endif