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