syscalls.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #ifndef _BITS_SYSCALLS_H
  2. #define _BITS_SYSCALLS_H
  3. #ifndef _SYSCALL_H
  4. #error "Never use <bits/syscall.h> directly; include <sys/syscall.h> instead."
  5. #endif
  6. #ifndef __ASSEMBLER__
  7. #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
  8. (__extension__ \
  9. ({ \
  10. register unsigned long __res __asm__ ("r10"); \
  11. LOAD_ARGS_c_##nr(args) \
  12. register unsigned long __callno __asm__ ("r9") \
  13. = name; \
  14. __asm__ __volatile__ (LOAD_ARGS_asm_##nr (args) \
  15. CHECK_ARGS_asm_##nr \
  16. "break 13" \
  17. : "=r" (__res) \
  18. : ASM_ARGS_##nr (args) \
  19. : ASM_CLOBBER_##nr); \
  20. __res; \
  21. }) \
  22. )
  23. #define LOAD_ARGS_c_0()
  24. #define LOAD_ARGS_asm_0()
  25. #define ASM_CLOBBER_0 "memory"
  26. #define ASM_ARGS_0() "r" (__callno)
  27. #define CHECK_ARGS_asm_0
  28. #define LOAD_ARGS_c_1(r10) \
  29. LOAD_ARGS_c_0() \
  30. register unsigned long __r10 __asm__ ("r10") = (unsigned long) (r10);
  31. #define LOAD_ARGS_asm_1(r10) LOAD_ARGS_asm_0 ()
  32. #define ASM_CLOBBER_1 ASM_CLOBBER_0
  33. #define ASM_ARGS_1(r10) ASM_ARGS_0 (), "0" (__r10)
  34. #define CHECK_ARGS_asm_1 \
  35. ".ifnc %0,$r10\n\t" \
  36. ".err\n\t" \
  37. ".endif\n\t"
  38. #define LOAD_ARGS_c_2(r10, r11) \
  39. LOAD_ARGS_c_1(r10) \
  40. register unsigned long __r11 __asm__ ("r11") = (unsigned long) (r11);
  41. #define LOAD_ARGS_asm_2(r10, r11) LOAD_ARGS_asm_1 (r10)
  42. #define ASM_CLOBBER_2 ASM_CLOBBER_1
  43. #define ASM_ARGS_2(r10, r11) ASM_ARGS_1 (r10), "r" (__r11)
  44. #define CHECK_ARGS_asm_2 \
  45. ".ifnc %0-%3,$r10-$r11\n\t" \
  46. ".err\n\t" \
  47. ".endif\n\t"
  48. #define LOAD_ARGS_c_3(r10, r11, r12) \
  49. LOAD_ARGS_c_2(r10, r11) \
  50. register unsigned long __r12 __asm__ ("r12") = (unsigned long) (r12);
  51. #define LOAD_ARGS_asm_3(r10, r11, r12) LOAD_ARGS_asm_2 (r10, r11)
  52. #define ASM_CLOBBER_3 ASM_CLOBBER_2
  53. #define ASM_ARGS_3(r10, r11, r12) ASM_ARGS_2 (r10, r11), "r" (__r12)
  54. #define CHECK_ARGS_asm_3 \
  55. ".ifnc %0-%3-%4,$r10-$r11-$r12\n\t" \
  56. ".err\n\t" \
  57. ".endif\n\t"
  58. #define LOAD_ARGS_c_4(r10, r11, r12, r13) \
  59. LOAD_ARGS_c_3(r10, r11, r12) \
  60. register unsigned long __r13 __asm__ ("r13") = (unsigned long) (r13);
  61. #define LOAD_ARGS_asm_4(r10, r11, r12, r13) LOAD_ARGS_asm_3 (r10, r11, r12)
  62. #define ASM_CLOBBER_4 ASM_CLOBBER_3
  63. #define ASM_ARGS_4(r10, r11, r12, r13) ASM_ARGS_3 (r10, r11, r12), "r" (__r13)
  64. #define CHECK_ARGS_asm_4 \
  65. ".ifnc %0-%3-%4-%5,$r10-$r11-$r12-$r13\n\t" \
  66. ".err\n\t" \
  67. ".endif\n\t"
  68. #define LOAD_ARGS_c_5(r10, r11, r12, r13, mof) \
  69. LOAD_ARGS_c_4(r10, r11, r12, r13)
  70. #define LOAD_ARGS_asm_5(r10, r11, r12, r13, mof) \
  71. LOAD_ARGS_asm_4 (r10, r11, r12, r13) "move %6,$mof\n\t"
  72. #define ASM_CLOBBER_5 ASM_CLOBBER_4
  73. #define ASM_ARGS_5(r10, r11, r12, r13, mof) \
  74. ASM_ARGS_4 (r10, r11, r12, r13), "g" (mof)
  75. #define CHECK_ARGS_asm_5 CHECK_ARGS_asm_4
  76. #define LOAD_ARGS_c_6(r10, r11, r12, r13, mof, srp) \
  77. LOAD_ARGS_c_5(r10, r11, r12, r13, mof)
  78. #define LOAD_ARGS_asm_6(r10, r11, r12, r13, mof, srp) \
  79. LOAD_ARGS_asm_5(r10, r11, r12, r13, mof) \
  80. "move %7,$srp\n\t"
  81. #define ASM_CLOBBER_6 ASM_CLOBBER_5, "srp"
  82. #define ASM_ARGS_6(r10, r11, r12, r13, mof, srp) \
  83. ASM_ARGS_5 (r10, r11, r12, r13, mof), "g" (srp)
  84. #define CHECK_ARGS_asm_6 CHECK_ARGS_asm_5
  85. #endif /* not __ASSEMBLER__ */
  86. #endif /* _BITS_SYSCALLS_H */