cache.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. #ifndef ____cacheline_aligned
  13. #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
  14. #endif
  15. #ifndef ____cacheline_aligned_in_smp
  16. #ifdef CONFIG_SMP
  17. #define ____cacheline_aligned_in_smp ____cacheline_aligned
  18. #else
  19. #define ____cacheline_aligned_in_smp
  20. #endif /* CONFIG_SMP */
  21. #endif
  22. #ifndef __cacheline_aligned
  23. #define __cacheline_aligned \
  24. __attribute__((__aligned__(SMP_CACHE_BYTES), \
  25. __section__(".data.cacheline_aligned")))
  26. #endif /* __cacheline_aligned */
  27. #ifndef __cacheline_aligned_in_smp
  28. #ifdef CONFIG_SMP
  29. #define __cacheline_aligned_in_smp __cacheline_aligned
  30. #else
  31. #define __cacheline_aligned_in_smp
  32. #endif /* CONFIG_SMP */
  33. #endif
  34. #if !defined(____cacheline_maxaligned_in_smp)
  35. #if defined(CONFIG_SMP)
  36. #define ____cacheline_maxaligned_in_smp \
  37. __attribute__((__aligned__(1 << (L1_CACHE_SHIFT_MAX))))
  38. #else
  39. #define ____cacheline_maxaligned_in_smp
  40. #endif
  41. #endif
  42. #endif /* __LINUX_CACHE_H */