2 * The UCW Library -- POSIX semaphores wrapper
4 * (c) 2006 Robert Spalek <robert@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
10 #ifndef _UCW_SEMAPHORE_H
11 #define _UCW_SEMAPHORE_H
13 #include <semaphore.h>
20 /* In Darwin, sem_init() is unfortunately not implemented and the guide
21 * recommends emulating it using sem_open(). */
28 sprintf(buf, "tmp/sem-%d-%d", getpid(), cnt++);
29 sem_t *sem = sem_open(buf, O_CREAT, 0777, 0);
30 ASSERT(sem != (sem_t*) SEM_FAILED);
45 sem_t *sem = xmalloc(sizeof(sem_t));
46 int res = sem_init(sem, 0, 0);