syscall_arch.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. long (__syscall)(long, ...);
  6. #define __asm_syscall(...) do { \
  7. __asm__ __volatile__ ( "svc 0" \
  8. : "=r"(x0) : __VA_ARGS__ : "memory", "cc"); \
  9. return x0; \
  10. } while (0)
  11. static inline long __syscall0(long n)
  12. {
  13. register long x8 __asm__("x8") = n;
  14. register long x0 __asm__("x0");
  15. __asm_syscall("r"(x8));
  16. }
  17. static inline long __syscall1(long n, long a)
  18. {
  19. register long x8 __asm__("x8") = n;
  20. register long x0 __asm__("x0") = a;
  21. __asm_syscall("r"(x8), "0"(x0));
  22. }
  23. static inline long __syscall2(long n, long a, long b)
  24. {
  25. register long x8 __asm__("x8") = n;
  26. register long x0 __asm__("x0") = a;
  27. register long x1 __asm__("x1") = b;
  28. __asm_syscall("r"(x8), "0"(x0), "r"(x1));
  29. }
  30. static inline long __syscall3(long n, long a, long b, long c)
  31. {
  32. register long x8 __asm__("x8") = n;
  33. register long x0 __asm__("x0") = a;
  34. register long x1 __asm__("x1") = b;
  35. register long x2 __asm__("x2") = c;
  36. __asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2));
  37. }
  38. static inline long __syscall4(long n, long a, long b, long c, long d)
  39. {
  40. register long x8 __asm__("x8") = n;
  41. register long x0 __asm__("x0") = a;
  42. register long x1 __asm__("x1") = b;
  43. register long x2 __asm__("x2") = c;
  44. register long x3 __asm__("x3") = d;
  45. __asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3));
  46. }
  47. static inline long __syscall5(long n, long a, long b, long c, long d, long e)
  48. {
  49. register long x8 __asm__("x8") = n;
  50. register long x0 __asm__("x0") = a;
  51. register long x1 __asm__("x1") = b;
  52. register long x2 __asm__("x2") = c;
  53. register long x3 __asm__("x3") = d;
  54. register long x4 __asm__("x4") = e;
  55. __asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4));
  56. }
  57. static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f)
  58. {
  59. register long x8 __asm__("x8") = n;
  60. register long x0 __asm__("x0") = a;
  61. register long x1 __asm__("x1") = b;
  62. register long x2 __asm__("x2") = c;
  63. register long x3 __asm__("x3") = d;
  64. register long x4 __asm__("x4") = e;
  65. register long x5 __asm__("x5") = f;
  66. __asm_syscall("r"(x8), "0"(x0), "r"(x1), "r"(x2), "r"(x3), "r"(x4), "r"(x5));
  67. }
  68. #define VDSO_USEFUL
  69. #define VDSO_CGT_SYM "__kernel_clock_gettime"
  70. #define VDSO_CGT_VER "LINUX_2.6.39"