percpu.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 PER_CPU_ATTRIBUTES __attribute__((__model__ (__small__)))
  14. #endif
  15. #define DECLARE_PER_CPU(type, name) \
  16. extern PER_CPU_ATTRIBUTES __typeof__(type) per_cpu__##name
  17. /*
  18. * Pretty much a literal copy of asm-generic/percpu.h, except that percpu_modcopy() is an
  19. * external routine, to avoid include-hell.
  20. */
  21. #ifdef CONFIG_SMP
  22. extern unsigned long __per_cpu_offset[NR_CPUS];
  23. #define per_cpu_offset(x) (__per_cpu_offset[x])
  24. /* Equal to __per_cpu_offset[smp_processor_id()], but faster to access: */
  25. DECLARE_PER_CPU(unsigned long, local_per_cpu_offset);
  26. #define per_cpu(var, cpu) (*RELOC_HIDE(&per_cpu__##var, __per_cpu_offset[cpu]))
  27. #define __get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
  28. #define __raw_get_cpu_var(var) (*RELOC_HIDE(&per_cpu__##var, __ia64_per_cpu_var(local_per_cpu_offset)))
  29. extern void percpu_modcopy(void *pcpudst, const void *src, unsigned long size);
  30. extern void setup_per_cpu_areas (void);
  31. extern void *per_cpu_init(void);
  32. #else /* ! SMP */
  33. #define per_cpu(var, cpu) (*((void)(cpu), &per_cpu__##var))
  34. #define __get_cpu_var(var) per_cpu__##var
  35. #define __raw_get_cpu_var(var) per_cpu__##var
  36. #define per_cpu_init() (__phys_per_cpu_start)
  37. #endif /* SMP */
  38. /*
  39. * Be extremely careful when taking the address of this variable! Due to virtual
  40. * remapping, it is different from the canonical address returned by __get_cpu_var(var)!
  41. * On the positive side, using __ia64_per_cpu_var() instead of __get_cpu_var() is slightly
  42. * more efficient.
  43. */
  44. #define __ia64_per_cpu_var(var) (per_cpu__##var)
  45. #endif /* !__ASSEMBLY__ */
  46. #endif /* _ASM_IA64_PERCPU_H */