1 /**************************************************************************** 2 **************************************************************************** 3 *** 4 *** This header was automatically generated from a Linux kernel header 5 *** of the same name, to make information necessary for userspace to 6 *** call into the kernel available to libc. It contains only constants, 7 *** structures, and macros generated from the original header, and thus, 8 *** contains no copyrightable information. 9 *** 10 **************************************************************************** 11 ****************************************************************************/ 12 #ifndef __LINUX_SPINLOCK_H 13 #define __LINUX_SPINLOCK_H 14 15 #include <linux/preempt.h> 16 #include <linux/linkage.h> 17 #include <linux/compiler.h> 18 #include <linux/thread_info.h> 19 #include <linux/kernel.h> 20 #include <linux/stringify.h> 21 22 #include <asm/system.h> 23 24 #define LOCK_SECTION_NAME ".text.lock."KBUILD_BASENAME 25 26 #define LOCK_SECTION_START(extra) ".subsection 1\n\t" extra ".ifndef " LOCK_SECTION_NAME "\n\t" LOCK_SECTION_NAME ":\n\t" ".endif\n" 27 28 #define LOCK_SECTION_END ".previous\n\t" 29 30 #define __lockfunc fastcall __attribute__((section(".spinlock.text"))) 31 32 #include <linux/spinlock_types.h> 33 34 #include <linux/spinlock_up.h> 35 36 #define spin_lock_init(lock) do { *(lock) = SPIN_LOCK_UNLOCKED; } while (0) 37 38 #define rwlock_init(lock) do { *(lock) = RW_LOCK_UNLOCKED; } while (0) 39 40 #define spin_is_locked(lock) __raw_spin_is_locked(&(lock)->raw_lock) 41 42 #define spin_unlock_wait(lock) __raw_spin_unlock_wait(&(lock)->raw_lock) 43 44 #include <linux/spinlock_api_up.h> 45 46 #define _raw_spin_lock(lock) __raw_spin_lock(&(lock)->raw_lock) 47 #define _raw_spin_lock_flags(lock, flags) __raw_spin_lock_flags(&(lock)->raw_lock, *(flags)) 48 #define _raw_spin_trylock(lock) __raw_spin_trylock(&(lock)->raw_lock) 49 #define _raw_spin_unlock(lock) __raw_spin_unlock(&(lock)->raw_lock) 50 #define _raw_read_lock(rwlock) __raw_read_lock(&(rwlock)->raw_lock) 51 #define _raw_read_trylock(rwlock) __raw_read_trylock(&(rwlock)->raw_lock) 52 #define _raw_read_unlock(rwlock) __raw_read_unlock(&(rwlock)->raw_lock) 53 #define _raw_write_lock(rwlock) __raw_write_lock(&(rwlock)->raw_lock) 54 #define _raw_write_trylock(rwlock) __raw_write_trylock(&(rwlock)->raw_lock) 55 #define _raw_write_unlock(rwlock) __raw_write_unlock(&(rwlock)->raw_lock) 56 57 #define read_can_lock(rwlock) __raw_read_can_lock(&(rwlock)->raw_lock) 58 #define write_can_lock(rwlock) __raw_write_can_lock(&(rwlock)->raw_lock) 59 60 #define spin_trylock(lock) __cond_lock(_spin_trylock(lock)) 61 #define read_trylock(lock) __cond_lock(_read_trylock(lock)) 62 #define write_trylock(lock) __cond_lock(_write_trylock(lock)) 63 64 #define spin_lock(lock) _spin_lock(lock) 65 66 #define spin_lock_nested(lock, subclass) _spin_lock(lock) 67 68 #define write_lock(lock) _write_lock(lock) 69 #define read_lock(lock) _read_lock(lock) 70 71 #define spin_lock_irqsave(lock, flags) _spin_lock_irqsave(lock, flags) 72 #define read_lock_irqsave(lock, flags) _read_lock_irqsave(lock, flags) 73 #define write_lock_irqsave(lock, flags) _write_lock_irqsave(lock, flags) 74 75 #define spin_lock_irq(lock) _spin_lock_irq(lock) 76 #define spin_lock_bh(lock) _spin_lock_bh(lock) 77 78 #define read_lock_irq(lock) _read_lock_irq(lock) 79 #define read_lock_bh(lock) _read_lock_bh(lock) 80 81 #define write_lock_irq(lock) _write_lock_irq(lock) 82 #define write_lock_bh(lock) _write_lock_bh(lock) 83 84 #define spin_unlock(lock) _spin_unlock(lock) 85 #define read_unlock(lock) _read_unlock(lock) 86 #define write_unlock(lock) _write_unlock(lock) 87 #define spin_unlock_irq(lock) _spin_unlock_irq(lock) 88 #define read_unlock_irq(lock) _read_unlock_irq(lock) 89 #define write_unlock_irq(lock) _write_unlock_irq(lock) 90 91 #define spin_unlock_irqrestore(lock, flags) _spin_unlock_irqrestore(lock, flags) 92 #define spin_unlock_bh(lock) _spin_unlock_bh(lock) 93 94 #define read_unlock_irqrestore(lock, flags) _read_unlock_irqrestore(lock, flags) 95 #define read_unlock_bh(lock) _read_unlock_bh(lock) 96 97 #define write_unlock_irqrestore(lock, flags) _write_unlock_irqrestore(lock, flags) 98 #define write_unlock_bh(lock) _write_unlock_bh(lock) 99 100 #define spin_trylock_bh(lock) __cond_lock(_spin_trylock_bh(lock)) 101 102 #define spin_trylock_irq(lock) ({ local_irq_disable(); _spin_trylock(lock) ? 1 : ({ local_irq_enable(); 0; }); }) 103 104 #define spin_trylock_irqsave(lock, flags) ({ local_irq_save(flags); _spin_trylock(lock) ? 1 : ({ local_irq_restore(flags); 0; }); }) 105 106 #include <asm/atomic.h> 107 108 #define atomic_dec_and_lock(atomic, lock) __cond_lock(_atomic_dec_and_lock(atomic, lock)) 109 110 #define spin_can_lock(lock) (!spin_is_locked(lock)) 111 112 #endif 113