2008-05-06 03:39:36 +00:00
|
|
|
/*
|
2015-05-11 21:14:52 +01:00
|
|
|
* Copyright 2008-2015 Haiku, Inc.
|
2008-05-06 03:39:36 +00:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _SEMAPHORE_H_
|
|
|
|
#define _SEMAPHORE_H_
|
|
|
|
|
2010-11-03 21:46:47 +00:00
|
|
|
|
2009-03-08 13:56:15 +00:00
|
|
|
#include <fcntl.h>
|
2008-05-08 01:39:49 +00:00
|
|
|
#include <stdint.h>
|
2008-05-06 03:39:36 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
|
2008-06-19 00:05:01 +00:00
|
|
|
typedef struct _sem_t {
|
2015-05-11 21:14:52 +01:00
|
|
|
int32_t type;
|
|
|
|
union {
|
|
|
|
int32_t named_sem_id;
|
|
|
|
int32_t unnamed_sem;
|
|
|
|
} u;
|
|
|
|
int32_t padding[2];
|
2008-05-06 03:39:36 +00:00
|
|
|
} sem_t;
|
|
|
|
|
|
|
|
#define SEM_FAILED ((sem_t*)(long)-1)
|
|
|
|
|
|
|
|
__BEGIN_DECLS
|
|
|
|
|
|
|
|
sem_t* sem_open(const char* name, int openFlags,...);
|
|
|
|
int sem_close(sem_t* semaphore);
|
|
|
|
int sem_unlink(const char* name);
|
|
|
|
|
|
|
|
int sem_init(sem_t* semaphore, int shared, unsigned value);
|
|
|
|
int sem_destroy(sem_t* semaphore);
|
|
|
|
|
|
|
|
int sem_post(sem_t* semaphore);
|
2022-02-16 20:29:11 +01:00
|
|
|
int sem_clockwait(sem_t* semaphore, clockid_t clock_id,
|
|
|
|
const struct timespec* abstime);
|
|
|
|
int sem_timedwait(sem_t* semaphore, const struct timespec* abstime);
|
2008-05-06 03:39:36 +00:00
|
|
|
int sem_trywait(sem_t* semaphore);
|
|
|
|
int sem_wait(sem_t* semaphore);
|
|
|
|
int sem_getvalue(sem_t* semaphore, int* value);
|
|
|
|
|
|
|
|
__END_DECLS
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* _SEMAPHORE_H_ */
|