- Update Xen patches to 3.3-rc5 and c/s 1157.
[linux-flexiantxendom0-3.2.10.git] / arch / x86 / include / mach-xen / asm / smp-processor-id.h
1 #ifndef _ASM_X86_SMP_PROCESSOR_ID_H
2 #define _ASM_X86_SMP_PROCESSOR_ID_H
3
4 #if defined(CONFIG_SMP) && !defined(__ASSEMBLY__)
5
6 #include <asm/percpu.h>
7
8 DECLARE_PER_CPU(int, cpu_number);
9
10 /*
11  * This function is needed by all SMP systems. It must _always_ be valid
12  * from the initial startup. We map APIC_BASE very early in page_setup(),
13  * so this is correct in the x86 case.
14  */
15 #define raw_smp_processor_id() percpu_read(cpu_number)
16 #define safe_smp_processor_id() smp_processor_id()
17
18 #ifdef CONFIG_X86_64_SMP
19 #define stack_smp_processor_id()                                        \
20 ({                                                                      \
21         struct thread_info *ti;                                         \
22         __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK));      \
23         ti->cpu;                                                        \
24 })
25 #endif
26
27 #ifdef CONFIG_DEBUG_PREEMPT
28 extern unsigned int debug_smp_processor_id(void);
29 # define smp_processor_id() debug_smp_processor_id()
30 #else
31 # define smp_processor_id() raw_smp_processor_id()
32 #endif
33
34 #endif /* SMP && !__ASSEMBLY__ */
35
36 #endif /* _ASM_X86_SMP_PROCESSOR_ID_H */