mirror of
https://github.com/kanjitalk755/macemu.git
synced 2025-01-13 08:29:43 +00:00
MacOS X doesn't implement unnamed POSIX semaphores even though their libc
defines the functions. Use Mach semaphores instead.
This commit is contained in:
parent
85db30f78d
commit
1b53603138
@ -7,6 +7,19 @@
|
||||
extern "C" {
|
||||
#endif /* c_plusplus || __cplusplus */
|
||||
|
||||
/* MacOS X doesn't implement unnamed POSIX semaphores, event though
|
||||
the libc defines them! */
|
||||
#if (defined(__MACH__) && defined(__APPLE__))
|
||||
#include <mach/mach_init.h>
|
||||
#include <mach/task.h>
|
||||
#include <mach/semaphore.h>
|
||||
|
||||
#define sem_t semaphore_t
|
||||
#define sem_init(SEM,UNUSED,VALUE) semaphore_create(current_task(), (SEM), SYNC_POLICY_FIFO, (VALUE))
|
||||
#define sem_destroy(SEM) semaphore_destroy(current_task(), *(SEM))
|
||||
#define sem_wait(SEM) semaphore_wait(*(SEM))
|
||||
#define sem_post(SEM) semaphore_signal(*(SEM))
|
||||
#else
|
||||
typedef struct psem {
|
||||
pthread_mutex_t sem_lock;
|
||||
int sem_value;
|
||||
@ -22,6 +35,7 @@ int sem_wait(sem_t* sem);
|
||||
int sem_trywait(sem_t* sem);
|
||||
int sem_post(sem_t* sem);
|
||||
int sem_getvalue(sem_t* sem, int* sval);
|
||||
#endif
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user