source: sbliveos2/trunk/include/linux/spinlock.h@ 200

Last change on this file since 200 was 142, checked in by ktk, 25 years ago

Import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1/* $Id: spinlock.h 142 2000-04-23 14:55:46Z ktk $ */
2
3#ifndef __LINUX_SPINLOCK_H
4#define __LINUX_SPINLOCK_H
5
6#ifdef __SMP__
7#include <asm/spinlock.h>
8
9#else /* !SMP */
10
11#define DEBUG_SPINLOCKS 0 /* 0 == no debugging, 1 == maintain lock state, 2 == full debug */
12
13/*
14 * Your basic spinlocks, allowing only a single CPU anywhere
15 *
16 * Gcc-2.7.x has a nasty bug with empty initializers.
17 */
18typedef unsigned long spinlock_t;
19
20#define SPIN_LOCK_UNLOCKED 0
21
22void spin_lock_init(spinlock_t *lock);
23void spin_lock(spinlock_t *lock);
24void spin_lock_flag(spinlock_t *lock, unsigned long *flag);
25int spin_trylock(spinlock_t *lock);
26void spin_unlock_wait(spinlock_t *lock);
27void spin_unlock(spinlock_t *lock);
28
29/*
30 * Read-write spinlocks, allowing multiple readers
31 * but only one writer.
32 *
33 * NOTE! it is quite common to have readers in interrupts
34 * but no interrupt writers. For those circumstances we
35 * can "mix" irq-safe locks - any writer needs to get a
36 * irq-safe write-lock, but readers can get non-irqsafe
37 * read-locks.
38 *
39 * Gcc-2.7.x has a nasty bug with empty initializers.
40 */
41 typedef struct { int gcc_is_buggy; } rwlock_t;
42 #define RW_LOCK_UNLOCKED { 0 }
43
44
45/*
46 * These are the generic versions of the spinlocks and read-write
47 * locks..
48 */
49
50#define spin_lock_irqsave(lock, flags) spin_lock_flag(lock, (unsigned long *)&flags)
51#define spin_lock_irq(lock) spin_lock(lock)
52#define spin_lock_bh(lock) spin_lock(lock)
53
54#define read_lock_irqsave(lock, flags) spin_lock_flag(lock, (unsigned long *)&flags)
55#define read_lock_irq(lock) spin_lock(lock)
56#define read_lock_bh(lock) spin_lock(lock)
57
58#define write_lock_irqsave(lock, flags) spin_lock_flag(lock, (unsigned long *)&flags)
59#define write_lock_irq(lock) spin_lock(lock)
60#define write_lock_bh(lock) spin_lock(lock)
61
62#define spin_unlock_irqrestore(lock, flags) spin_unlock(lock)
63#define spin_unlock_irq(lock) spin_unlock(lock)
64#define spin_unlock_bh(lock) spin_unlock(lock)
65
66#define read_unlock_irqrestore(lock, flags) spin_unlock(lock)
67#define read_unlock_irq(lock) spin_unlock(lock)
68#define read_unlock_bh(lock) spin_unlock(lock)
69
70#define write_unlock_irqrestore(lock, flags) spin_unlock(lock)
71#define write_unlock_irq(lock) spin_unlock(lock)
72#define write_unlock_bh(lock) spin_unlock(lock)
73
74#define read_lock(lock) spin_lock(lock)
75#define read_unlock(lock) spin_unlock(lock)
76#define write_lock(lock) spin_lock(lock)
77#define write_unlock(lock) spin_unlock(lock)
78
79#endif /* !SMP */
80#endif /* __LINUX_SPINLOCK_H */
Note: See TracBrowser for help on using the repository browser.