OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [include/] [asm-s390/] [semaphore.h] - Blame information for rev 1774

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1276 phoenix
/*
2
 *  include/asm-s390/semaphore.h
3
 *
4
 *  S390 version
5
 *    Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6
 *
7
 *  Derived from "include/asm-i386/semaphore.h"
8
 *    (C) Copyright 1996 Linus Torvalds
9
 */
10
 
11
#ifndef _S390_SEMAPHORE_H
12
#define _S390_SEMAPHORE_H
13
 
14
#include <asm/system.h>
15
#include <asm/atomic.h>
16
#include <linux/wait.h>
17
#include <linux/rwsem.h>
18
 
19
struct semaphore {
20
        atomic_t count;
21
        int sleepers;
22
        wait_queue_head_t wait;
23
};
24
 
25
#define __SEM_DEBUG_INIT(name)
26
 
27
#define __SEMAPHORE_INITIALIZER(name,count) \
28
{ ATOMIC_INIT(count), 0, __WAIT_QUEUE_HEAD_INITIALIZER((name).wait) \
29
        __SEM_DEBUG_INIT(name) }
30
 
31
#define __MUTEX_INITIALIZER(name) \
32
        __SEMAPHORE_INITIALIZER(name,1)
33
 
34
#define __DECLARE_SEMAPHORE_GENERIC(name,count) \
35
        struct semaphore name = __SEMAPHORE_INITIALIZER(name,count)
36
 
37
#define DECLARE_MUTEX(name) __DECLARE_SEMAPHORE_GENERIC(name,1)
38
#define DECLARE_MUTEX_LOCKED(name) __DECLARE_SEMAPHORE_GENERIC(name,0)
39
 
40
static inline void sema_init (struct semaphore *sem, int val)
41
{
42
        *sem = (struct semaphore)__SEMAPHORE_INITIALIZER((*sem),val);
43
}
44
 
45
static inline void init_MUTEX (struct semaphore *sem)
46
{
47
        sema_init(sem, 1);
48
}
49
 
50
static inline void init_MUTEX_LOCKED (struct semaphore *sem)
51
{
52
        sema_init(sem, 0);
53
}
54
 
55
asmlinkage void __down_failed(void /* special register calling convention */);
56
asmlinkage int  __down_failed_interruptible(void  /* params in registers */);
57
asmlinkage int  __down_failed_trylock(void  /* params in registers */);
58
asmlinkage void __up_wakeup(void /* special register calling convention */);
59
 
60
asmlinkage void __down(struct semaphore * sem);
61
asmlinkage int  __down_interruptible(struct semaphore * sem);
62
asmlinkage int  __down_trylock(struct semaphore * sem);
63
asmlinkage void __up(struct semaphore * sem);
64
 
65
static inline void down(struct semaphore * sem)
66
{
67
        if (atomic_dec_return(&sem->count) < 0)
68
                __down(sem);
69
}
70
 
71
static inline int down_interruptible(struct semaphore * sem)
72
{
73
        int ret = 0;
74
 
75
        if (atomic_dec_return(&sem->count) < 0)
76
                ret = __down_interruptible(sem);
77
        return ret;
78
}
79
 
80
static inline int down_trylock(struct semaphore * sem)
81
{
82
        int ret = 0;
83
 
84
        if (atomic_dec_return(&sem->count) < 0)
85
                ret = __down_trylock(sem);
86
        return ret;
87
}
88
 
89
static inline void up(struct semaphore * sem)
90
{
91
        if (atomic_inc_return(&sem->count) <= 0)
92
                __up(sem);
93
}
94
 
95
static inline int sem_getcount(struct semaphore *sem)
96
{
97
        return atomic_read(&sem->count);
98
}
99
 
100
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.