syscalls.h 3.1 KB

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