unistd.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. #ifndef _ASM_CRIS_ARCH_UNISTD_H_
  2. #define _ASM_CRIS_ARCH_UNISTD_H_
  3. /* XXX - _foo needs to be __foo, while __NR_bar could be _NR_bar. */
  4. /*
  5. * Don't remove the .ifnc tests; they are an insurance against
  6. * any hard-to-spot gcc register allocation bugs.
  7. */
  8. #define _syscall0(type,name) \
  9. type name(void) \
  10. { \
  11. register long __a __asm__ ("r10"); \
  12. register long __n_ __asm__ ("r9") = (__NR_##name); \
  13. __asm__ __volatile__ (".ifnc %0%1,$r10$r9\n\t" \
  14. ".err\n\t" \
  15. ".endif\n\t" \
  16. "break 13" \
  17. : "=r" (__a) \
  18. : "r" (__n_) \
  19. : "memory"); \
  20. if (__a >= 0) \
  21. return (type) __a; \
  22. errno = -__a; \
  23. return (type) -1; \
  24. }
  25. #define _syscall1(type,name,type1,arg1) \
  26. type name(type1 arg1) \
  27. { \
  28. register long __a __asm__ ("r10") = (long) arg1; \
  29. register long __n_ __asm__ ("r9") = (__NR_##name); \
  30. __asm__ __volatile__ (".ifnc %0%1,$r10$r9\n\t" \
  31. ".err\n\t" \
  32. ".endif\n\t" \
  33. "break 13" \
  34. : "=r" (__a) \
  35. : "r" (__n_), "0" (__a) \
  36. : "memory"); \
  37. if (__a >= 0) \
  38. return (type) __a; \
  39. errno = -__a; \
  40. return (type) -1; \
  41. }
  42. #define _syscall2(type,name,type1,arg1,type2,arg2) \
  43. type name(type1 arg1,type2 arg2) \
  44. { \
  45. register long __a __asm__ ("r10") = (long) arg1; \
  46. register long __b __asm__ ("r11") = (long) arg2; \
  47. register long __n_ __asm__ ("r9") = (__NR_##name); \
  48. __asm__ __volatile__ (".ifnc %0%1%3,$r10$r9$r11\n\t" \
  49. ".err\n\t" \
  50. ".endif\n\t" \
  51. "break 13" \
  52. : "=r" (__a) \
  53. : "r" (__n_), "0" (__a), "r" (__b) \
  54. : "memory"); \
  55. if (__a >= 0) \
  56. return (type) __a; \
  57. errno = -__a; \
  58. return (type) -1; \
  59. }
  60. #define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
  61. type name(type1 arg1,type2 arg2,type3 arg3) \
  62. { \
  63. register long __a __asm__ ("r10") = (long) arg1; \
  64. register long __b __asm__ ("r11") = (long) arg2; \
  65. register long __c __asm__ ("r12") = (long) arg3; \
  66. register long __n_ __asm__ ("r9") = (__NR_##name); \
  67. __asm__ __volatile__ (".ifnc %0%1%3%4,$r10$r9$r11$r12\n\t" \
  68. ".err\n\t" \
  69. ".endif\n\t" \
  70. "break 13" \
  71. : "=r" (__a) \
  72. : "r" (__n_), "0" (__a), "r" (__b), "r" (__c) \
  73. : "memory"); \
  74. if (__a >= 0) \
  75. return (type) __a; \
  76. errno = -__a; \
  77. return (type) -1; \
  78. }
  79. #define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
  80. type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
  81. { \
  82. register long __a __asm__ ("r10") = (long) arg1; \
  83. register long __b __asm__ ("r11") = (long) arg2; \
  84. register long __c __asm__ ("r12") = (long) arg3; \
  85. register long __d __asm__ ("r13") = (long) arg4; \
  86. register long __n_ __asm__ ("r9") = (__NR_##name); \
  87. __asm__ __volatile__ (".ifnc %0%1%3%4%5,$r10$r9$r11$r12$r13\n\t" \
  88. ".err\n\t" \
  89. ".endif\n\t" \
  90. "break 13" \
  91. : "=r" (__a) \
  92. : "r" (__n_), "0" (__a), "r" (__b), \
  93. "r" (__c), "r" (__d)\
  94. : "memory"); \
  95. if (__a >= 0) \
  96. return (type) __a; \
  97. errno = -__a; \
  98. return (type) -1; \
  99. }
  100. #define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
  101. type5,arg5) \
  102. type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
  103. { \
  104. register long __a __asm__ ("r10") = (long) arg1; \
  105. register long __b __asm__ ("r11") = (long) arg2; \
  106. register long __c __asm__ ("r12") = (long) arg3; \
  107. register long __d __asm__ ("r13") = (long) arg4; \
  108. register long __e __asm__ ("mof") = (long) arg5; \
  109. register long __n_ __asm__ ("r9") = (__NR_##name); \
  110. __asm__ __volatile__ (".ifnc %0%1%3%4%5%6,$r10$r9$r11$r12$r13$mof\n\t" \
  111. ".err\n\t" \
  112. ".endif\n\t" \
  113. "break 13" \
  114. : "=r" (__a) \
  115. : "r" (__n_), "0" (__a), "r" (__b), \
  116. "r" (__c), "r" (__d), "h" (__e) \
  117. : "memory"); \
  118. if (__a >= 0) \
  119. return (type) __a; \
  120. errno = -__a; \
  121. return (type) -1; \
  122. }
  123. #define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
  124. type5,arg5,type6,arg6) \
  125. type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
  126. { \
  127. register long __a __asm__ ("r10") = (long) arg1; \
  128. register long __b __asm__ ("r11") = (long) arg2; \
  129. register long __c __asm__ ("r12") = (long) arg3; \
  130. register long __d __asm__ ("r13") = (long) arg4; \
  131. register long __e __asm__ ("mof") = (long) arg5; \
  132. register long __f __asm__ ("srp") = (long) arg6; \
  133. register long __n_ __asm__ ("r9") = (__NR_##name); \
  134. __asm__ __volatile__ (".ifnc %0%1%3%4%5%6%7,$r10$r9$r11$r12$r13$mof$srp\n\t" \
  135. ".err\n\t" \
  136. ".endif\n\t" \
  137. "break 13" \
  138. : "=r" (__a) \
  139. : "r" (__n_), "0" (__a), "r" (__b), \
  140. "r" (__c), "r" (__d), "h" (__e), "x" (__f) \
  141. : "memory"); \
  142. if (__a >= 0) \
  143. return (type) __a; \
  144. errno = -__a; \
  145. return (type) -1; \
  146. }
  147. #endif