]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/compat/freebsd32/freebsd32.h
Merge ^/head r320042 through r320397.
[FreeBSD/FreeBSD.git] / sys / compat / freebsd32 / freebsd32.h
1 /*-
2  * Copyright (c) 2001 Doug Rabson
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  * $FreeBSD$
27  */
28
29 #ifndef _COMPAT_FREEBSD32_FREEBSD32_H_
30 #define _COMPAT_FREEBSD32_FREEBSD32_H_
31
32 #include <sys/procfs.h>
33 #include <sys/socket.h>
34 #include <sys/user.h>
35
36 #define PTRIN(v)        (void *)(uintptr_t) (v)
37 #define PTROUT(v)       (u_int32_t)(uintptr_t) (v)
38
39 #define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0)
40 #define PTRIN_CP(src,dst,fld) \
41         do { (dst).fld = PTRIN((src).fld); } while (0)
42 #define PTROUT_CP(src,dst,fld) \
43         do { (dst).fld = PTROUT((src).fld); } while (0)
44
45 /*
46  * i386 is the only arch with a 32-bit time_t
47  */
48 #ifdef __amd64__
49 typedef int32_t time32_t;
50 #else
51 typedef int64_t time32_t;
52 #endif
53
54 struct timeval32 {
55         time32_t tv_sec;
56         int32_t tv_usec;
57 };
58 #define TV_CP(src,dst,fld) do {                 \
59         CP((src).fld,(dst).fld,tv_sec);         \
60         CP((src).fld,(dst).fld,tv_usec);        \
61 } while (0)
62
63 struct timespec32 {
64         time32_t tv_sec;
65         int32_t tv_nsec;
66 };
67 #define TS_CP(src,dst,fld) do {                 \
68         CP((src).fld,(dst).fld,tv_sec);         \
69         CP((src).fld,(dst).fld,tv_nsec);        \
70 } while (0)
71
72 struct itimerspec32 {
73         struct timespec32  it_interval;
74         struct timespec32  it_value;
75 };
76 #define ITS_CP(src, dst) do {                   \
77         TS_CP((src), (dst), it_interval);       \
78         TS_CP((src), (dst), it_value);          \
79 } while (0)
80
81 struct rusage32 {
82         struct timeval32 ru_utime;
83         struct timeval32 ru_stime;
84         int32_t ru_maxrss;
85         int32_t ru_ixrss;
86         int32_t ru_idrss;
87         int32_t ru_isrss;
88         int32_t ru_minflt;
89         int32_t ru_majflt;
90         int32_t ru_nswap;
91         int32_t ru_inblock;
92         int32_t ru_oublock;
93         int32_t ru_msgsnd;
94         int32_t ru_msgrcv;
95         int32_t ru_nsignals;
96         int32_t ru_nvcsw;
97         int32_t ru_nivcsw;
98 };
99
100 struct wrusage32 {
101         struct rusage32 wru_self;
102         struct rusage32 wru_children;
103 };
104
105 struct itimerval32 {
106         struct timeval32 it_interval;
107         struct timeval32 it_value;
108 };
109
110 #define FREEBSD4_MFSNAMELEN     16
111 #define FREEBSD4_MNAMELEN       (88 - 2 * sizeof(int32_t))
112
113 /* 4.x version */
114 struct statfs32 {
115         int32_t f_spare2;
116         int32_t f_bsize;
117         int32_t f_iosize;
118         int32_t f_blocks;
119         int32_t f_bfree;
120         int32_t f_bavail;
121         int32_t f_files;
122         int32_t f_ffree;
123         fsid_t  f_fsid;
124         uid_t   f_owner;
125         int32_t f_type;
126         int32_t f_flags;
127         int32_t f_syncwrites;
128         int32_t f_asyncwrites;
129         char    f_fstypename[FREEBSD4_MFSNAMELEN];
130         char    f_mntonname[FREEBSD4_MNAMELEN];
131         int32_t f_syncreads;
132         int32_t f_asyncreads;
133         int16_t f_spares1;
134         char    f_mntfromname[FREEBSD4_MNAMELEN];
135         int16_t f_spares2 __packed;
136         int32_t f_spare[2];
137 };
138
139 struct kevent32 {
140         uint32_t        ident;          /* identifier for this event */
141         short           filter;         /* filter for event */
142         u_short         flags;
143         u_int           fflags;
144         int32_t         data1, data2;
145         uint32_t        udata;          /* opaque user data identifier */
146         uint32_t        ext64[8];
147 };
148
149 struct iovec32 {
150         u_int32_t iov_base;
151         int     iov_len;
152 };
153
154 struct msghdr32 {
155         u_int32_t        msg_name;
156         socklen_t        msg_namelen;
157         u_int32_t        msg_iov;
158         int              msg_iovlen;
159         u_int32_t        msg_control;
160         socklen_t        msg_controllen;
161         int              msg_flags;
162 };
163
164 #if defined(__amd64__)
165 #define __STAT32_TIME_T_EXT     1
166 #endif
167
168 struct stat32 {
169         dev_t st_dev;
170         ino_t st_ino;
171         nlink_t st_nlink;
172         mode_t  st_mode;
173         u_int16_t st_padding0;
174         uid_t   st_uid;
175         gid_t   st_gid;
176         u_int32_t st_padding1;
177         dev_t st_rdev;
178 #ifdef  __STAT32_TIME_T_EXT
179         __int32_t st_atim_ext;
180 #endif
181         struct timespec32 st_atim;
182 #ifdef  __STAT32_TIME_T_EXT
183         __int32_t st_mtim_ext;
184 #endif
185         struct timespec32 st_mtim;
186 #ifdef  __STAT32_TIME_T_EXT
187         __int32_t st_ctim_ext;
188 #endif
189         struct timespec32 st_ctim;
190 #ifdef  __STAT32_TIME_T_EXT
191         __int32_t st_btim_ext;
192 #endif
193         struct timespec32 st_birthtim;
194         off_t   st_size;
195         int64_t st_blocks;
196         u_int32_t st_blksize;
197         u_int32_t st_flags;
198         u_int64_t st_gen;
199         u_int64_t st_spare[10];
200 };
201 struct freebsd11_stat32 {
202         u_int32_t st_dev;
203         u_int32_t st_ino;
204         mode_t  st_mode;
205         u_int16_t st_nlink;
206         uid_t   st_uid;
207         gid_t   st_gid;
208         u_int32_t st_rdev;
209         struct timespec32 st_atim;
210         struct timespec32 st_mtim;
211         struct timespec32 st_ctim;
212         off_t   st_size;
213         int64_t st_blocks;
214         u_int32_t st_blksize;
215         u_int32_t st_flags;
216         u_int32_t st_gen;
217         int32_t st_lspare;
218         struct timespec32 st_birthtim;
219         unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
220         unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec32));
221 };
222
223 struct ostat32 {
224         __uint16_t st_dev;
225         __uint32_t st_ino;
226         mode_t  st_mode;
227         __uint16_t st_nlink;
228         __uint16_t st_uid;
229         __uint16_t st_gid;
230         __uint16_t st_rdev;
231         __int32_t st_size;
232         struct timespec32 st_atim;
233         struct timespec32 st_mtim;
234         struct timespec32 st_ctim;
235         __int32_t st_blksize;
236         __int32_t st_blocks;
237         u_int32_t st_flags;
238         __uint32_t st_gen;
239 };
240
241 struct jail32_v0 {
242         u_int32_t       version;
243         uint32_t        path;
244         uint32_t        hostname;
245         u_int32_t       ip_number;
246 };
247
248 struct jail32 {
249         uint32_t        version;
250         uint32_t        path;
251         uint32_t        hostname;
252         uint32_t        jailname;
253         uint32_t        ip4s;
254         uint32_t        ip6s;
255         uint32_t        ip4;
256         uint32_t        ip6;
257 };
258
259 struct sigaction32 {
260         u_int32_t       sa_u;
261         int             sa_flags;
262         sigset_t        sa_mask;
263 };
264
265 struct thr_param32 {
266         uint32_t start_func;
267         uint32_t arg;
268         uint32_t stack_base;
269         uint32_t stack_size;
270         uint32_t tls_base;
271         uint32_t tls_size;
272         uint32_t child_tid;
273         uint32_t parent_tid;
274         int32_t  flags;
275         uint32_t rtp;
276         uint32_t spare[3];
277 };
278
279 struct i386_ldt_args32 {
280         uint32_t start;
281         uint32_t descs;
282         uint32_t num;
283 };
284
285 struct mq_attr32 {
286         int     mq_flags;
287         int     mq_maxmsg;
288         int     mq_msgsize;
289         int     mq_curmsgs;
290         int     __reserved[4];
291 };
292
293 struct kinfo_proc32 {
294         int     ki_structsize;
295         int     ki_layout;
296         uint32_t ki_args;
297         uint32_t ki_paddr;
298         uint32_t ki_addr;
299         uint32_t ki_tracep;
300         uint32_t ki_textvp;
301         uint32_t ki_fd;
302         uint32_t ki_vmspace;
303         uint32_t ki_wchan;
304         pid_t   ki_pid;
305         pid_t   ki_ppid;
306         pid_t   ki_pgid;
307         pid_t   ki_tpgid;
308         pid_t   ki_sid;
309         pid_t   ki_tsid;
310         short   ki_jobc;
311         short   ki_spare_short1;
312         uint32_t ki_tdev_freebsd11;
313         sigset_t ki_siglist;
314         sigset_t ki_sigmask;
315         sigset_t ki_sigignore;
316         sigset_t ki_sigcatch;
317         uid_t   ki_uid;
318         uid_t   ki_ruid;
319         uid_t   ki_svuid;
320         gid_t   ki_rgid;
321         gid_t   ki_svgid;
322         short   ki_ngroups;
323         short   ki_spare_short2;
324         gid_t   ki_groups[KI_NGROUPS];
325         uint32_t ki_size;
326         int32_t ki_rssize;
327         int32_t ki_swrss;
328         int32_t ki_tsize;
329         int32_t ki_dsize;
330         int32_t ki_ssize;
331         u_short ki_xstat;
332         u_short ki_acflag;
333         fixpt_t ki_pctcpu;
334         u_int   ki_estcpu;
335         u_int   ki_slptime;
336         u_int   ki_swtime;
337         u_int   ki_cow;
338         u_int64_t ki_runtime;
339         struct  timeval32 ki_start;
340         struct  timeval32 ki_childtime;
341         int     ki_flag;
342         int     ki_kiflag;
343         int     ki_traceflag;
344         char    ki_stat;
345         signed char ki_nice;
346         char    ki_lock;
347         char    ki_rqindex;
348         u_char  ki_oncpu_old;
349         u_char  ki_lastcpu_old;
350         char    ki_tdname[TDNAMLEN+1];
351         char    ki_wmesg[WMESGLEN+1];
352         char    ki_login[LOGNAMELEN+1];
353         char    ki_lockname[LOCKNAMELEN+1];
354         char    ki_comm[COMMLEN+1];
355         char    ki_emul[KI_EMULNAMELEN+1];
356         char    ki_loginclass[LOGINCLASSLEN+1];
357         char    ki_moretdname[MAXCOMLEN-TDNAMLEN+1];
358         char    ki_sparestrings[46];
359         int     ki_spareints[KI_NSPARE_INT];
360         uint64_t ki_tdev;
361         int     ki_oncpu;
362         int     ki_lastcpu;
363         int     ki_tracer;
364         int     ki_flag2;
365         int     ki_fibnum;
366         u_int   ki_cr_flags;
367         int     ki_jid;
368         int     ki_numthreads;
369         lwpid_t ki_tid;
370         struct  priority ki_pri;
371         struct  rusage32 ki_rusage;
372         struct  rusage32 ki_rusage_ch;
373         uint32_t ki_pcb;
374         uint32_t ki_kstack;
375         uint32_t ki_udata;
376         uint32_t ki_tdaddr;
377         uint32_t ki_spareptrs[KI_NSPARE_PTR];   /* spare room for growth */
378         int     ki_sparelongs[KI_NSPARE_LONG];
379         int     ki_sflag;
380         int     ki_tdflags;
381 };
382
383 struct kinfo_sigtramp32 {
384         uint32_t ksigtramp_start;
385         uint32_t ksigtramp_end;
386         uint32_t ksigtramp_spare[4];
387 };
388
389 struct kld32_file_stat_1 {
390         int     version;        /* set to sizeof(struct kld_file_stat_1) */
391         char    name[MAXPATHLEN];
392         int     refs;
393         int     id;
394         uint32_t address;       /* load address */
395         uint32_t size;          /* size in bytes */
396 };
397
398 struct kld32_file_stat {
399         int     version;        /* set to sizeof(struct kld_file_stat) */
400         char    name[MAXPATHLEN];
401         int     refs;
402         int     id;
403         uint32_t address;       /* load address */
404         uint32_t size;          /* size in bytes */
405         char    pathname[MAXPATHLEN];
406 };
407
408 struct procctl_reaper_pids32 {
409         u_int   rp_count;
410         u_int   rp_pad0[15];
411         uint32_t rp_pids;
412 };
413
414 #endif /* !_COMPAT_FREEBSD32_FREEBSD32_H_ */