syscall_arch.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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) __SYSCALL_LL_E((x))
  5. #define __SYSCALL_SSLEN 8
  6. static inline long __syscall0(long n)
  7. {
  8. unsigned long __ret;
  9. __asm__ __volatile__ ("call __vsyscall" : "=a"(__ret) : "a"(n) : "memory");
  10. return __ret;
  11. }
  12. static inline long __syscall1(long n, long a1)
  13. {
  14. unsigned long __ret;
  15. __asm__ __volatile__ ("call __vsyscall" : "=a"(__ret) : "a"(n), "d"(a1) : "memory");
  16. return __ret;
  17. }
  18. static inline long __syscall2(long n, long a1, long a2)
  19. {
  20. unsigned long __ret;
  21. __asm__ __volatile__ ("call __vsyscall" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2) : "memory");
  22. return __ret;
  23. }
  24. static inline long __syscall3(long n, long a1, long a2, long a3)
  25. {
  26. unsigned long __ret;
  27. __asm__ __volatile__ ("call __vsyscall" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2), "D"(a3) : "memory");
  28. return __ret;
  29. }
  30. static inline long __syscall4(long n, long a1, long a2, long a3, long a4)
  31. {
  32. unsigned long __ret;
  33. __asm__ __volatile__ ("call __vsyscall" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2), "D"(a3), "S"(a4) : "memory");
  34. return __ret;
  35. }
  36. static inline long __syscall5(long n, long a1, long a2, long a3, long a4, long a5)
  37. {
  38. unsigned long __ret;
  39. __asm__ __volatile__ ("push %6 ; call __vsyscall ; add $4,%%esp" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2), "D"(a3), "S"(a4), "g"(a5) : "memory");
  40. return __ret;
  41. }
  42. static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a5, long a6)
  43. {
  44. unsigned long __ret;
  45. __asm__ __volatile__ ("push %6 ; call __vsyscall6 ; add $4,%%esp" : "=a"(__ret) : "a"(n), "d"(a1), "c"(a2), "D"(a3), "S"(a4), "g"(0+(long[]){a5, a6}) : "memory");
  46. return __ret;
  47. }
  48. #define __SC_socket 1
  49. #define __SC_bind 2
  50. #define __SC_connect 3
  51. #define __SC_listen 4
  52. #define __SC_accept 5
  53. #define __SC_getsockname 6
  54. #define __SC_getpeername 7
  55. #define __SC_socketpair 8
  56. #define __SC_send 9
  57. #define __SC_recv 10
  58. #define __SC_sendto 11
  59. #define __SC_recvfrom 12
  60. #define __SC_shutdown 13
  61. #define __SC_setsockopt 14
  62. #define __SC_getsockopt 15
  63. #define __SC_sendmsg 16
  64. #define __SC_recvmsg 17
  65. #define __SC_accept4 18
  66. #define __SC_recvmmsg 19
  67. #define __SC_sendmmsg 20