xref: /haiku/headers/posix/semaphore.h (revision c237c4ce593ee823d9867fd997e51e4c447f5623)
1 /*
2  * Copyright 2008-2015 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 type;
17 	union {
18 		int32_t named_sem_id;
19 		int32_t unnamed_sem;
20 	} u;
21 	int32_t padding[2];
22 } sem_t;
23 
24 #define SEM_FAILED	((sem_t*)(long)-1)
25 
26 __BEGIN_DECLS
27 
28 sem_t*	sem_open(const char* name, int openFlags,...);
29 int		sem_close(sem_t* semaphore);
30 int		sem_unlink(const char* name);
31 
32 int		sem_init(sem_t* semaphore, int shared, unsigned value);
33 int		sem_destroy(sem_t* semaphore);
34 
35 int		sem_post(sem_t* semaphore);
36 int		sem_clockwait(sem_t* semaphore, clockid_t clock_id,
37 			const struct timespec* abstime);
38 int		sem_timedwait(sem_t* semaphore, const struct timespec* abstime);
39 int		sem_trywait(sem_t* semaphore);
40 int		sem_wait(sem_t* semaphore);
41 int		sem_getvalue(sem_t* semaphore, int* value);
42 
43 __END_DECLS
44 
45 
46 #endif	/* _SEMAPHORE_H_ */
47