percpu.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #ifndef _ASM_IA64_PERCPU_H
  2. #define _ASM_IA64_PERCPU_H
  3. /*
  4. * Copyright (C) 2002-2003 Hewlett-Packard Co
  5. * David Mosberger-Tang <davidm@hpl.hp.com>
  6. */
  7. #define PERCPU_ENOUGH_ROOM PERCPU_PAGE_SIZE
  8. #ifdef __ASSEMBLY__
  9. # define THIS_CPU(var) (per_cpu__##var) /* use this to mark accesses to per-CPU variables... */
  10. #else /* !__ASSEMBLY__ */
  11. #include <linux/threads.h>
  12. #ifdef HAVE_MODEL_SMALL_ATTRIBUTE
  13. # define __SMALL_ADDR_AREA __attribute__((__model__ (__small__)))
  14. #else
  15. # define __SMALL_ADDR_AREA
  16. #endif
  17. #define DECLARE_PER_CPU(type, name) \
  18. extern __SMALL_ADDR_AREA __typeof__(type) per_cpu__##name
  19. /* Separate out the type, so (int[3], foo) works. */
  20. #define DEFINE_PER_CPU(type, name) \
  21. __attribute__((__section__(".data.percpu"))) \
  22. __SMALL_ADDR_AREA __typeof__(type) per_cpu__##name
  23. /*
  24. * Pretty much a literal copy of asm-generic/percpu.h, except that percpu_modcopy() is an
  25. * external routine, to avoid include-hell.
  26. */
  27. #ifdef CONFIG_SMP
  28. extern unsigned long __per_cpu_offset[NR_CPUS];
  29. #define per_cpu_offset(x) (__per_cpu_offset(x))
  30. /* Equal to __per_cpu_offset[smp_processor_id()], but faster to access: */
  31. DECLARE_PER_CPU(unsigned long, local_per_cpu_offset);
  32. #define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
  33. #define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
  34. #define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
  35. extern void percpu_modcopy(void *pcpudst, const void *src, unsigned long size);
  36. extern void setup_per_cpu_areas (void);
  37. extern void *per_cpu_init(void);
  38. #else /* ! SMP */
  39. #define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var))
  40. #define __get_cpu_var(var) per_cpu__##var
  41. #define __raw_get_cpu_var(var) per_cpu__##var
  42. #define per_cpu_init() (__phys_per_cpu_start)
  43. #endif /* SMP */
  44. #define EXPORT_PER_CPU_SYMBOL(var) EXPORT_SYMBOL(per_cpu__##var)
  45. #define EXPORT_PER_CPU_SYMBOL_GPL(var) EXPORT_SYMBOL_GPL(per_cpu__##var)
  46. /*
  47. * Be extremely careful when taking the address of this variable! Due to virtual
  48. * remapping, it is different from the canonical address returned by __get_cpu_var(var)!
  49. * On the positive side, using __ia64_per_cpu_var() instead of __get_cpu_var() is slightly
  50. * more efficient.
  51. */
  52. #define __ia64_per_cpu_var(var) (per_cpu__##var)
  53. #endif /* !__ASSEMBLY__ */
  54. #endif /* _ASM_IA64_PERCPU_H */