dl-syscalls.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * This file contains the system call macros and syscall
  3. * numbers used by the shared library loader.
  4. */
  5. #define __NR_exit 1
  6. #define __NR_read 3
  7. #define __NR_write 4
  8. #define __NR_open 5
  9. #define __NR_close 6
  10. #define __NR_getpid 20
  11. #define __NR_getuid 24
  12. #define __NR_getgid 47
  13. #define __NR_geteuid 49
  14. #define __NR_getegid 50
  15. #define __NR_readlink 58
  16. #define __NR_mmap 71
  17. #define __NR_munmap 73
  18. #define __NR_stat 38
  19. #define __NR_mprotect 74
  20. /* Here are the macros which define how this platform makes
  21. * system calls. This particular variant does _not_ set
  22. * errno (note how it is disabled in __syscall_return) since
  23. * these will get called before the errno symbol is dynamicly
  24. * linked. */
  25. #define _syscall0(type,name) \
  26. type name(void) \
  27. { \
  28. long __res; \
  29. register long __g1 __asm__ ("g1") = __NR_##name; \
  30. __asm__ __volatile__ ("t 0x10\n\t" \
  31. "bcc 1f\n\t" \
  32. "mov %%o0, %0\n\t" \
  33. "sub %%g0, %%o0, %0\n\t" \
  34. "1:\n\t" \
  35. : "=r" (__res)\
  36. : "r" (__g1) \
  37. : "o0", "cc"); \
  38. if (__res < -255 || __res >= 0) \
  39. return (type) __res; \
  40. /*errno = -__res; */\
  41. return -1; \
  42. }
  43. #define _syscall1(type,name,type1,arg1) \
  44. type name(type1 arg1) \
  45. { \
  46. long __res; \
  47. register long __g1 __asm__ ("g1") = __NR_##name; \
  48. register long __o0 __asm__ ("o0") = (long)(arg1); \
  49. __asm__ __volatile__ ("t 0x10\n\t" \
  50. "bcc 1f\n\t" \
  51. "mov %%o0, %0\n\t" \
  52. "sub %%g0, %%o0, %0\n\t" \
  53. "1:\n\t" \
  54. : "=r" (__res), "=&r" (__o0) \
  55. : "1" (__o0), "r" (__g1) \
  56. : "cc"); \
  57. if (__res < -255 || __res >= 0) \
  58. return (type) __res; \
  59. /*errno = -__res;*/ \
  60. return -1; \
  61. }
  62. #define _syscall2(type,name,type1,arg1,type2,arg2) \
  63. type name(type1 arg1,type2 arg2) \
  64. { \
  65. long __res; \
  66. register long __g1 __asm__ ("g1") = __NR_##name; \
  67. register long __o0 __asm__ ("o0") = (long)(arg1); \
  68. register long __o1 __asm__ ("o1") = (long)(arg2); \
  69. __asm__ __volatile__ ("t 0x10\n\t" \
  70. "bcc 1f\n\t" \
  71. "mov %%o0, %0\n\t" \
  72. "sub %%g0, %%o0, %0\n\t" \
  73. "1:\n\t" \
  74. : "=r" (__res), "=&r" (__o0) \
  75. : "1" (__o0), "r" (__o1), "r" (__g1) \
  76. : "cc"); \
  77. if (__res < -255 || __res >= 0) \
  78. return (type) __res; \
  79. /*errno = -__res;*/ \
  80. return -1; \
  81. }
  82. #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
  83. type name(type1 arg1,type2 arg2,type3 arg3) \
  84. { \
  85. long __res; \
  86. register long __g1 __asm__ ("g1") = __NR_##name; \
  87. register long __o0 __asm__ ("o0") = (long)(arg1); \
  88. register long __o1 __asm__ ("o1") = (long)(arg2); \
  89. register long __o2 __asm__ ("o2") = (long)(arg3); \
  90. __asm__ __volatile__ ("t 0x10\n\t" \
  91. "bcc 1f\n\t" \
  92. "mov %%o0, %0\n\t" \
  93. "sub %%g0, %%o0, %0\n\t" \
  94. "1:\n\t" \
  95. : "=r" (__res), "=&r" (__o0) \
  96. : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__g1) \
  97. : "cc"); \
  98. if (__res < -255 || __res>=0) \
  99. return (type) __res; \
  100. /*errno = -__res;*/ \
  101. return -1; \
  102. }
  103. #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  104. type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
  105. { \
  106. long __res; \
  107. register long __g1 __asm__ ("g1") = __NR_##name; \
  108. register long __o0 __asm__ ("o0") = (long)(arg1); \
  109. register long __o1 __asm__ ("o1") = (long)(arg2); \
  110. register long __o2 __asm__ ("o2") = (long)(arg3); \
  111. register long __o3 __asm__ ("o3") = (long)(arg4); \
  112. __asm__ __volatile__ ("t 0x10\n\t" \
  113. "bcc 1f\n\t" \
  114. "mov %%o0, %0\n\t" \
  115. "sub %%g0, %%o0, %0\n\t" \
  116. "1:\n\t" \
  117. : "=r" (__res), "=&r" (__o0) \
  118. : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__g1) \
  119. : "cc"); \
  120. if (__res < -255 || __res>=0) \
  121. return (type) __res; \
  122. /*errno = -__res;*/ \
  123. return -1; \
  124. }
  125. #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
  126. type5,arg5) \
  127. type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
  128. { \
  129. long __res; \
  130. register long __g1 __asm__ ("g1") = __NR_##name; \
  131. register long __o0 __asm__ ("o0") = (long)(arg1); \
  132. register long __o1 __asm__ ("o1") = (long)(arg2); \
  133. register long __o2 __asm__ ("o2") = (long)(arg3); \
  134. register long __o3 __asm__ ("o3") = (long)(arg4); \
  135. register long __o4 __asm__ ("o4") = (long)(arg5); \
  136. __asm__ __volatile__ ("t 0x10\n\t" \
  137. "bcc 1f\n\t" \
  138. "mov %%o0, %0\n\t" \
  139. "sub %%g0, %%o0, %0\n\t" \
  140. "1:\n\t" \
  141. : "=r" (__res), "=&r" (__o0) \
  142. : "1" (__o0), "r" (__o1), "r" (__o2), "r" (__o3), "r" (__o4), "r" (__g1) \
  143. : "cc"); \
  144. if (__res < -255 || __res>=0) \
  145. return (type) __res; \
  146. /*errno = -__res; */\
  147. return -1; \
  148. }