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