SYS.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. SYS.h
  3. */
  4. #ifndef SYS_H
  5. #define SYS_H
  6. #include <syscall.h>
  7. #define SYS_call_0(x) \
  8. LABEL_(x); \
  9. BODY(x)
  10. #define _SYS_call_0(x) \
  11. LABEL__(x); \
  12. LABEL(x); \
  13. BODY(x)
  14. #define SYS_call_1(x) \
  15. LABEL_(x); \
  16. ENTRY1; \
  17. BODY(x)
  18. #define _SYS_call_1(x) \
  19. LABEL__(x); \
  20. ENTRY1; \
  21. LABEL(x); \
  22. BODY(x)
  23. #define SYS_call_2(x) \
  24. LABEL_(x); \
  25. ENTRY2; \
  26. BODY(x)
  27. #define _SYS_call_2(x) \
  28. LABEL__(x); \
  29. ENTRY2; \
  30. LABEL(x); \
  31. BODY(x)
  32. #define SYS_call_3(x) \
  33. LABEL_(x); \
  34. ENTRY3; \
  35. BODY(x)
  36. #define _SYS_call_3(x) \
  37. LABEL__(x); \
  38. ENTRY3; \
  39. LABEL(x); \
  40. BODY(x)
  41. #define SYS_call_4(x) \
  42. LABEL_(x); \
  43. ENTRY4; \
  44. BODY(x)
  45. #define _SYS_call_4(x) \
  46. LABEL__(x); \
  47. ENTRY4; \
  48. LABEL(x); \
  49. BODY(x)
  50. #define SYS_call_5(x) \
  51. LABEL_(x); \
  52. ENTRY5; \
  53. BODY(x)
  54. #define _SYS_call_5(x) \
  55. LABEL__(x); \
  56. ENTRY5; \
  57. LABEL(x); \
  58. BODY(x)
  59. #define SYS_call_6(x) \
  60. LABEL_(x); \
  61. ENTRY6; \
  62. BODY(x)
  63. #define _SYS_call_6(x) \
  64. LABEL__(x); \
  65. ENTRY6; \
  66. LABEL(x); \
  67. BODY(x)
  68. #define BODY1(x) \
  69. sys_call(x); \
  70. ta %g0; \
  71. bgeu 0f; \
  72. sethi %hi(cerror), %o5; \
  73. or %o5, %lo(cerror), %o5; \
  74. jmp %o5; \
  75. nop; \
  76. 0:;
  77. #define BODY(x) \
  78. BODY1(x) \
  79. retl; \
  80. nop
  81. #if __STDC__
  82. #define LABEL_(x) \
  83. .global _ ## x; \
  84. _ ## x:
  85. #define LABEL__(x) \
  86. .global __ ## x; \
  87. __ ## x:
  88. #else
  89. #define LABEL_(x) \
  90. .global _/**/x; \
  91. _/**/x:
  92. #define LABEL__(x) \
  93. .global __/**/x; \
  94. __/**/x:
  95. #endif
  96. #define LABEL(x) \
  97. .global x; \
  98. x:
  99. #define ENTRY1 \
  100. ld [%l0], %o0 \
  101. #define ENTRY2 \
  102. ENTRY1; \
  103. ld [%l0+4], %o1 \
  104. #define ENTRY3 \
  105. ENTRY2; \
  106. ld [%l0+8], %o2 \
  107. #define ENTRY4 \
  108. ENTRY3; \
  109. ld [%l0+12], %o3 \
  110. #define ENTRY5 \
  111. ENTRY4; \
  112. ld [%l0+16], %o4 \
  113. #define ENTRY6 \
  114. ENTRY5; \
  115. ld [%l0+20], %o5 \
  116. #if __STDC__
  117. #define sys_call(x) \
  118. mov SYS_ ## x, %g1
  119. #else
  120. #define sys_call(x) \
  121. mov SYS_/**/x, %g1
  122. #endif
  123. #endif /* SYS_H */