Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
spinlock.h File Reference
#include <linux/typecheck.h>
#include <linux/preempt.h>
#include <linux/linkage.h>
#include <linux/compiler.h>
#include <linux/irqflags.h>
#include <linux/thread_info.h>
#include <linux/kernel.h>
#include <linux/stringify.h>
#include <linux/bottom_half.h>
#include <asm/barrier.h>
#include <linux/spinlock_types.h>
#include <linux/spinlock_up.h>
#include <linux/rwlock.h>
#include <linux/spinlock_api_up.h>
#include <linux/atomic.h>

Go to the source code of this file.

Macros

#define LOCK_SECTION_NAME   ".text..lock."KBUILD_BASENAME
 
#define LOCK_SECTION_START(extra)
 
#define LOCK_SECTION_END   ".previous\n\t"
 
#define __lockfunc   __attribute__((section(".spinlock.text")))
 
#define raw_spin_lock_init(lock)   do { *(lock) = __RAW_SPIN_LOCK_UNLOCKED(lock); } while (0)
 
#define raw_spin_is_locked(lock)   arch_spin_is_locked(&(lock)->raw_lock)
 
#define raw_spin_is_contended(lock)   (((void)(lock), 0))
 
#define raw_spin_unlock_wait(lock)   arch_spin_unlock_wait(&(lock)->raw_lock)
 
#define raw_spin_trylock(lock)   __cond_lock(lock, _raw_spin_trylock(lock))
 
#define raw_spin_lock(lock)   _raw_spin_lock(lock)
 
#define raw_spin_lock_nested(lock, subclass)   _raw_spin_lock(lock)
 
#define raw_spin_lock_nest_lock(lock, nest_lock)   _raw_spin_lock(lock)
 
#define raw_spin_lock_irqsave(lock, flags)
 
#define raw_spin_lock_irqsave_nested(lock, flags, subclass)   raw_spin_lock_irqsave(lock, flags)
 
#define raw_spin_lock_irq(lock)   _raw_spin_lock_irq(lock)
 
#define raw_spin_lock_bh(lock)   _raw_spin_lock_bh(lock)
 
#define raw_spin_unlock(lock)   _raw_spin_unlock(lock)
 
#define raw_spin_unlock_irq(lock)   _raw_spin_unlock_irq(lock)
 
#define raw_spin_unlock_irqrestore(lock, flags)
 
#define raw_spin_unlock_bh(lock)   _raw_spin_unlock_bh(lock)
 
#define raw_spin_trylock_bh(lock)   __cond_lock(lock, _raw_spin_trylock_bh(lock))
 
#define raw_spin_trylock_irq(lock)
 
#define raw_spin_trylock_irqsave(lock, flags)
 
#define raw_spin_can_lock(lock)   (!raw_spin_is_locked(lock))
 
#define spin_lock_init(_lock)
 
#define spin_lock_nested(lock, subclass)
 
#define spin_lock_nest_lock(lock, nest_lock)
 
#define spin_lock_irqsave(lock, flags)
 
#define spin_lock_irqsave_nested(lock, flags, subclass)
 
#define spin_trylock_irqsave(lock, flags)
 
#define assert_spin_locked(lock)   assert_raw_spin_locked(&(lock)->rlock)
 
#define atomic_dec_and_lock(atomic, lock)   __cond_lock(lock, _atomic_dec_and_lock(atomic, lock))
 

Functions

int _atomic_dec_and_lock (atomic_t *atomic, spinlock_t *lock)
 

Macro Definition Documentation

#define __lockfunc   __attribute__((section(".spinlock.text")))

Definition at line 76 of file spinlock.h.

#define assert_spin_locked (   lock)    assert_raw_spin_locked(&(lock)->rlock)

Definition at line 378 of file spinlock.h.

#define atomic_dec_and_lock (   atomic,
  lock 
)    __cond_lock(lock, _atomic_dec_and_lock(atomic, lock))

Definition at line 394 of file spinlock.h.

#define LOCK_SECTION_END   ".previous\n\t"

Definition at line 73 of file spinlock.h.

#define LOCK_SECTION_NAME   ".text..lock."KBUILD_BASENAME

Definition at line 64 of file spinlock.h.

#define LOCK_SECTION_START (   extra)
Value:
".subsection 1\n\t" \
extra \
".ifndef " LOCK_SECTION_NAME "\n\t" \
LOCK_SECTION_NAME ":\n\t" \
".endif\n"

Definition at line 66 of file spinlock.h.

#define raw_spin_can_lock (   lock)    (!raw_spin_is_locked(lock))

raw_spin_can_lock - would raw_spin_trylock() succeed? : the spinlock in question.

Definition at line 254 of file spinlock.h.

#define raw_spin_is_contended (   lock)    (((void)(lock), 0))

Definition at line 116 of file spinlock.h.

