syscall_arch.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #define __SYSCALL_LL_E(x) \
  2. ((union { long long ll; long l[2]; }){ .ll = x }).l[0], \
  3. ((union { long long ll; long l[2]; }){ .ll = x }).l[1]
  4. #define __SYSCALL_LL_O(x) 0, __SYSCALL_LL_E((x))
  5. static inline long __syscall0(long n)
  6. {
  7. register long r0 __asm__("r0") = n;
  8. register long r3 __asm__("r3");
  9. __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
  10. : "+r"(r0), "=r"(r3)
  11. :: "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
  12. return r3;
  13. }
  14. static inline long __syscall1(long n, long a)
  15. {
  16. register long r0 __asm__("r0") = n;
  17. register long r3 __asm__("r3") = a;
  18. __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
  19. : "+r"(r0), "+r"(r3)
  20. :: "memory", "cr0", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
  21. return r3;
  22. }
  23. static inline long __syscall2(long n, long a, long b)
  24. {
  25. register long r0 __asm__("r0") = n;
  26. register long r3 __asm__("r3") = a;
  27. register long r4 __asm__("r4") = b;
  28. __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
  29. : "+r"(r0), "+r"(r3), "+r"(r4)
  30. :: "memory", "cr0", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
  31. return r3;
  32. }
  33. static inline long __syscall3(long n, long a, long b, long c)
  34. {
  35. register long r0 __asm__("r0") = n;
  36. register long r3 __asm__("r3") = a;
  37. register long r4 __asm__("r4") = b;
  38. register long r5 __asm__("r5") = c;
  39. __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
  40. : "+r"(r0), "+r"(r3), "+r"(r4), "+r"(r5)
  41. :: "memory", "cr0", "r6", "r7", "r8", "r9", "r10", "r11", "r12");
  42. return r3;
  43. }
  44. static inline long __syscall4(long n, long a, long b, long c, long d)
  45. {
  46. register long r0 __asm__("r0") = n;
  47. register long r3 __asm__("r3") = a;
  48. register long r4 __asm__("r4") = b;
  49. register long r5 __asm__("r5") = c;
  50. register long r6 __asm__("r6") = d;
  51. __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
  52. : "+r"(r0), "+r"(r3), "+r"(r4), "+r"(r5), "+r"(r6)
  53. :: "memory", "cr0", "r7", "r8", "r9", "r10", "r11", "r12");
  54. return r3;
  55. }
  56. static inline long __syscall5(long n, long a, long b, long c, long d, long e)
  57. {
  58. register long r0 __asm__("r0") = n;
  59. register long r3 __asm__("r3") = a;
  60. register long r4 __asm__("r4") = b;
  61. register long r5 __asm__("r5") = c;
  62. register long r6 __asm__("r6") = d;
  63. register long r7 __asm__("r7") = e;
  64. __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
  65. : "+r"(r0), "+r"(r3), "+r"(r4), "+r"(r5), "+r"(r6), "+r"(r7)
  66. :: "memory", "cr0", "r8", "r9", "r10", "r11", "r12");
  67. return r3;
  68. }
  69. static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
  70. {
  71. register long r0 __asm__("r0") = n;
  72. register long r3 __asm__("r3") = a;
  73. register long r4 __asm__("r4") = b;
  74. register long r5 __asm__("r5") = c;
  75. register long r6 __asm__("r6") = d;
  76. register long r7 __asm__("r7") = e;
  77. register long r8 __asm__("r8") = f;
  78. __asm__ __volatile__("sc ; bns+ 1f ; neg %1, %1 ; 1:"
  79. : "+r"(r0), "+r"(r3), "+r"(r4), "+r"(r5), "+r"(r6), "+r"(r7), "+r"(r8)
  80. :: "memory", "cr0", "r9", "r10", "r11", "r12");
  81. return r3;
  82. }
  83. #define SYSCALL_FADVISE_6_ARG
  84. #define SO_RCVTIMEO_OLD 18
  85. #define SO_SNDTIMEO_OLD 19