ld_syscalls.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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_getuid 24
  11. #define __NR_geteuid 49
  12. #define __NR_getgid 47
  13. #define __NR_getegid 50
  14. #define __NR_readlink 85
  15. #define __NR_mmap 90
  16. #define __NR_munmap 91
  17. #define __NR_stat 106
  18. #define __NR_mprotect 125
  19. /* Here are the macros which define how this platform makes
  20. * system calls. This particular variant does _not_ set
  21. * errno (note how it is disabled in __syscall_return) since
  22. * these will get called before the errno symbol is dynamicly
  23. * linked. */
  24. #define __syscall_return(type, res) \
  25. do { \
  26. if ((unsigned long)(res) >= (unsigned long)(-125)) { \
  27. /* avoid using res which is declared to be in register d0; \
  28. errno might expand to a function call and clobber it. */ \
  29. /* int __err = -(res); \
  30. errno = __err; */ \
  31. res = -1; \
  32. } \
  33. return (type) (res); \
  34. } while (0)
  35. #define _syscall0(type, name) \
  36. type name(void) \
  37. { \
  38. long __res; \
  39. __asm__ __volatile__ ("movel %1, %%d0\n\t" \
  40. "trap #0\n\t" \
  41. "movel %%d0, %0" \
  42. : "=g" (__res) \
  43. : "i" (__NR_##name) \
  44. : "cc", "%d0"); \
  45. if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
  46. /* errno = -__res; */ \
  47. __res = -1; \
  48. } \
  49. return (type)__res; \
  50. }
  51. #define _syscall1(type, name, atype, a) \
  52. type name(atype a) \
  53. { \
  54. long __res; \
  55. __asm__ __volatile__ ("movel %2, %%d1\n\t" \
  56. "movel %1, %%d0\n\t" \
  57. "trap #0\n\t" \
  58. "movel %%d0, %0" \
  59. : "=g" (__res) \
  60. : "i" (__NR_##name), \
  61. "g" ((long)a) \
  62. : "cc", "%d0", "%d1"); \
  63. if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
  64. /* errno = -__res; */ \
  65. __res = -1; \
  66. } \
  67. return (type)__res; \
  68. }
  69. #define _syscall2(type, name, atype, a, btype, b) \
  70. type name(atype a, btype b) \
  71. { \
  72. long __res; \
  73. __asm__ __volatile__ ("movel %3, %%d2\n\t" \
  74. "movel %2, %%d1\n\t" \
  75. "movel %1, %%d0\n\t" \
  76. "trap #0\n\t" \
  77. "movel %%d0, %0" \
  78. : "=g" (__res) \
  79. : "i" (__NR_##name), \
  80. "a" ((long)a), \
  81. "g" ((long)b) \
  82. : "cc", "%d0", "%d1", "%d2"); \
  83. if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
  84. /* errno = -__res; */ \
  85. __res = -1; \
  86. } \
  87. return (type)__res; \
  88. }
  89. #define _syscall3(type, name, atype, a, btype, b, ctype, c) \
  90. type name(atype a, btype b, ctype c) \
  91. { \
  92. long __res; \
  93. __asm__ __volatile__ ("movel %4, %%d3\n\t" \
  94. "movel %3, %%d2\n\t" \
  95. "movel %2, %%d1\n\t" \
  96. "movel %1, %%d0\n\t" \
  97. "trap #0\n\t" \
  98. "movel %%d0, %0" \
  99. : "=g" (__res) \
  100. : "i" (__NR_##name), \
  101. "a" ((long)a), \
  102. "a" ((long)b), \
  103. "g" ((long)c) \
  104. : "cc", "%d0", "%d1", "%d2", "%d3"); \
  105. if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
  106. /* errno = -__res; */ \
  107. __res = -1; \
  108. } \
  109. return (type)__res; \
  110. }
  111. #define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \
  112. type name(atype a, btype b, ctype c, dtype d) \
  113. { \
  114. long __res; \
  115. __asm__ __volatile__ ("movel %5, %%d4\n\t" \
  116. "movel %4, %%d3\n\t" \
  117. "movel %3, %%d2\n\t" \
  118. "movel %2, %%d1\n\t" \
  119. "movel %1, %%d0\n\t" \
  120. "trap #0\n\t" \
  121. "movel %%d0, %0" \
  122. : "=g" (__res) \
  123. : "i" (__NR_##name), \
  124. "a" ((long)a), \
  125. "a" ((long)b), \
  126. "a" ((long)c), \
  127. "g" ((long)d) \
  128. : "cc", "%d0", "%d1", "%d2", "%d3", \
  129. "%d4"); \
  130. if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
  131. /* errno = -__res; */ \
  132. __res = -1; \
  133. } \
  134. return (type)__res; \
  135. }
  136. #define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e)\
  137. type name(atype a, btype b, ctype c, dtype d, etype e) \
  138. { \
  139. long __res; \
  140. __asm__ __volatile__ ("movel %6, %%d5\n\t" \
  141. "movel %5, %%d4\n\t" \
  142. "movel %4, %%d3\n\t" \
  143. "movel %3, %%d2\n\t" \
  144. "movel %2, %%d1\n\t" \
  145. "movel %1, %%d0\n\t" \
  146. "trap #0\n\t" \
  147. "movel %%d0, %0" \
  148. : "=g" (__res) \
  149. : "i" (__NR_##name), \
  150. "a" ((long)a), \
  151. "a" ((long)b), \
  152. "a" ((long)c), \
  153. "a" ((long)d), \
  154. "g" ((long)e) \
  155. : "cc", "%d0", "%d1", "%d2", "%d3", \
  156. "%d4", "%d5"); \
  157. if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
  158. /* errno = -__res; */ \
  159. __res = -1; \
  160. } \
  161. return (type)__res; \
  162. }