syscall_arch.h 2.3 KB

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