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
15typedef 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
28sem_t*	sem_open(const char* name, int openFlags,...);
29int		sem_close(sem_t* semaphore);
30int		sem_unlink(const char* name);
31
32int		sem_init(sem_t* semaphore, int shared, unsigned value);
33int		sem_destroy(sem_t* semaphore);
34
35int		sem_post(sem_t* semaphore);
36int		sem_clockwait(sem_t* semaphore, clockid_t clock_id,
37			const struct timespec* abstime);
38int		sem_timedwait(sem_t* semaphore, const struct timespec* abstime);
39int		sem_trywait(sem_t* semaphore);
40int		sem_wait(sem_t* semaphore);
41int		sem_getvalue(sem_t* semaphore, int* value);
42
43__END_DECLS
44
45
46#endif	/* _SEMAPHORE_H_ */
47