linkage.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_LINKAGE_H
  3. #define _LINUX_LINKAGE_H
  4. #include <linux/compiler_types.h>
  5. #include <linux/stringify.h>
  6. #include <linux/export.h>
  7. #include <asm/linkage.h>
  8. /* Some toolchains use other characters (e.g. '`') to mark new line in macro */
  9. #ifndef ASM_NL
  10. #define ASM_NL ;
  11. #endif
  12. #ifdef __cplusplus
  13. #define CPP_ASMLINKAGE extern "C"
  14. #else
  15. #define CPP_ASMLINKAGE
  16. #endif
  17. #ifndef asmlinkage
  18. #define asmlinkage CPP_ASMLINKAGE
  19. #endif
  20. #ifndef cond_syscall
  21. #define cond_syscall(x) asm( \
  22. ".weak " __stringify(x) "\n\t" \
  23. ".set " __stringify(x) "," \
  24. __stringify(sys_ni_syscall))
  25. #endif
  26. #ifndef SYSCALL_ALIAS
  27. #define SYSCALL_ALIAS(alias, name) asm( \
  28. ".globl " __stringify(alias) "\n\t" \
  29. ".set " __stringify(alias) "," \
  30. __stringify(name))
  31. #endif
  32. #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
  33. #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
  34. /*
  35. * For assembly routines.
  36. *
  37. * Note when using these that you must specify the appropriate
  38. * alignment directives yourself
  39. */
  40. #define __PAGE_ALIGNED_DATA .section ".data..page_aligned", "aw"
  41. #define __PAGE_ALIGNED_BSS .section ".bss..page_aligned", "aw"
  42. /*
  43. * This is used by architectures to keep arguments on the stack
  44. * untouched by the compiler by keeping them live until the end.
  45. * The argument stack may be owned by the assembly-language
  46. * caller, not the callee, and gcc doesn't always understand
  47. * that.
  48. *
  49. * We have the return value, and a maximum of six arguments.
  50. *
  51. * This should always be followed by a "return ret" for the
  52. * protection to work (ie no more work that the compiler might
  53. * end up needing stack temporaries for).
  54. */
  55. /* Assembly files may be compiled with -traditional .. */
  56. #ifndef __ASSEMBLY__
  57. #ifndef asmlinkage_protect
  58. # define asmlinkage_protect(n, ret, args...) do { } while (0)
  59. #endif
  60. #endif
  61. #ifndef __ALIGN
  62. #define __ALIGN .align 4,0x90
  63. #define __ALIGN_STR ".align 4,0x90"
  64. #endif
  65. #ifdef __ASSEMBLY__
  66. #ifndef LINKER_SCRIPT
  67. #define ALIGN __ALIGN
  68. #define ALIGN_STR __ALIGN_STR
  69. #ifndef ENTRY
  70. #define ENTRY(name) \
  71. .globl name ASM_NL \
  72. ALIGN ASM_NL \
  73. name:
  74. #endif
  75. #endif /* LINKER_SCRIPT */
  76. #ifndef WEAK
  77. #define WEAK(name) \
  78. .weak name ASM_NL \
  79. name:
  80. #endif
  81. #ifndef END
  82. #define END(name) \
  83. .size name, .-name
  84. #endif
  85. /* If symbol 'name' is treated as a subroutine (gets called, and returns)
  86. * then please use ENDPROC to mark 'name' as STT_FUNC for the benefit of
  87. * static analysis tools such as stack depth analyzer.
  88. */
  89. #ifndef ENDPROC
  90. #define ENDPROC(name) \
  91. .type name, @function ASM_NL \
  92. END(name)
  93. #endif
  94. #endif
  95. #endif