1 /* Unlike the asm/unistd.h kernel header file (which this is partly based on),
2 * this file must be able to cope with PIC and non-PIC code. For some arches
3 * there is no difference. For x86 (which has far too few registers) there is
4 * a difference. Regardless, including asm/unistd.h is hereby officially
5 * forbidden. Don't do it. It is bad for you.
8 # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
11 #define __syscall_return(type, res) \
13 if ((unsigned long)(res) >= (unsigned long)(-125)) { \
14 /* avoid using res which is declared to be in register d0; \
15 errno might expand to a function call and clobber it. */ \
20 return (type) (res); \
23 #define _syscall0(type, name) \
26 register long __res __asm__("er0"); \
27 __asm__ __volatile__ ("mov.l %1,er0\n\t" \
30 : "ir" (__NR_##name) \
32 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
39 #define _syscall1(type, name, atype, a) \
42 register long __res __asm__("er0"); \
43 __asm__ __volatile__ ("mov.l %2, er1\n\t" \
47 : "ir" (__NR_##name), \
50 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
57 #define _syscall2(type, name, atype, a, btype, b) \
58 type name(atype a, btype b) \
60 register long __res __asm__("er0"); \
61 __asm__ __volatile__ ("mov.l %3, er2\n\t" \
66 : "ir" (__NR_##name), \
69 : "cc", "er1", "er2"); \
70 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
77 #define _syscall3(type, name, atype, a, btype, b, ctype, c) \
78 type name(atype a, btype b, ctype c) \
80 register long __res __asm__("er0"); \
81 __asm__ __volatile__ ("mov.l %4, er3\n\t" \
87 : "ir" (__NR_##name), \
91 : "cc", "er1", "er2", "er3"); \
92 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
99 #define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d) \
100 type name(atype a, btype b, ctype c, dtype d) \
102 register long __res __asm__("er0"); \
103 __asm__ __volatile__ ("mov.l %5, er4\n\t" \
104 "mov.l %4, er3\n\t" \
105 "mov.l %3, er2\n\t" \
106 "mov.l %2, er1\n\t" \
107 "mov.l %1, er0\n\t" \
110 : "ir" (__NR_##name), \
115 : "cc", "er1", "er2", "er3", "er4"); \
116 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
120 return (type)__res; \
123 #define _syscall5(type, name, atype, a, btype, b, ctype, c, dtype, d, etype, e) \
124 type name(atype a, btype b, ctype c, dtype d, etype e) \
126 register long __res __asm__("er0"); \
127 __asm__ __volatile__ ( \
128 "mov.l er5,@-sp\n\t" \
129 "mov.l %5, er4\n\t" \
130 "mov.l %4, er3\n\t" \
131 "mov.l %3, er2\n\t" \
132 "mov.l %2, er1\n\t" \
133 "mov.l %1, er0\n\t" \
134 "mov.l %6, er5\n\t" \
136 "mov.l @sp+,er5\n\t" \
138 : "ir" (__NR_##name), \
144 : "cc", "er1", "er2", "er3", "er4"); \
145 if ((unsigned long)(__res) >= (unsigned long)(-125)) { \
149 return (type)__res; \