Lines Matching refs:sem

93 #define sem_init(sem, sem_attr1, sem_init_value) \  argument
94 (int)((*sem = CreateSemaphore(NULL, 0, 32768, NULL)) == NULL)
95 #define sem_wait(sem) \ argument
96 (int)(WAIT_OBJECT_0 != WaitForSingleObject(*sem, INFINITE))
97 #define sem_post(sem) ReleaseSemaphore(*sem, 1, NULL) argument
98 #define sem_destroy(sem) \ argument
99 if (*sem) ((int)(CloseHandle(*sem)) == TRUE)
110 static inline int sem_init(sem_t *sem, int pshared, unsigned int value) {
111 DosCreateEventSem(NULL, &sem->event, pshared ? DC_SEM_SHARED : 0,
113 DosCreateMutexSem(NULL, &sem->wait_mutex, 0, FALSE);
114 DosCreateMutexSem(NULL, &sem->count_mutex, 0, FALSE);
116 sem->count = value;
121 static inline int sem_wait(sem_t *sem) {
122 DosRequestMutexSem(sem->wait_mutex, -1);
124 DosWaitEventSem(sem->event, -1);
126 DosRequestMutexSem(sem->count_mutex, -1);
128 sem->count--;
129 if (sem->count == 0) {
132 DosResetEventSem(sem->event, &post_count);
135 DosReleaseMutexSem(sem->count_mutex);
137 DosReleaseMutexSem(sem->wait_mutex);
142 static inline int sem_post(sem_t *sem) {
143 DosRequestMutexSem(sem->count_mutex, -1);
145 if (sem->count < 32768) {
146 sem->count++;
147 DosPostEventSem(sem->event);
150 DosReleaseMutexSem(sem->count_mutex);
155 static inline int sem_destroy(sem_t *sem) {
156 DosCloseEventSem(sem->event);
157 DosCloseMutexSem(sem->wait_mutex);
158 DosCloseMutexSem(sem->count_mutex);
171 #define sem_wait(sem) (semaphore_wait(*sem))
172 #define sem_post(sem) semaphore_signal(*sem)
173 #define sem_destroy(sem) semaphore_destroy(mach_task_self(), *sem)