linkage.h 2.6 KB

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