Subversion Repositories Kolibri OS

Rev

Rev 2003 | Rev 5272 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1408 serge 1
#ifndef __LINUX_SPINLOCK_API_UP_H
2
#define __LINUX_SPINLOCK_API_UP_H
3
 
4
#ifndef __LINUX_SPINLOCK_H
5
# error "please don't include this file directly"
6
#endif
7
 
8
/*
9
 * include/linux/spinlock_api_up.h
10
 *
11
 * spinlock API implementation on UP-nondebug (inlined implementation)
12
 *
13
 * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
14
 * Released under the General Public License (GPL).
15
 */
16
 
17
#define in_lock_functions(ADDR)		0
18
 
1964 serge 19
#define assert_raw_spin_locked(lock)	do { (void)(lock); } while (0)
1408 serge 20
 
21
/*
22
 * In the UP-nondebug case there's no real locking going on, so the
23
 * only thing we have to do is to keep the preempt counts and irq
24
 * flags straight, to suppress compiler warnings of unused lock
25
 * variables, and to add the proper checker annotations:
26
 */
27
#define __LOCK(lock) \
28
  do { preempt_disable(); __acquire(lock); (void)(lock); } while (0)
29
 
30
#define __LOCK_BH(lock) \
31
  do { local_bh_disable(); __LOCK(lock); } while (0)
32
 
33
#define __LOCK_IRQ(lock) \
3031 serge 34
  do { asm volatile ("cli \n"); __LOCK(lock); } while (0)
1408 serge 35
 
36
#define __LOCK_IRQSAVE(lock, flags) \
2003 serge 37
  do {                              \
38
     __asm__ __volatile__ (         \
39
     "pushf\n\t"                    \
40
     "popl %0\n\t"                  \
41
     "cli\n"                        \
42
     : "=r" (flags));               \
43
      __LOCK(lock);                 \
44
       } while (0)                  \
1408 serge 45
 
46
#define __UNLOCK(lock) \
47
  do { preempt_enable(); __release(lock); (void)(lock); } while (0)
48
 
49
#define __UNLOCK_BH(lock) \
1964 serge 50
  do { preempt_enable_no_resched(); local_bh_enable(); \
51
	  __release(lock); (void)(lock); } while (0)
1408 serge 52
 
53
#define __UNLOCK_IRQ(lock) \
3031 serge 54
  do { asm volatile ("sti \n"); __UNLOCK(lock); } while (0)
1408 serge 55
 
2003 serge 56
#define __UNLOCK_IRQRESTORE(lock, flags)    \
57
  do {                                      \
58
     if (flags & (1<<9))                    \
59
        __asm__ __volatile__ ("sti");       \
60
      __UNLOCK(lock);                       \
61
     } while (0)
1408 serge 62
 
63
#define _spin_lock(lock)			__LOCK(lock)
64
#define _spin_lock_nested(lock, subclass)	__LOCK(lock)
65
#define _read_lock(lock)			__LOCK(lock)
66
#define _write_lock(lock)			__LOCK(lock)
67
#define _spin_lock_bh(lock)			__LOCK_BH(lock)
68
#define _read_lock_bh(lock)			__LOCK_BH(lock)
69
#define _write_lock_bh(lock)			__LOCK_BH(lock)
70
#define _spin_lock_irq(lock)			__LOCK_IRQ(lock)
71
#define _read_lock_irq(lock)			__LOCK_IRQ(lock)
72
#define _write_lock_irq(lock)			__LOCK_IRQ(lock)
73
#define _spin_lock_irqsave(lock, flags)		__LOCK_IRQSAVE(lock, flags)
74
#define _read_lock_irqsave(lock, flags)		__LOCK_IRQSAVE(lock, flags)
75
#define _write_lock_irqsave(lock, flags)	__LOCK_IRQSAVE(lock, flags)
76
#define _spin_trylock(lock)			({ __LOCK(lock); 1; })
77
#define _read_trylock(lock)			({ __LOCK(lock); 1; })
78
#define _write_trylock(lock)			({ __LOCK(lock); 1; })
79
#define _spin_trylock_bh(lock)			({ __LOCK_BH(lock); 1; })
80
#define _spin_unlock(lock)			__UNLOCK(lock)
81
#define _read_unlock(lock)			__UNLOCK(lock)
82
#define _write_unlock(lock)			__UNLOCK(lock)
83
#define _spin_unlock_bh(lock)			__UNLOCK_BH(lock)
84
#define _write_unlock_bh(lock)			__UNLOCK_BH(lock)
85
#define _read_unlock_bh(lock)			__UNLOCK_BH(lock)
86
#define _spin_unlock_irq(lock)			__UNLOCK_IRQ(lock)
87
#define _read_unlock_irq(lock)			__UNLOCK_IRQ(lock)
88
#define _write_unlock_irq(lock)			__UNLOCK_IRQ(lock)
89
#define _spin_unlock_irqrestore(lock, flags)	__UNLOCK_IRQRESTORE(lock, flags)
90
#define _read_unlock_irqrestore(lock, flags)	__UNLOCK_IRQRESTORE(lock, flags)
91
#define _write_unlock_irqrestore(lock, flags)	__UNLOCK_IRQRESTORE(lock, flags)
92
 
93
#endif /* __LINUX_SPINLOCK_API_UP_H */