Subversion Repositories shark

Rev

Rev 847 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
847 giacomo 1
#ifndef _I386_SEMAPHORE_H
2
#define _I386_SEMAPHORE_H
3
 
4
#include <linux/linkage.h>
5
 
6
#ifdef __KERNEL__
7
 
8
#include <asm/system.h>
9
#include <asm/atomic.h>
10
#include <linux/wait.h>
11
#include <linux/rwsem.h>
12
 
13
typedef int sem_t;  /* sem.h */
14
int sem_wait(sem_t *sem);
15
int sem_init(sem_t *sem, int pshared, unsigned int value);
16
int sem_post(sem_t *sem);
17
int sem_trywait(sem_t *s);
18
 
19
struct semaphore {
20
        int init;
21
        int start_value;
22
        sem_t shark_sem;
23
};
24
 
25
#define DECLARE_MUTEX(name) struct semaphore name = { .init=0, .start_value=1}
26
#define DECLARE_MUTEX_LOCKED(name) struct semaphore name= { .init=0, .start_value=0}
27
 
28
static inline void down(struct semaphore * sem)
29
{
30
/*        if (sem->init == 0)
31
        {
32
                sem_init(&sem->shark_sem, 0, sem->start_value);
33
                sem->init = 1;
34
        }
35
        sem_wait(&sem->shark_sem);
36
*/
37
}
38
 
39
static inline void up(struct semaphore * sem)
40
{
41
/*
42
        sem_post(&sem->shark_sem);
43
*/
44
}
45
 
46
static inline void init_MUTEX (struct semaphore *sem)
47
{
48
/*
49
        sem_init(&sem->shark_sem, 0, 1);
50
*/
51
}
52
 
53
static inline void init_MUTEX_LOCKED (struct semaphore *sem)
54
{      
55
/*
56
        sem_init(&sem->shark_sem, 0, 0);
57
*/
58
}
59
 
60
static inline int down_trylock(struct semaphore * sem)
61
{      
62
        return 0;
63
/*
64
        return ( sem_trywait(&sem->shark_sem) );
65
*/
66
}
67
 
68
#endif
69
#endif