1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef SYSCALL_DEFS_H
21#define SYSCALL_DEFS_H
22
23#include <sys/syscall.h>
24#include <sys/resource.h>
25
26#include "errno_defs.h"
27
28#include "freebsd/syscall_nr.h"
29#include "netbsd/syscall_nr.h"
30#include "openbsd/syscall_nr.h"
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47#if (!defined(TARGET_I386))
48typedef int64_t target_freebsd_time_t;
49#else
50typedef int32_t target_freebsd_time_t;
51#endif
52
53struct target_iovec {
54 abi_long iov_base;
55 abi_long iov_len;
56};
57
58
59
60
61#define TARGET_FREEBSD_MAP_RESERVED0080 0x0080
62
63#define TARGET_FREEBSD_MAP_RESERVED0100 0x0100
64
65#define TARGET_FREEBSD_MAP_STACK 0x0400
66
67#define TARGET_FREEBSD_MAP_NOSYNC 0x0800
68
69
70#define TARGET_FREEBSD_MAP_FLAGMASK 0x1ff7
71
72#define TARGET_NETBSD_MAP_INHERIT 0x0080
73
74#define TARGET_NETBSD_MAP_TRYFIXED 0x0400
75
76#define TARGET_NETBSD_MAP_WIRED 0x0800
77
78
79#define TARGET_NETBSD_MAP_STACK 0x2000
80
81
82#define TARGET_NETBSD_MAP_FLAGMASK 0x3ff7
83
84#define TARGET_OPENBSD_MAP_INHERIT 0x0080
85
86#define TARGET_OPENBSD_MAP_NOEXTEND 0x0100
87
88#define TARGET_OPENBSD_MAP_TRYFIXED 0x0400
89
90
91#define TARGET_OPENBSD_MAP_FLAGMASK 0x17f7
92
93
94#define TARGET_BSD_MAP_FLAGMASK 0x3ff7
95
96
97
98
99
100
101typedef abi_long target_freebsd_suseconds_t;
102
103
104struct target_freebsd_timespec {
105 target_freebsd_time_t tv_sec;
106 abi_long tv_nsec;
107#if !defined(TARGET_I386) && TARGET_ABI_BITS == 32
108 abi_long _pad;
109#endif
110};
111
112#define TARGET_CPUCLOCK_WHICH_PID 0
113#define TARGET_CPUCLOCK_WHICH_TID 1
114
115
116struct target_freebsd__umtx_time {
117 struct target_freebsd_timespec _timeout;
118 uint32_t _flags;
119 uint32_t _clockid;
120};
121
122struct target_freebsd_timeval {
123 target_freebsd_time_t tv_sec;
124 target_freebsd_suseconds_t tv_usec;
125#if !defined(TARGET_I386) && TARGET_ABI_BITS == 32
126 abi_long _pad;
127#endif
128};
129
130
131
132
133#if defined(__FreeBSD__)
134#define TARGET_RLIM_INFINITY RLIM_INFINITY
135#else
136#define TARGET_RLIM_INFINITY ((abi_ulong)-1)
137#endif
138
139#define TARGET_RLIMIT_CPU 0
140#define TARGET_RLIMIT_FSIZE 1
141#define TARGET_RLIMIT_DATA 2
142#define TARGET_RLIMIT_STACK 3
143#define TARGET_RLIMIT_CORE 4
144#define TARGET_RLIMIT_RSS 5
145#define TARGET_RLIMIT_MEMLOCK 6
146#define TARGET_RLIMIT_NPROC 7
147#define TARGET_RLIMIT_NOFILE 8
148#define TARGET_RLIMIT_SBSIZE 9
149#define TARGET_RLIMIT_AS 10
150#define TARGET_RLIMIT_NPTS 11
151#define TARGET_RLIMIT_SWAP 12
152
153struct target_rlimit {
154 uint64_t rlim_cur;
155 uint64_t rlim_max;
156};
157
158struct target_freebsd_rusage {
159 struct target_freebsd_timeval ru_utime;
160 struct target_freebsd_timeval ru_stime;
161 abi_long ru_maxrss;
162 abi_long ru_ixrss;
163 abi_long ru_idrss;
164 abi_long ru_isrss;
165 abi_long ru_minflt;
166 abi_long ru_majflt;
167 abi_long ru_nswap;
168 abi_long ru_inblock;
169 abi_long ru_oublock;
170 abi_long ru_msgsnd;
171 abi_long ru_msgrcv;
172 abi_long ru_nsignals;
173 abi_long ru_nvcsw;
174 abi_long ru_nivcsw;
175};
176
177struct target_freebsd__wrusage {
178 struct target_freebsd_rusage wru_self;
179 struct target_freebsd_rusage wru_children;
180};
181
182#define safe_syscall0(type, name) \
183type safe_##name(void) \
184{ \
185 return safe_syscall(SYS_##name); \
186}
187
188#define safe_syscall1(type, name, type1, arg1) \
189type safe_##name(type1 arg1) \
190{ \
191 return safe_syscall(SYS_##name, arg1); \
192}
193
194#define safe_syscall2(type, name, type1, arg1, type2, arg2) \
195type safe_##name(type1 arg1, type2 arg2) \
196{ \
197 return safe_syscall(SYS_##name, arg1, arg2); \
198}
199
200#define safe_syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \
201type safe_##name(type1 arg1, type2 arg2, type3 arg3) \
202{ \
203 return safe_syscall(SYS_##name, arg1, arg2, arg3); \
204}
205
206#define safe_syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \
207 type4, arg4) \
208type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
209{ \
210 return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4); \
211}
212
213#define safe_syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \
214 type4, arg4, type5, arg5) \
215type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
216 type5 arg5) \
217{ \
218 return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5); \
219}
220
221#define safe_syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \
222 type4, arg4, type5, arg5, type6, arg6) \
223type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
224 type5 arg5, type6 arg6) \
225{ \
226 return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5, arg6); \
227}
228
229
230#define target_to_host_bitmask(x, tbl) (x)
231#define host_to_target_bitmask(x, tbl) (x)
232
233#endif
234