xref: /haiku/headers/posix/semaphore.h (revision f2b4344867e97c3f4e742a1b4a15e6879644601a)
1 /*
2  * Copyright 2008-2010 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 
15 typedef 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 
24 sem_t*	sem_open(const char* name, int openFlags,...);
25 int		sem_close(sem_t* semaphore);
26 int		sem_unlink(const char* name);
27 
28 int		sem_init(sem_t* semaphore, int shared, unsigned value);
29 int		sem_destroy(sem_t* semaphore);
30 
31 int		sem_post(sem_t* semaphore);
32 int		sem_timedwait(sem_t* semaphore, const struct timespec* timeout);
33 int		sem_trywait(sem_t* semaphore);
34 int		sem_wait(sem_t* semaphore);
35 int		sem_getvalue(sem_t* semaphore, int* value);
36 
37 __END_DECLS
38 
39 
40 #endif	/* _SEMAPHORE_H_ */
41