jump_label.h 783 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef _ASM_X86_JUMP_LABEL_H
  2. #define _ASM_X86_JUMP_LABEL_H
  3. #ifdef __KERNEL__
  4. #include <linux/types.h>
  5. #include <asm/nops.h>
  6. #define JUMP_LABEL_NOP_SIZE 5
  7. # define JUMP_LABEL_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t"
  8. # define JUMP_LABEL(key, label) \
  9. do { \
  10. asm goto("1:" \
  11. JUMP_LABEL_INITIAL_NOP \
  12. ".pushsection __jump_table, \"a\" \n\t"\
  13. _ASM_PTR "1b, %l[" #label "], %c0 \n\t" \
  14. ".popsection \n\t" \
  15. : : "i" (key) : : label); \
  16. } while (0)
  17. #endif /* __KERNEL__ */
  18. #ifdef CONFIG_X86_64
  19. typedef u64 jump_label_t;
  20. struct jump_entry {
  21. jump_label_t code;
  22. jump_label_t target;
  23. jump_label_t key;
  24. };
  25. #else
  26. typedef u32 jump_label_t;
  27. struct jump_entry {
  28. jump_label_t code;
  29. jump_label_t target;
  30. jump_label_t key;
  31. };
  32. #endif
  33. #endif