Rizin
unix-like reverse engineering framework and cli tools
sfsyscall.h
Go to the documentation of this file.
1 /*
2  * sfsyscall.h --- SFLib syscall macros for OpenBSD/i386
3  * see http://www.secdev.org/projects/shellforge.html for more informations
4  *
5  * Copyright (C) 2004 Philippe Biondi <phil@secdev.org>
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by
9  * the Free Software Foundation.
10  *
11  * This program is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  */
16 
17 
18 /*
19  * Automatically generated by gensflib.py
20  * Fri Nov 25 15:52:34 2011
21  */
22 
23 #ifndef SFSYSCALL_H
24 #define SFSYSCALL_H
25 
26 
27 /* $Id$ */
28 
29 #ifdef SF_USE_ERRNO
30 /* Remove errno stuff */
31 int errno;
32 #error "SF_USER_ERRNO not supported yet"
33 #else
34 #define __sfsyscall_return(type, res) \
35 do { \
36  return (type) (res); \
37 } while (0)
38 #endif
39 
40 
41 /* syscall macros */
42 
43 #define _sfsyscall0(type,name) \
44 type name(void) \
45 { \
46 long __res; \
47 __asm__ volatile ("int $0x80" \
48  : "=a" (__res) \
49  : "0" (__NR_##name)); \
50 __sfsyscall_return(type,__res); \
51 }
52 
53 #define _sfsyscall1(type,name,type1,arg1) \
54 type name(type1 arg1) \
55 { \
56 long __res; \
57 __asm__ volatile ("pushl %2\n\t" \
58  "pushl %%eax\n\t" \
59  "int $0x80\n\t" \
60  "add $8, %%esp" \
61  : "=a" (__res) \
62  : "0" (__NR_##name),"g" ((long)(arg1))); \
63 __sfsyscall_return(type,__res); \
64 }
65 
66 #define _sfsyscall2(type,name,type1,arg1,type2,arg2) \
67 type name(type1 arg1,type2 arg2) \
68 { \
69 long __res; \
70 __asm__ volatile ("pushl %3\n\t" \
71  "pushl %2\n\t" \
72  "pushl %%eax\n\t" \
73  "int $0x80\n\t" \
74  "add $12, %%esp" \
75  : "=a" (__res) \
76  : "0" (__NR_##name),"g" ((long)(arg1)),"g" ((long)(arg2)) ); \
77 __sfsyscall_return(type,__res); \
78 }
79 
80 #define _sfsyscall3(type,name,type1,arg1,type2,arg2,type3,arg3) \
81 type name(type1 arg1,type2 arg2,type3 arg3) \
82 { \
83 long __res; \
84 __asm__ volatile ("pusha; pushl %4\n\t" \
85  "pushl %3\n\t" \
86  "pushl %2\n\t" \
87  "pushl %%eax\n\t" \
88  "int $0x80\n\t" \
89  "add $16, %%esp\n\t" \
90  "popa" \
91  : "=a" (__res) \
92  : "0" (__NR_##name),"g" ((long)(arg1)),"g" ((long)(arg2)), \
93  "g" ((long)(arg3)) ); \
94 __sfsyscall_return(type,__res); \
95 }
96 
97 #define _sfsyscall4(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4) \
98 type name (type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
99 { \
100 long __res; \
101 __asm__ volatile ("pushl %5\n\t" \
102  "pushl %4\n\t" \
103  "pushl %3\n\t" \
104  "pushl %2\n\t" \
105  "pushl %%eax\n\t" \
106  "int $0x80\n\t" \
107  "add $20, %%esp" \
108  : "=a" (__res) \
109  : "0" (__NR_##name),"g" ((long)(arg1)),"c" ((long)(arg2)), \
110  "d" ((long)(arg3)),"S" ((long)(arg4)) ); \
111 __sfsyscall_return(type,__res); \
112 }
113 
114 #define _sfsyscall5(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
115  type5,arg5) \
116 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5) \
117 { \
118 long __res; \
119 __asm__ volatile ("pushl %6\n\t" \
120  "pushl %5\n\t" \
121  "pushl %4\n\t" \
122  "pushl %3\n\t" \
123  "pushl %2\n\t" \
124  "pushl %%eax\n\t" \
125  "int $0x80\n\t" \
126  "add $24, %%esp" \
127  : "=a" (__res) \
128  : "0" (__NR_##name),"g" ((long)(arg1)),"g" ((long)(arg2)), \
129  "g" ((long)(arg3)),"g" ((long)(arg4)),"g" ((long)(arg5))); \
130 __sfsyscall_return(type,__res); \
131 }
132 
133 #define _sfsyscall6(type,name,type1,arg1,type2,arg2,type3,arg3,type4,arg4, \
134  type5,arg5,type6,arg6) \
135 type name (type1 arg1,type2 arg2,type3 arg3,type4 arg4,type5 arg5, type6 arg6) \
136 { \
137 long __res; \
138 __asm__ volatile ("pushl %7\n\t" \
139  "pushl %6\n\t" \
140  "pushl %5\n\t" \
141  "pushl %4\n\t" \
142  "pushl %3\n\t" \
143  "pushl %2\n\t" \
144  "pushl %%eax\n\t" \
145  "int $0x80\n\t" \
146  "add $28, %%esp" \
147  : "=a" (__res) \
148  : "0" (__NR_##name),"g" ((long)(arg1)),"g" ((long)(arg2)), \
149  "g" ((long)(arg3)),"g" ((long)(arg4)),"g" ((long)(arg5)), \
150  "g" ((long)(arg6))); \
151 __sfsyscall_return(type,__res); \
152 }
153 
154 
155 
156 #endif /* SFSYSCALL_H */