1/* 2 * Copyright 2008-2012 Haiku, Inc. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef _SEMAPHORE_H_ 6#define _SEMAPHORE_H_ 7 8 9#include <fcntl.h> 10#include <stdint.h> 11#include <sys/cdefs.h> 12#include <time.h> 13 14 15typedef struct _sem_t { 16 int32_t id; 17 int32_t _padding[3]; 18} sem_t; 19 20#define SEM_FAILED ((sem_t*)(long)-1) 21 22__BEGIN_DECLS 23 24sem_t* sem_open(const char* name, int openFlags,...); 25int sem_close(sem_t* semaphore); 26int sem_unlink(const char* name); 27 28int sem_init(sem_t* semaphore, int shared, unsigned value); 29int sem_destroy(sem_t* semaphore); 30 31int sem_post(sem_t* semaphore); 32int sem_timedwait(sem_t* semaphore, const struct timespec* timeout); 33int sem_trywait(sem_t* semaphore); 34int sem_wait(sem_t* semaphore); 35int sem_getvalue(sem_t* semaphore, int* value); 36 37__END_DECLS 38 39 40#endif /* _SEMAPHORE_H_ */ 41