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