hw/riscv: use MachineState::fdt in riscv_socket_fdt_write_id()
[qemu.git] / bsd-user / syscall_defs.h
blobb6d113d24a731c31cdc664cd92a9c0f513c24f18
1 /*
2 * System call related declarations
4 * Copyright (c) 2013-15 Stacey D. Son (sson at FreeBSD)
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20 #ifndef SYSCALL_DEFS_H
21 #define SYSCALL_DEFS_H
23 #include <sys/syscall.h>
24 #include <sys/resource.h>
26 #include "errno_defs.h"
28 #include "freebsd/syscall_nr.h"
29 #include "netbsd/syscall_nr.h"
30 #include "openbsd/syscall_nr.h"
33 * machine/_types.h
34 * or x86/_types.h
38 * time_t seems to be very inconsistly defined for the different *BSD's...
40 * FreeBSD uses a 64bits time_t except on i386
41 * so we have to add a special case here.
43 * On NetBSD time_t is always defined as an int64_t. On OpenBSD time_t
44 * is always defined as an int.
47 #if (!defined(TARGET_I386))
48 typedef int64_t target_freebsd_time_t;
49 #else
50 typedef int32_t target_freebsd_time_t;
51 #endif
53 struct target_iovec {
54 abi_long iov_base; /* Starting address */
55 abi_long iov_len; /* Number of bytes */
59 * sys/mman.h
61 #define TARGET_FREEBSD_MAP_RESERVED0080 0x0080 /* previously misimplemented */
62 /* MAP_INHERIT */
63 #define TARGET_FREEBSD_MAP_RESERVED0100 0x0100 /* previously unimplemented */
64 /* MAP_NOEXTEND */
65 #define TARGET_FREEBSD_MAP_STACK 0x0400 /* region grows down, like a */
66 /* stack */
67 #define TARGET_FREEBSD_MAP_NOSYNC 0x0800 /* page to but do not sync */
68 /* underlying file */
70 #define TARGET_FREEBSD_MAP_FLAGMASK 0x1ff7
72 #define TARGET_NETBSD_MAP_INHERIT 0x0080 /* region is retained after */
73 /* exec */
74 #define TARGET_NETBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, even */
75 /* within break */
76 #define TARGET_NETBSD_MAP_WIRED 0x0800 /* mlock() mapping when it is */
77 /* established */
79 #define TARGET_NETBSD_MAP_STACK 0x2000 /* allocated from memory, */
80 /* swap space (stack) */
82 #define TARGET_NETBSD_MAP_FLAGMASK 0x3ff7
84 #define TARGET_OPENBSD_MAP_INHERIT 0x0080 /* region is retained after */
85 /* exec */
86 #define TARGET_OPENBSD_MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change */
87 /* file size */
88 #define TARGET_OPENBSD_MAP_TRYFIXED 0x0400 /* attempt hint address, */
89 /* even within heap */
91 #define TARGET_OPENBSD_MAP_FLAGMASK 0x17f7
93 /* XXX */
94 #define TARGET_BSD_MAP_FLAGMASK 0x3ff7
97 * sys/time.h
98 * sys/timex.h
101 typedef abi_long target_freebsd_suseconds_t;
103 /* compare to sys/timespec.h */
104 struct target_freebsd_timespec {
105 target_freebsd_time_t tv_sec; /* seconds */
106 abi_long tv_nsec; /* and nanoseconds */
107 #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32
108 abi_long _pad;
109 #endif
112 #define TARGET_CPUCLOCK_WHICH_PID 0
113 #define TARGET_CPUCLOCK_WHICH_TID 1
115 /* sys/umtx.h */
116 struct target_freebsd__umtx_time {
117 struct target_freebsd_timespec _timeout;
118 uint32_t _flags;
119 uint32_t _clockid;
122 struct target_freebsd_timeval {
123 target_freebsd_time_t tv_sec; /* seconds */
124 target_freebsd_suseconds_t tv_usec;/* and microseconds */
125 #if !defined(TARGET_I386) && TARGET_ABI_BITS == 32
126 abi_long _pad;
127 #endif
131 * sys/resource.h
133 #if defined(__FreeBSD__)
134 #define TARGET_RLIM_INFINITY RLIM_INFINITY
135 #else
136 #define TARGET_RLIM_INFINITY ((abi_ulong)-1)
137 #endif
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
153 struct target_rlimit {
154 uint64_t rlim_cur;
155 uint64_t rlim_max;
158 struct target_freebsd_rusage {
159 struct target_freebsd_timeval ru_utime; /* user time used */
160 struct target_freebsd_timeval ru_stime; /* system time used */
161 abi_long ru_maxrss; /* maximum resident set size */
162 abi_long ru_ixrss; /* integral shared memory size */
163 abi_long ru_idrss; /* integral unshared data size */
164 abi_long ru_isrss; /* integral unshared stack size */
165 abi_long ru_minflt; /* page reclaims */
166 abi_long ru_majflt; /* page faults */
167 abi_long ru_nswap; /* swaps */
168 abi_long ru_inblock; /* block input operations */
169 abi_long ru_oublock; /* block output operations */
170 abi_long ru_msgsnd; /* messages sent */
171 abi_long ru_msgrcv; /* messages received */
172 abi_long ru_nsignals; /* signals received */
173 abi_long ru_nvcsw; /* voluntary context switches */
174 abi_long ru_nivcsw; /* involuntary context switches */
177 struct target_freebsd__wrusage {
178 struct target_freebsd_rusage wru_self;
179 struct target_freebsd_rusage wru_children;
182 #define safe_syscall0(type, name) \
183 type safe_##name(void) \
185 return safe_syscall(SYS_##name); \
188 #define safe_syscall1(type, name, type1, arg1) \
189 type safe_##name(type1 arg1) \
191 return safe_syscall(SYS_##name, arg1); \
194 #define safe_syscall2(type, name, type1, arg1, type2, arg2) \
195 type safe_##name(type1 arg1, type2 arg2) \
197 return safe_syscall(SYS_##name, arg1, arg2); \
200 #define safe_syscall3(type, name, type1, arg1, type2, arg2, type3, arg3) \
201 type safe_##name(type1 arg1, type2 arg2, type3 arg3) \
203 return safe_syscall(SYS_##name, arg1, arg2, arg3); \
206 #define safe_syscall4(type, name, type1, arg1, type2, arg2, type3, arg3, \
207 type4, arg4) \
208 type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4) \
210 return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4); \
213 #define safe_syscall5(type, name, type1, arg1, type2, arg2, type3, arg3, \
214 type4, arg4, type5, arg5) \
215 type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
216 type5 arg5) \
218 return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5); \
221 #define safe_syscall6(type, name, type1, arg1, type2, arg2, type3, arg3, \
222 type4, arg4, type5, arg5, type6, arg6) \
223 type safe_##name(type1 arg1, type2 arg2, type3 arg3, type4 arg4, \
224 type5 arg5, type6 arg6) \
226 return safe_syscall(SYS_##name, arg1, arg2, arg3, arg4, arg5, arg6); \
229 /* So far all target and host bitmasks are the same */
230 #define target_to_host_bitmask(x, tbl) (x)
231 #define host_to_target_bitmask(x, tbl) (x)
233 #endif /* SYSCALL_DEFS_H */