#define raw_spin_is_locked (   lock)    arch_spin_is_locked(&(lock)->raw_lock)

Definition at line 107 of file spinlock.h.

#define raw_spin_lock (   lock)    _raw_spin_lock(lock)

Definition at line 170 of file spinlock.h.

#define raw_spin_lock_bh (   lock)    _raw_spin_lock_bh(lock)

Definition at line 222 of file spinlock.h.

#define raw_spin_lock_init (   lock)    do { *(lock) = __RAW_SPIN_LOCK_UNLOCKED(lock); } while (0)

Definition at line 103 of file spinlock.h.

#define raw_spin_lock_irq (   lock)    _raw_spin_lock_irq(lock)

Definition at line 221 of file spinlock.h.

#define raw_spin_lock_irqsave (   lock,
  flags 
)
Value:
do { \
typecheck(unsigned long, flags); \
_raw_spin_lock_irqsave(lock, flags); \
} while (0)

Definition at line 210 of file spinlock.h.

#define raw_spin_lock_irqsave_nested (   lock,
  flags,
  subclass 
)    raw_spin_lock_irqsave(lock, flags)

Definition at line 216 of file spinlock.h.

#define raw_spin_lock_nest_lock (   lock,
  nest_lock 
)    _raw_spin_lock(lock)

Definition at line 183 of file spinlock.h.

#define raw_spin_lock_nested (   lock,
  subclass 
)    _raw_spin_lock(lock)

Definition at line 182 of file spinlock.h.

#define raw_spin_trylock (   lock)    __cond_lock(lock, _raw_spin_trylock(lock))

Definition at line 168 of file spinlock.h.

#define raw_spin_trylock_bh (   lock)    __cond_lock(lock, _raw_spin_trylock_bh(lock))

Definition at line 233 of file spinlock.h.

#define raw_spin_trylock_irq (   lock)
Value:
({ \
local_irq_disable(); \
raw_spin_trylock(lock) ? \
1 : ({ local_irq_enable(); 0; }); \
})

Definition at line 236 of file spinlock.h.

#define raw_spin_trylock_irqsave (   lock,
  flags 
)
Value:
({ \
local_irq_save(flags); \
raw_spin_trylock(lock) ? \
1 : ({ local_irq_restore(flags); 0; }); \
})

Definition at line 243 of file spinlock.h.

#define raw_spin_unlock (   lock)    _raw_spin_unlock(lock)

Definition at line 223 of file spinlock.h.

#define raw_spin_unlock_bh (   lock)    _raw_spin_unlock_bh(lock)

Definition at line 231 of file spinlock.h.

#define raw_spin_unlock_irq (   lock)    _raw_spin_unlock_irq(lock)

Definition at line 224 of file spinlock.h.

#define raw_spin_unlock_irqrestore (   lock,
  flags 
)
Value:
do { \
typecheck(unsigned long, flags); \
_raw_spin_unlock_irqrestore(lock, flags); \
} while (0)

Definition at line 226 of file spinlock.h.

#define raw_spin_unlock_wait (   lock)    arch_spin_unlock_wait(&(lock)->raw_lock)

raw_spin_unlock_wait - wait until the spinlock gets unlocked : the spinlock in question.

Definition at line 129 of file spinlock.h.

#define spin_lock_init (   _lock)
Value:
do { \
spinlock_check(_lock); \
raw_spin_lock_init(&(_lock)->rlock); \
} while (0)

Definition at line 277 of file spinlock.h.

#define spin_lock_irqsave (   lock,
  flags 
)
Value:
do { \
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
} while (0)

Definition at line 313 of file spinlock.h.

#define spin_lock_irqsave_nested (   lock,
  flags,
  subclass 
)
Value:
do { \
raw_spin_lock_irqsave_nested(spinlock_check(lock), flags, subclass); \
} while (0)

Definition at line 318 of file spinlock.h.

#define spin_lock_nest_lock (   lock,
  nest_lock 
)
Value:
do { \
raw_spin_lock_nest_lock(spinlock_check(lock), nest_lock); \
} while (0)

Definition at line 303 of file spinlock.h.

#define spin_lock_nested (   lock,
  subclass 
)
Value:
do { \
raw_spin_lock_nested(spinlock_check(lock), subclass); \
} while (0)

Definition at line 298 of file spinlock.h.

#define spin_trylock_irqsave (   lock,
  flags 
)
Value:
({ \
raw_spin_trylock_irqsave(spinlock_check(lock), flags); \
})

Definition at line 353 of file spinlock.h.

Function Documentation

int _atomic_dec_and_lock ( atomic_t atomic,
spinlock_t lock 
)

atomic_dec_and_lock - lock on reaching reference count zero : the atomic counter : the spinlock in question

Decrements by 1. If the result is 0, returns true and locks . Returns false for all other cases.

Definition at line 20 of file dec_and_lock.c.