7 |
|
extern "C" { |
8 |
|
#endif /* c_plusplus || __cplusplus */ |
9 |
|
|
10 |
+ |
/* MacOS X doesn't implement unnamed POSIX semaphores, event though |
11 |
+ |
the libc defines them! */ |
12 |
+ |
#if (defined(__MACH__) && defined(__APPLE__)) |
13 |
+ |
#include <mach/mach_init.h> |
14 |
+ |
#include <mach/task.h> |
15 |
+ |
#include <mach/semaphore.h> |
16 |
+ |
|
17 |
+ |
#define sem_t semaphore_t |
18 |
+ |
#define sem_init(SEM,UNUSED,VALUE) semaphore_create(current_task(), (SEM), SYNC_POLICY_FIFO, (VALUE)) |
19 |
+ |
#define sem_destroy(SEM) semaphore_destroy(current_task(), *(SEM)) |
20 |
+ |
#define sem_wait(SEM) semaphore_wait(*(SEM)) |
21 |
+ |
#define sem_post(SEM) semaphore_signal(*(SEM)) |
22 |
+ |
#else |
23 |
|
typedef struct psem { |
24 |
|
pthread_mutex_t sem_lock; |
25 |
|
int sem_value; |
35 |
|
int sem_trywait(sem_t* sem); |
36 |
|
int sem_post(sem_t* sem); |
37 |
|
int sem_getvalue(sem_t* sem, int* sval); |
38 |
+ |
#endif |
39 |
|
|
40 |
|
#if defined(c_plusplus) || defined(__cplusplus) |
41 |
|
}; |