Import 2.3.18pre1
[davej-history.git] / include / asm-alpha / hardirq.h
blob31cdbac06374a255a50b55afd7d881d8364faa81
1 #ifndef _ALPHA_HARDIRQ_H
2 #define _ALPHA_HARDIRQ_H
4 /* Initially just a straight copy of the i386 code. */
6 #include <linux/threads.h>
8 #ifndef __SMP__
9 extern int __local_irq_count;
10 #define local_irq_count(cpu) ((void)(cpu), __local_irq_count)
11 #else
12 #define local_irq_count(cpu) (cpu_data[cpu].irq_count)
13 #endif
16 * Are we in an interrupt context? Either doing bottom half
17 * or hardware interrupt processing?
20 #define in_interrupt() \
21 ({ \
22 int __cpu = smp_processor_id(); \
23 (local_irq_count(__cpu) + local_bh_count(__cpu)) != 0; \
26 #ifndef __SMP__
28 #define hardirq_trylock(cpu) (local_irq_count(cpu) == 0)
29 #define hardirq_endlock(cpu) ((void) 0)
31 #define hardirq_enter(cpu, irq) (local_irq_count(cpu)++)
32 #define hardirq_exit(cpu, irq) (local_irq_count(cpu)--)
34 #define synchronize_irq() barrier()
36 #else
38 #include <asm/atomic.h>
39 #include <linux/spinlock.h>
40 #include <asm/smp.h>
42 extern int global_irq_holder;
43 extern spinlock_t global_irq_lock;
44 extern atomic_t global_irq_count;
46 static inline void release_irqlock(int cpu)
48 /* if we didn't own the irq lock, just ignore.. */
49 if (global_irq_holder == cpu) {
50 global_irq_holder = NO_PROC_ID;
51 spin_unlock(&global_irq_lock);
55 static inline void hardirq_enter(int cpu, int irq)
57 ++local_irq_count(cpu);
58 atomic_inc(&global_irq_count);
61 static inline void hardirq_exit(int cpu, int irq)
63 atomic_dec(&global_irq_count);
64 --local_irq_count(cpu);
67 static inline int hardirq_trylock(int cpu)
69 return (!atomic_read(&global_irq_count)
70 && !spin_is_locked(&global_irq_lock));
73 #define hardirq_endlock(cpu) ((void)0)
75 extern void synchronize_irq(void);
77 #endif /* __SMP__ */
78 #endif /* _ALPHA_HARDIRQ_H */