jump_label.h 971 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (c) 2010 Cavium Networks, Inc.
  7. */
  8. #ifndef _ASM_MIPS_JUMP_LABEL_H
  9. #define _ASM_MIPS_JUMP_LABEL_H
  10. #include <linux/types.h>
  11. #ifdef __KERNEL__
  12. #define JUMP_LABEL_NOP_SIZE 4
  13. #ifdef CONFIG_64BIT
  14. #define WORD_INSN ".dword"
  15. #else
  16. #define WORD_INSN ".word"
  17. #endif
  18. static __always_inline bool arch_static_branch(struct static_key *key)
  19. {
  20. asm_volatile_goto("1:\tnop\n\t"
  21. "nop\n\t"
  22. ".pushsection __jump_table, \"aw\"\n\t"
  23. WORD_INSN " 1b, %l[l_yes], %0\n\t"
  24. ".popsection\n\t"
  25. : : "i" (key) : : l_yes);
  26. return false;
  27. l_yes:
  28. return true;
  29. }
  30. #endif /* __KERNEL__ */
  31. #ifdef CONFIG_64BIT
  32. typedef u64 jump_label_t;
  33. #else
  34. typedef u32 jump_label_t;
  35. #endif
  36. struct jump_entry {
  37. jump_label_t code;
  38. jump_label_t target;
  39. jump_label_t key;
  40. };
  41. #endif /* _ASM_MIPS_JUMP_LABEL_H */