syscall_arch.h 2.2 KB

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