3dfe682f55
* Changed the semantics of unnamed semaphores. Before parent and child of a fork() would always share an earlier created semaphore. Now we do that only, if the "shared" parameter of sem_init() was true. That's still not quite the behavior Linux and Solaris have, but should be perfectly fine with how reasonable code would use the API. * There's a global table for shared unnamed semaphores now. ATM a semaphore is leaked when no one explicitly destroys it (just as with named sems). * Enforce per-team and global semaphore number limits. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25362 a95241bf-73f2-0310-859d-f6bbb57e9c96
39 lines
798 B
C
39 lines
798 B
C
/*
|
|
* Copyright 2008, Haiku, Inc.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _SEMAPHORE_H_
|
|
#define _SEMAPHORE_H_
|
|
|
|
#include <stdint.h>
|
|
#include <sys/cdefs.h>
|
|
#include <time.h>
|
|
|
|
|
|
typedef struct {
|
|
int32_t id;
|
|
int32_t _padding[3];
|
|
} 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);
|
|
int sem_timedwait(sem_t* semaphore, const struct timespec* timeout);
|
|
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_ */
|