jump_label_ref.h 878 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef _LINUX_JUMP_LABEL_REF_H
  2. #define _LINUX_JUMP_LABEL_REF_H
  3. #include <linux/jump_label.h>
  4. #include <asm/atomic.h>
  5. #ifdef HAVE_JUMP_LABEL
  6. static inline void jump_label_inc(atomic_t *key)
  7. {
  8. if (atomic_add_return(1, key) == 1)
  9. jump_label_enable(key);
  10. }
  11. static inline void jump_label_dec(atomic_t *key)
  12. {
  13. if (atomic_dec_and_test(key))
  14. jump_label_disable(key);
  15. }
  16. #else /* !HAVE_JUMP_LABEL */
  17. static inline void jump_label_inc(atomic_t *key)
  18. {
  19. atomic_inc(key);
  20. }
  21. static inline void jump_label_dec(atomic_t *key)
  22. {
  23. atomic_dec(key);
  24. }
  25. #undef JUMP_LABEL
  26. #define JUMP_LABEL(key, label) \
  27. do { \
  28. if (unlikely(__builtin_choose_expr( \
  29. __builtin_types_compatible_p(typeof(key), atomic_t *), \
  30. atomic_read((atomic_t *)(key)), *(key)))) \
  31. goto label; \
  32. } while (0)
  33. #endif /* HAVE_JUMP_LABEL */
  34. #endif /* _LINUX_JUMP_LABEL_REF_H */