]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libc/sysdeps/linux/h8300/bits/syscalls.h
Inital import
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libc / sysdeps / linux / h8300 / bits / syscalls.h
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.
6  */
7 #ifndef _SYSCALL_H
8 # error "Never use <bits/syscalls.h> directly; include <sys/syscall.h> instead."
9 #endif
10
11 #define __syscall_return(type, res) \
12 do { \
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.  */ \
16                 int __err = -(res); \
17                 errno = __err; \
18                 res = -1; \
19         } \
20         return (type) (res); \
21 } while (0)
22
23 #define _syscall0(type, name)                                                   \
24 type name(void)                                                                 \
25 {                                                                               \
26   register long __res __asm__("er0");                                           \
27   __asm__ __volatile__ ("mov.l  %1,er0\n\t"                                     \
28                         "trapa  #0\n\t"                                         \
29                         : "=r" (__res)                                          \
30                         : "ir" (__NR_##name)                                    \
31                         : "cc");                                                \
32   if ((unsigned long)(__res) >= (unsigned long)(-125)) {                        \
33     errno = -__res;                                                             \
34     __res = -1;                                                                 \
35   }                                                                             \
36   return (type)__res;                                                           \
37 }
38
39 #define _syscall1(type, name, atype, a)                                         \
40 type name(atype a)                                                              \
41 {                                                                               \
42   register long __res __asm__("er0");                                           \
43   __asm__ __volatile__ ("mov.l  %2, er1\n\t"                                    \
44                         "mov.l  %1, er0\n\t"                                    \
45                         "trapa  #0\n\t"                                         \
46                         : "=r" (__res)                                          \
47                         : "ir" (__NR_##name),                                   \
48                           "g" ((long)a)                                         \
49                         : "cc", "er1");                                 \
50   if ((unsigned long)(__res) >= (unsigned long)(-125)) {                        \
51     errno = -__res;                                                             \
52     __res = -1;                                                                 \
53   }                                                                             \
54   return (type)__res;                                                           \
55 }
56
57 #define _syscall2(type, name, atype, a, btype, b)                               \
58 type name(atype a, btype b)                                                     \
59 {                                                                               \
60   register long __res __asm__("er0");                                           \
61   __asm__ __volatile__ ("mov.l  %3, er2\n\t"                                    \
62                         "mov.l  %2, er1\n\t"                                    \
63                         "mov.l  %1, er0\n\t"                                    \
64                         "trapa  #0\n\t"                                         \
65                         : "=r" (__res)                                          \
66                         : "ir" (__NR_##name),                                   \
67                           "g" ((long)a),                                        \
68                           "g" ((long)b)                                         \
69                         : "cc", "er1", "er2");                          \
70   if ((unsigned long)(__res) >= (unsigned long)(-125)) {                        \
71     errno = -__res;                                                             \
72     __res = -1;                                                                 \
73   }                                                                             \
74   return (type)__res;                                                           \
75 }
76
77 #define _syscall3(type, name, atype, a, btype, b, ctype, c)                     \
78 type name(atype a, btype b, ctype c)                                            \
79 {                                                                               \
80   register long __res __asm__("er0");                                           \
81   __asm__ __volatile__ ("mov.l  %4, er3\n\t"                                    \
82                         "mov.l  %3, er2\n\t"                                    \
83                         "mov.l  %2, er1\n\t"                                    \
84                         "mov.l  %1, er0\n\t"                                    \
85                         "trapa  #0\n\t"                                         \
86                         : "=r" (__res)                                          \
87                         : "ir" (__NR_##name),                                   \
88                           "g" ((long)a),                                        \
89                           "g" ((long)b),                                        \
90                           "g" ((long)c)                                         \
91                         : "cc", "er1", "er2", "er3");                   \
92   if ((unsigned long)(__res) >= (unsigned long)(-125)) {                        \
93     errno = -__res;                                                             \
94     __res = -1;                                                                 \
95   }                                                                             \
96   return (type)__res;                                                           \
97 }
98
99 #define _syscall4(type, name, atype, a, btype, b, ctype, c, dtype, d)           \
100 type name(atype a, btype b, ctype c, dtype d)                                   \
101 {                                                                               \
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"                                    \
108                         "trapa  #0\n\t"                                         \
109                         : "=r" (__res)                                          \
110                         : "ir" (__NR_##name),                                   \
111                           "g" ((long)a),                                        \
112                           "g" ((long)b),                                        \
113                           "g" ((long)c),                                        \
114                           "g" ((long)d)                                         \
115                         : "cc", "er1", "er2", "er3", "er4");                    \
116   if ((unsigned long)(__res) >= (unsigned long)(-125)) {                        \
117     errno = -__res;                                                             \
118     __res = -1;                                                                 \
119   }                                                                             \
120   return (type)__res;                                                           \
121 }
122
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)                          \
125 {                                                                               \
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"                                    \
135                         "trapa  #0\n\t"                                         \
136                        "mov.l  @sp+,er5\n\t"                                   \
137                         : "=r" (__res)                                          \
138                         : "ir" (__NR_##name),                                   \
139                           "g" ((long)a),                                        \
140                           "g" ((long)b),                                        \
141                           "g" ((long)c),                                        \
142                           "g" ((long)d),                                        \
143                           "m" ((long)e)                                         \
144                         : "cc", "er1", "er2", "er3", "er4");                    \
145   if ((unsigned long)(__res) >= (unsigned long)(-125)) {                        \
146     errno = -__res;                                                             \
147     __res = -1;                                                                 \
148   }                                                                             \
149   return (type)__res;                                                           \
150 }
151