linux/include/linux/rwlock.h

#ifndef __LINUX_RWLOCK_H
#define __LINUX_RWLOCK_H

#ifndef __LINUX_INSIDE_SPINLOCK_H
# error "please don't include this file directly"
#endif

/*
 * rwlock related methods
 *
 * split out from spinlock.h
 *
 * portions Copyright 2005, Red Hat, Inc., Ingo Molnar
 * Released under the General Public License (GPL).
 */

#ifdef CONFIG_DEBUG_SPINLOCK
  extern void __rwlock_init(rwlock_t *lock, const char *name,
			    struct lock_class_key *key);
#define rwlock_init(lock)
#else
#define rwlock_init
#endif

#ifdef CONFIG_DEBUG_SPINLOCK
 extern void do_raw_read_lock(rwlock_t *lock) __acquires();
 extern int do_raw_read_trylock(rwlock_t *lock);
 extern void do_raw_read_unlock(rwlock_t *lock) __releases();
 extern void do_raw_write_lock(rwlock_t *lock) __acquires();
 extern int do_raw_write_trylock(rwlock_t *lock);
 extern void do_raw_write_unlock(rwlock_t *lock) __releases();
#else
#define do_raw_read_lock
#define do_raw_read_trylock
#define do_raw_read_unlock
#define do_raw_write_lock
#define do_raw_write_trylock
#define do_raw_write_unlock
#endif

/*
 * Define the various rw_lock methods.  Note we define these
 * regardless of whether CONFIG_SMP or CONFIG_PREEMPT are set. The various
 * methods are defined as nops in the case they are not required.
 */
#define read_trylock(lock)
#define write_trylock(lock)

#define write_lock(lock)
#define read_lock(lock)

#ifdef CONFIG_DEBUG_LOCK_ALLOC
#define write_lock_nested(lock, subclass)
#else
#define write_lock_nested
#endif

#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)

#define read_lock_irqsave(lock, flags)
#define write_lock_irqsave(lock, flags)

#else

#define read_lock_irqsave
#define write_lock_irqsave

#endif

#define read_lock_irq(lock)
#define read_lock_bh(lock)
#define write_lock_irq(lock)
#define write_lock_bh(lock)
#define read_unlock(lock)
#define write_unlock(lock)
#define read_unlock_irq(lock)
#define write_unlock_irq(lock)

#define read_unlock_irqrestore(lock, flags)
#define read_unlock_bh(lock)

#define write_unlock_irqrestore(lock, flags)
#define write_unlock_bh(lock)

#define write_trylock_irqsave(lock, flags)

#ifdef arch_rwlock_is_contended
#define rwlock_is_contended(lock)
#else
#define rwlock_is_contended
#endif /* arch_rwlock_is_contended */

#endif /* __LINUX_RWLOCK_H */