compiler.h 858 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef _TOOLS_LINUX_COMPILER_H_
  2. #define _TOOLS_LINUX_COMPILER_H_
  3. /* Optimization barrier */
  4. /* The "volatile" is due to gcc bugs */
  5. #define barrier() __asm__ __volatile__("": : :"memory")
  6. #ifndef __always_inline
  7. # define __always_inline inline __attribute__((always_inline))
  8. #endif
  9. #define __user
  10. #ifndef __attribute_const__
  11. # define __attribute_const__
  12. #endif
  13. #ifndef __maybe_unused
  14. # define __maybe_unused __attribute__((unused))
  15. #endif
  16. #ifndef __packed
  17. # define __packed __attribute__((__packed__))
  18. #endif
  19. #ifndef __force
  20. # define __force
  21. #endif
  22. #ifndef __weak
  23. # define __weak __attribute__((weak))
  24. #endif
  25. #ifndef likely
  26. # define likely(x) __builtin_expect(!!(x), 1)
  27. #endif
  28. #ifndef unlikely
  29. # define unlikely(x) __builtin_expect(!!(x), 0)
  30. #endif
  31. #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
  32. #endif /* _TOOLS_LINUX_COMPILER_H */