Lines Matching refs:sem

58 static inline void sema_init (struct semaphore *sem, int val)  in sema_init()  argument
60 atomic_set(&sem->count, val); in sema_init()
61 init_waitqueue_head(&sem->wait); in sema_init()
63 sem->__magic = (long)&sem->__magic; in sema_init()
67 static inline void init_MUTEX (struct semaphore *sem) in init_MUTEX() argument
69 sema_init(sem, 1); in init_MUTEX()
72 static inline void init_MUTEX_LOCKED (struct semaphore *sem) in init_MUTEX_LOCKED() argument
74 sema_init(sem, 0); in init_MUTEX_LOCKED()
77 extern void __down(struct semaphore * sem);
78 extern int __down_interruptible(struct semaphore * sem);
79 extern void __up(struct semaphore * sem);
81 extern inline void down(struct semaphore * sem) in down() argument
84 CHECK_MAGIC(sem->__magic); in down()
90 if (atomic_dec_return(&sem->count) < 0) in down()
91 __down(sem); in down()
95 extern inline int down_interruptible(struct semaphore * sem) in down_interruptible() argument
100 CHECK_MAGIC(sem->__magic); in down_interruptible()
103 if (atomic_dec_return(&sem->count) < 0) in down_interruptible()
104 ret = __down_interruptible(sem); in down_interruptible()
109 extern inline int down_trylock(struct semaphore * sem) in down_trylock() argument
114 CHECK_MAGIC(sem->__magic); in down_trylock()
117 ret = atomic_dec_if_positive(&sem->count) < 0; in down_trylock()
122 extern inline void up(struct semaphore * sem) in up() argument
125 CHECK_MAGIC(sem->__magic); in up()
129 if (atomic_inc_return(&sem->count) <= 0) in up()
130 __up(sem); in up()
133 static inline int sem_getcount(struct semaphore *sem) in sem_getcount() argument
135 return atomic_read(&sem->count); in sem_getcount()