forked from fantaisie-software/purebasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsvsem.h
More file actions
55 lines (45 loc) · 1.23 KB
/
svsem.h
File metadata and controls
55 lines (45 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef MBA_SVSEM_H
#define MBA_SVSEM_H
/* svsem - POSIX-like semaphores implemented using SysV semaphores
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
#include <sys/sem.h> /* for SEM_UNDO */
#include <fcntl.h>
#include <mba/pool.h>
#include <mba/varray.h>
#define O_UNDO 0x80000
typedef struct {
int id;
int num;
int flags;
char name[17]; /* only svsem_create/destroy can access this member! */
} svsem_t;
struct _svs_data { /* context data for svsem pool */
int id;
int val;
struct varray sems;
char name[17];
};
int svsem_create(svsem_t *sem, int value, int undo);
int svsem_destroy(svsem_t *sem);
int svsem_open(svsem_t *sem, const char *path, int oflag, ... /* mode_t mode, int value */);
int svsem_close(svsem_t *sem);
int svsem_remove(svsem_t *sem);
int svsem_pool_create(struct pool *p,
unsigned int max_size,
unsigned int value, int undo,
struct allocator *al);
int svsem_pool_destroy(struct pool *p);
int svsem_wait(svsem_t *sem);
int svsem_trywait(svsem_t *sem);
int svsem_post(svsem_t *sem);
int svsem_post_multiple(svsem_t *sem, int count);
int svsem_getvalue(svsem_t *sem, int *value);
int svsem_setvalue(svsem_t *sem, int value);
#ifdef __cplusplus
}
#endif
#endif /* MBA_SVSEM_H */