linkage.h 2.5 KB

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