Luca's patch ported
[cbs-scheduler.git] / include / linux / irqflags.h
blob13e1c83a376022ea292d1a25afb0e895fab75ccb
1 /*
2 * include/linux/irqflags.h
4 * IRQ flags tracing: follow the state of the hardirq and softirq flags and
5 * provide callbacks for transitions between ON and OFF states.
7 * This file gets included from lowlevel asm headers too, to provide
8 * wrapped versions of the local_irq_*() APIs, based on the
9 * raw_local_irq_*() macros from the lowlevel headers.
11 #ifndef _LINUX_TRACE_IRQFLAGS_H
12 #define _LINUX_TRACE_IRQFLAGS_H
14 #include <linux/typecheck.h>
16 /* dummy wrapper for now: */
17 #define BUILD_CHECK_IRQ_FLAGS(flags)
19 #ifdef CONFIG_TRACE_IRQFLAGS
20 extern void trace_softirqs_on(unsigned long ip);
21 extern void trace_softirqs_off(unsigned long ip);
22 extern void trace_hardirqs_on(void);
23 extern void trace_hardirqs_off(void);
24 # define trace_hardirq_context(p) ((p)->hardirq_context)
25 # define trace_softirq_context(p) ((p)->softirq_context)
26 # define trace_hardirqs_enabled(p) ((p)->hardirqs_enabled)
27 # define trace_softirqs_enabled(p) ((p)->softirqs_enabled)
28 # define trace_hardirq_enter() do { current->hardirq_context++; } while (0)
29 # define trace_hardirq_exit() do { current->hardirq_context--; } while (0)
30 # define lockdep_softirq_enter() do { current->softirq_context++; } while (0)
31 # define lockdep_softirq_exit() do { current->softirq_context--; } while (0)
32 # define INIT_TRACE_IRQFLAGS .softirqs_enabled = 1,
33 #else
34 # define trace_hardirqs_on() do { } while (0)
35 # define trace_hardirqs_off() do { } while (0)
36 # define trace_softirqs_on(ip) do { } while (0)
37 # define trace_softirqs_off(ip) do { } while (0)
38 # define trace_hardirq_context(p) 0
39 # define trace_softirq_context(p) 0
40 # define trace_hardirqs_enabled(p) 0
41 # define trace_softirqs_enabled(p) 0
42 # define trace_hardirq_enter() do { } while (0)
43 # define trace_hardirq_exit() do { } while (0)
44 # define lockdep_softirq_enter() do { } while (0)
45 # define lockdep_softirq_exit() do { } while (0)
46 # define INIT_TRACE_IRQFLAGS
47 #endif
49 #if defined(CONFIG_IRQSOFF_TRACER) || \
50 defined(CONFIG_PREEMPT_TRACER)
51 extern void stop_critical_timings(void);
52 extern void start_critical_timings(void);
53 #else
54 # define stop_critical_timings() do { } while (0)
55 # define start_critical_timings() do { } while (0)
56 #endif
58 #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
60 #include <asm/irqflags.h>
62 #define local_irq_enable() \
63 do { trace_hardirqs_on(); raw_local_irq_enable(); } while (0)
64 #define local_irq_disable() \
65 do { raw_local_irq_disable(); trace_hardirqs_off(); } while (0)
66 #define local_irq_save(flags) \
67 do { \
68 typecheck(unsigned long, flags); \
69 raw_local_irq_save(flags); \
70 trace_hardirqs_off(); \
71 } while (0)
74 #define local_irq_restore(flags) \
75 do { \
76 typecheck(unsigned long, flags); \
77 if (raw_irqs_disabled_flags(flags)) { \
78 raw_local_irq_restore(flags); \
79 trace_hardirqs_off(); \
80 } else { \
81 trace_hardirqs_on(); \
82 raw_local_irq_restore(flags); \
83 } \
84 } while (0)
85 #else /* !CONFIG_TRACE_IRQFLAGS_SUPPORT */
87 * The local_irq_*() APIs are equal to the raw_local_irq*()
88 * if !TRACE_IRQFLAGS.
90 # define raw_local_irq_disable() local_irq_disable()
91 # define raw_local_irq_enable() local_irq_enable()
92 # define raw_local_irq_save(flags) \
93 do { \
94 typecheck(unsigned long, flags); \
95 local_irq_save(flags); \
96 } while (0)
97 # define raw_local_irq_restore(flags) \
98 do { \
99 typecheck(unsigned long, flags); \
100 local_irq_restore(flags); \
101 } while (0)
102 #endif /* CONFIG_TRACE_IRQFLAGS_SUPPORT */
104 #ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT
105 #define safe_halt() \
106 do { \
107 trace_hardirqs_on(); \
108 raw_safe_halt(); \
109 } while (0)
111 #define local_save_flags(flags) \
112 do { \
113 typecheck(unsigned long, flags); \
114 raw_local_save_flags(flags); \
115 } while (0)
117 #define irqs_disabled() \
118 ({ \
119 unsigned long _flags; \
121 raw_local_save_flags(_flags); \
122 raw_irqs_disabled_flags(_flags); \
125 #define irqs_disabled_flags(flags) \
126 ({ \
127 typecheck(unsigned long, flags); \
128 raw_irqs_disabled_flags(flags); \
130 #endif /* CONFIG_X86 */
132 #endif