cache.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef __LINUX_CACHE_H
  2. #define __LINUX_CACHE_H
  3. #include <linux/kernel.h>
  4. #include <linux/config.h>
  5. #include <asm/cache.h>
  6. #ifndef L1_CACHE_ALIGN
  7. #define L1_CACHE_ALIGN(x) ALIGN(x, L1_CACHE_BYTES)
  8. #endif
  9. #ifndef SMP_CACHE_BYTES
  10. #define SMP_CACHE_BYTES L1_CACHE_BYTES
  11. #endif
  12. #if defined(CONFIG_X86) || defined(CONFIG_SPARC64)
  13. #define __read_mostly __attribute__((__section__(".data.read_mostly")))
  14. #else
  15. #define __read_mostly
  16. #endif
  17. #ifndef ____cacheline_aligned
  18. #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
  19. #endif
  20. #ifndef ____cacheline_aligned_in_smp
  21. #ifdef CONFIG_SMP
  22. #define ____cacheline_aligned_in_smp ____cacheline_aligned
  23. #else
  24. #define ____cacheline_aligned_in_smp
  25. #endif /* CONFIG_SMP */
  26. #endif
  27. #ifndef __cacheline_aligned
  28. #define __cacheline_aligned \
  29. __attribute__((__aligned__(SMP_CACHE_BYTES), \
  30. __section__(".data.cacheline_aligned")))
  31. #endif /* __cacheline_aligned */
  32. #ifndef __cacheline_aligned_in_smp
  33. #ifdef CONFIG_SMP
  34. #define __cacheline_aligned_in_smp __cacheline_aligned
  35. #else
  36. #define __cacheline_aligned_in_smp
  37. #endif /* CONFIG_SMP */
  38. #endif
  39. #if !defined(____cacheline_maxaligned_in_smp)
  40. #if defined(CONFIG_SMP)
  41. #define ____cacheline_maxaligned_in_smp \
  42. __attribute__((__aligned__(1 << (L1_CACHE_SHIFT_MAX))))
  43. #else
  44. #define ____cacheline_maxaligned_in_smp
  45. #endif
  46. #endif
  47. #endif /* __LINUX_CACHE_H */