OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [sys/] [linux/] [machine/] [i386/] [syscall.h] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* libc/sys/linux/machine/i386/syscall.h - x86 linux system calls */
2
 
3
/* Written 2000 by Werner Almesberger */
4
 
5
 
6
#ifndef SYSCALL_H
7
 
8
#include <machine/weakalias.h>
9
#include <sys/errno.h>
10
#include <asm/unistd.h>
11
#include <unistd.h>
12
 
13
 
14
/*
15
 * Note: several system calls are for SysV or BSD compatibility, or are
16
 * specific Linuxisms. Most of those system calls are not implemented in
17
 * this library.
18
 */
19
 
20
 
21
#if defined(__PIC__) && defined(__i386__)
22
 
23
/*
24
 * PIC uses %ebx, so we need to save it during system calls
25
 */
26
 
27
#ifndef __syscall_return
28
 
29
/* FIXME: remove this and switch over to use vsyscall.  */
30
 
31
#define __syscall_return(type, res) \
32
do { \
33
  if ((unsigned long)(res) >= (unsigned long)(-125)) { \
34
    errno = -(res); \
35
    res = -1; \
36
  } \
37
  return (type) (res); \
38
} while (0)
39
 
40
#endif                                                                                
41
#undef __inline_syscall0
42
#define __inline_syscall0(name,ret) \
43
__asm__ volatile ("int $0x80" \
44
        : "=a" (ret) \
45
        : "0" (__NR_##name));
46
 
47
#undef __inline_syscall1
48
#define __inline_syscall1(name,ret,arg1) \
49
__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
50
        : "=a" (ret) \
51
        : "0" (__NR_##name),"r" ((long)(arg1)));
52
 
53
#undef __inline_syscall2
54
#define __inline_syscall2(name,ret,arg1,arg2) \
55
__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
56
        : "=a" (ret) \
57
        : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)));
58
 
59
#undef __inline_syscall3
60
#define __inline_syscall3(name,ret,arg1,arg2,arg3) \
61
__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
62
        : "=a" (ret) \
63
        : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
64
                "d" ((long)(arg3)));
65
 
66
#undef __inline_syscall4
67
#define __inline_syscall4(name,ret,arg1,arg2,arg3,arg4) \
68
__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
69
        : "=a" (ret) \
70
        : "0" (__NR_##name),"r" ((long)(arg1)),"c" ((long)(arg2)), \
71
          "d" ((long)(arg3)),"S" ((long)(arg4)));
72
 
73
#undef __inline_syscall5
74
#define __inline_syscall5(name,ret,arg1,arg2,arg3,arg4,arg5) \
75
__asm__ volatile ("push %%ebx; movl %2,%%ebx; int $0x80; pop %%ebx" \
76
        : "=a" (ret) \
77
        : "0" (__NR_##name),"m" ((long)(arg1)),"c" ((long)(arg2)), \
78
          "d" ((long)(arg3)),"S" ((long)(arg4)),"D" ((long)(arg5)));
79
 
80
#undef __inline_syscall6
81
#define __inline_syscall6(name,ret,arg1,arg2,arg3,arg4,arg5,arg6) \
82
__asm__ volatile ("push %%ebx; lea 8(%%ebp),%%ebx; int $0x80; pop %%ebx" \
83
        : "=a" (ret) \
84
        : "0" (__NR_##name));
85
 
86
#undef _syscall0_base
87
#define _syscall0_base(type,name) \
88
type __libc_##name (void) \
89
{ \
90
long __res; \
91
__inline_syscall0(name,__res) \
92
__syscall_return(type,__res); \
93
}
94
 
95
#undef _syscall1_base
96
#define _syscall1_base(type,name,type1,arg1) \
97
type __libc_##name (type1 arg1) \
98
{ \
99
long __res; \
100
__inline_syscall1(name,__res,arg1) \
101
__syscall_return(type,__res); \
102
}
103
 
104
#undef _syscall2_base
105
#define _syscall2_base(type,name,type1,arg1,type2,arg2) \
106
type __libc_##name (type1 arg1,type2 arg2) \
107
{ \
108
long __res; \
109
__inline_syscall2(name,__res,arg1,arg2) \
110
__syscall_return(type,__res); \
111
}
112
 
113
#undef _syscall3_base
114
#define _syscall3_base(type,name,type1,arg1,type2,arg2,type3,arg3) \
115
type __libc_##name (type1 arg1,type2 arg2,type3 arg3) \
116
{ \
117
long __res; \
118
__inline_syscall3(name,__res,arg1,arg2,arg3) \
119
__syscall_return(type,__res); \
120
}
121
 
122
#undef _syscall4_base
123
#define _syscall4_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
124
type __libc_##name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
125
{ \
126
long __res; \
127
__inline_syscall4(name,__res,arg1,arg2,arg3,arg4) \
128
__syscall_return(type,__res); \
129
}
130
 
131
#undef _syscall5_base
132
#define _syscall5_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
133
          type5,arg5) \
134
type __libc_##name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
135
{ \
136
long __res; \
137
__inline_syscall5(name,__res,arg1,arg2,arg3,arg4,arg5) \
138
__syscall_return(type,__res); \
139
} \
140
 
141
#undef _syscall6_base
142
#define _syscall6_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
143
          type5,arg5,type6,arg6) \
144
type __libc_##name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5,type6 arg6) \
145
{ \
146
long __res; \
147
__inline_syscall6(name,__res,arg1,arg2,arg3,arg4,arg5,arg6) \
148
__syscall_return(type,__res); \
149
}
150
 
151
#undef _syscall0
152
#define _syscall0(type,name) \
153
_syscall0_base(type,name) \
154
weak_alias(__libc_##name,name);
155
 
156
#undef _syscall1
157
#define _syscall1(type,name,type1,arg1) \
158
_syscall1_base(type,name,type1,arg1) \
159
weak_alias(__libc_##name,name);
160
 
161
#undef _syscall2
162
#define _syscall2(type,name,type1,arg1,type2,arg2) \
163
_syscall2_base(type,name,type1,arg1,type2,arg2) \
164
weak_alias(__libc_##name,name);
165
 
166
#undef _syscall3
167
#define _syscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
168
_syscall3_base(type,name,type1,arg1,type2,arg2,type3,arg3) \
169
weak_alias(__libc_##name,name);
170
 
171
#undef _syscall4
172
#define _syscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
173
_syscall4_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
174
weak_alias(__libc_##name,name);
175
 
176
#undef _syscall5
177
#define _syscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
178
          type5,arg5) \
179
_syscall5_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5) \
180
weak_alias(__libc_##name,name);
181
 
182
#undef _syscall6
183
#define _syscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
184
          type5,arg5,type6,arg6) \
185
_syscall6_base(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4,type5,arg5,type6,arg6) \
186
weak_alias(__libc_##name,name);
187
 
188
#endif /* __PIC__ && __i386__ */
189
 
190
#endif /* SYSCALL_H */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.