projects
/
fio.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
filehash.c: remove debug hash dump
[fio.git]
/
sem.c
1
#include <stdio.h>
2
3
#include "sem.h"
4
#include "smalloc.h"
5
6
void fio_sem_remove(struct fio_sem *sem)
7
{
8
sfree(sem);
9
}
10
11
struct fio_sem *fio_sem_init(int value)
12
{
13
struct fio_sem *sem;
14
15
sem = smalloc(sizeof(*sem));
16
if (!sem)
17
return NULL;
18
19
sem->sem_val = value;
20
21
if (!sem_init(&sem->sem, 1, value))
22
return sem;
23
24
perror("sem_init");
25
sfree(sem);
26
return NULL;
27
}
28
29
void fio_sem_down(struct fio_sem *sem)
30
{
31
sem_wait(&sem->sem);
32
}
33
34
void fio_sem_up(struct fio_sem *sem)
35
{
36
sem_post(&sem->sem);
37
}