xref: /haiku/headers/posix/semaphore.h (revision 1294543de9ac0eff000eaea1b18368c36435d08e)
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 <fcntl.h>
9 #include <stdint.h>
10 #include <sys/cdefs.h>
11 #include <time.h>
12 
13 
14 typedef struct _sem_t {
15 	int32_t	id;
16 	int32_t	_padding[3];
17 } sem_t;
18 
19 #define SEM_FAILED	((sem_t*)(long)-1)
20 
21 __BEGIN_DECLS
22 
23 sem_t*	sem_open(const char* name, int openFlags,...);
24 int		sem_close(sem_t* semaphore);
25 int		sem_unlink(const char* name);
26 
27 int		sem_init(sem_t* semaphore, int shared, unsigned value);
28 int		sem_destroy(sem_t* semaphore);
29 
30 int		sem_post(sem_t* semaphore);
31 int		sem_timedwait(sem_t* semaphore, const struct timespec* timeout);
32 int		sem_trywait(sem_t* semaphore);
33 int		sem_wait(sem_t* semaphore);
34 int		sem_getvalue(sem_t* semaphore, int* value);
35 
36 __END_DECLS
37 
38 
39 #endif	/* _SEMAPHORE_H_ */
40