Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 41083
b: refs/heads/master
c: ee3ce19
h: refs/heads/master
i:
  41081: 9b2bdcf
  41079: 7bf53b9
v: v3
  • Loading branch information
Alexey Dobriyan authored and Linus Torvalds committed Nov 25, 2006
1 parent 4d2c5a7 commit 9469c7e
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5e66b0b5f187c811419ff10cfb5668c028a64d57
refs/heads/master: ee3ce191e8eaa4cc15c51a28b34143b36404c4f5
37 changes: 32 additions & 5 deletions trunk/include/linux/irqflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
#ifndef _LINUX_TRACE_IRQFLAGS_H
#define _LINUX_TRACE_IRQFLAGS_H

#define BUILD_CHECK_IRQ_FLAGS(flags) \
do { \
BUILD_BUG_ON(sizeof(flags) != sizeof(unsigned long)); \
typecheck(unsigned long, flags); \
} while (0)

#ifdef CONFIG_TRACE_IRQFLAGS
extern void trace_hardirqs_on(void);
extern void trace_hardirqs_off(void);
Expand Down Expand Up @@ -50,10 +56,15 @@
#define local_irq_disable() \
do { raw_local_irq_disable(); trace_hardirqs_off(); } while (0)
#define local_irq_save(flags) \
do { raw_local_irq_save(flags); trace_hardirqs_off(); } while (0)
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
raw_local_irq_save(flags); \
trace_hardirqs_off(); \
} while (0)

#define local_irq_restore(flags) \
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
if (raw_irqs_disabled_flags(flags)) { \
raw_local_irq_restore(flags); \
trace_hardirqs_off(); \
Expand All @@ -69,8 +80,16 @@
*/
# define raw_local_irq_disable() local_irq_disable()
# define raw_local_irq_enable() local_irq_enable()
# define raw_local_irq_save(flags) local_irq_save(flags)
# define raw_local_irq_restore(flags) local_irq_restore(flags)
# define raw_local_irq_save(flags) \
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
local_irq_save(flags); \
} while (0)
# define raw_local_irq_restore(flags) \
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
local_irq_restore(flags); \
} while (0)
#endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */

#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
Expand All @@ -80,7 +99,11 @@
raw_safe_halt(); \
} while (0)

#define local_save_flags(flags) raw_local_save_flags(flags)
#define local_save_flags(flags) \
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
raw_local_save_flags(flags); \
} while (0)

#define irqs_disabled() \
({ \
Expand All @@ -90,7 +113,11 @@
raw_irqs_disabled_flags(flags); \
})

#define irqs_disabled_flags(flags) raw_irqs_disabled_flags(flags)
#define irqs_disabled_flags(flags) \
({ \
BUILD_CHECK_IRQ_FLAGS(flags); \
raw_irqs_disabled_flags(flags); \
})
#endif /* CONFIG_X86 */

#endif
53 changes: 44 additions & 9 deletions trunk/include/linux/spinlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <linux/thread_info.h>
#include <linux/kernel.h>
#include <linux/stringify.h>
#include <linux/irqflags.h>

#include <asm/system.h>

Expand Down Expand Up @@ -183,13 +184,37 @@ do { \
#define read_lock(lock) _read_lock(lock)

#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
#define spin_lock_irqsave(lock, flags) flags = _spin_lock_irqsave(lock)
#define read_lock_irqsave(lock, flags) flags = _read_lock_irqsave(lock)
#define write_lock_irqsave(lock, flags) flags = _write_lock_irqsave(lock)
#define spin_lock_irqsave(lock, flags) \
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
flags = _spin_lock_irqsave(lock); \
} while (0)
#define read_lock_irqsave(lock, flags) \
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
flags = _read_lock_irqsave(lock); \
} while (0)
#define write_lock_irqsave(lock, flags) \
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
flags = _write_lock_irqsave(lock); \
} while (0)
#else
#define spin_lock_irqsave(lock, flags) _spin_lock_irqsave(lock, flags)
#define read_lock_irqsave(lock, flags) _read_lock_irqsave(lock, flags)
#define write_lock_irqsave(lock, flags) _write_lock_irqsave(lock, flags)
#define spin_lock_irqsave(lock, flags) \
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
_spin_lock_irqsave(lock, flags); \
} while (0)
#define read_lock_irqsave(lock, flags) \
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
_read_lock_irqsave(lock, flags); \
} while (0)
#define write_lock_irqsave(lock, flags) \
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
_write_lock_irqsave(lock, flags); \
} while (0)
#endif

#define spin_lock_irq(lock) _spin_lock_irq(lock)
Expand Down Expand Up @@ -225,15 +250,24 @@ do { \
#endif

#define spin_unlock_irqrestore(lock, flags) \
_spin_unlock_irqrestore(lock, flags)
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
_spin_unlock_irqrestore(lock, flags); \
} while (0)
#define spin_unlock_bh(lock) _spin_unlock_bh(lock)

#define read_unlock_irqrestore(lock, flags) \
_read_unlock_irqrestore(lock, flags)
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
_read_unlock_irqrestore(lock, flags); \
} while (0)
#define read_unlock_bh(lock) _read_unlock_bh(lock)

#define write_unlock_irqrestore(lock, flags) \
_write_unlock_irqrestore(lock, flags)
do { \
BUILD_CHECK_IRQ_FLAGS(flags); \
_write_unlock_irqrestore(lock, flags); \
} while (0)
#define write_unlock_bh(lock) _write_unlock_bh(lock)

#define spin_trylock_bh(lock) __cond_lock(lock, _spin_trylock_bh(lock))
Expand All @@ -247,6 +281,7 @@ do { \

#define spin_trylock_irqsave(lock, flags) \
({ \
BUILD_CHECK_IRQ_FLAGS(flags); \
local_irq_save(flags); \
spin_trylock(lock) ? \
1 : ({ local_irq_restore(flags); 0; }); \
Expand Down

0 comments on commit 9469c7e

Please sign in to comment.