1//===-- sanitizer_platform_limits_freebsd.h -------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file is a part of Sanitizer common code.
10//
11// Sizes and layouts of platform-specific FreeBSD data structures.
12//===----------------------------------------------------------------------===//
13
14#ifndef SANITIZER_PLATFORM_LIMITS_FREEBSD_H
15#define SANITIZER_PLATFORM_LIMITS_FREEBSD_H
16
17#if SANITIZER_FREEBSD
18
19#include "sanitizer_internal_defs.h"
20#include "sanitizer_platform.h"
21
22#include "sanitizer_platform_limits_posix.h"
23
24// FreeBSD's dlopen() returns a pointer to an Obj_Entry structure that
25// incorporates the map structure.
26# define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \
27    ((link_map*)((handle) == nullptr ? nullptr : ((char*)(handle) + 560)))
28// Get sys/_types.h, because that tells us whether 64-bit inodes are
29// used in struct dirent below.
30#include <sys/_types.h>
31
32namespace __sanitizer {
33  extern unsigned struct_utsname_sz;
34  extern unsigned struct_stat_sz;
35#if defined(__powerpc64__)
36  const unsigned struct___old_kernel_stat_sz = 0;
37#else
38  const unsigned struct___old_kernel_stat_sz = 32;
39#endif
40  extern unsigned struct_rusage_sz;
41  extern unsigned siginfo_t_sz;
42  extern unsigned struct_itimerval_sz;
43  extern unsigned pthread_t_sz;
44  extern unsigned pthread_mutex_t_sz;
45  extern unsigned pthread_cond_t_sz;
46  extern unsigned pid_t_sz;
47  extern unsigned timeval_sz;
48  extern unsigned uid_t_sz;
49  extern unsigned gid_t_sz;
50  extern unsigned fpos_t_sz;
51  extern unsigned mbstate_t_sz;
52  extern unsigned struct_timezone_sz;
53  extern unsigned struct_tms_sz;
54  extern unsigned struct_itimerspec_sz;
55  extern unsigned struct_sigevent_sz;
56  extern unsigned struct_sched_param_sz;
57  extern unsigned struct_statfs64_sz;
58  extern unsigned struct_statfs_sz;
59  extern unsigned struct_sockaddr_sz;
60  extern unsigned ucontext_t_sz;
61  extern unsigned struct_rlimit_sz;
62  extern unsigned struct_utimbuf_sz;
63  extern unsigned struct_timespec_sz;
64  extern unsigned struct_regmatch_sz;
65  extern unsigned struct_regex_sz;
66  extern unsigned struct_FTS_sz;
67  extern unsigned struct_FTSENT_sz;
68  extern const int unvis_valid;
69  extern const int unvis_validpush;
70
71  struct __sanitizer_iocb {
72    u64   aio_data;
73    u32   aio_key_or_aio_reserved1; // Simply crazy.
74    u32   aio_reserved1_or_aio_key; // Luckily, we don't need these.
75    u16   aio_lio_opcode;
76    s16   aio_reqprio;
77    u32   aio_fildes;
78    u64   aio_buf;
79    u64   aio_nbytes;
80    s64   aio_offset;
81    u64   aio_reserved2;
82    u64   aio_reserved3;
83  };
84
85  struct __sanitizer_io_event {
86    u64 data;
87    u64 obj;
88    u64 res;
89    u64 res2;
90  };
91
92  const unsigned iocb_cmd_pread = 0;
93  const unsigned iocb_cmd_pwrite = 1;
94  const unsigned iocb_cmd_preadv = 7;
95  const unsigned iocb_cmd_pwritev = 8;
96
97  struct __sanitizer___sysctl_args {
98    int *name;
99    int nlen;
100    void *oldval;
101    uptr *oldlenp;
102    void *newval;
103    uptr newlen;
104    unsigned long ___unused[4];
105  };
106
107  struct __sanitizer_ipc_perm {
108    unsigned int cuid;
109    unsigned int cgid;
110    unsigned int uid;
111    unsigned int gid;
112    unsigned short mode;
113    unsigned short seq;
114    long key;
115  };
116
117#if !defined(__i386__)
118  typedef long long __sanitizer_time_t;
119#else
120  typedef long __sanitizer_time_t;
121#endif
122
123  struct __sanitizer_shmid_ds {
124    __sanitizer_ipc_perm shm_perm;
125    unsigned long shm_segsz;
126    unsigned int shm_lpid;
127    unsigned int shm_cpid;
128    int shm_nattch;
129    __sanitizer_time_t shm_atime;
130    __sanitizer_time_t shm_dtime;
131    __sanitizer_time_t shm_ctime;
132  };
133
134  extern unsigned struct_msqid_ds_sz;
135  extern unsigned struct_mq_attr_sz;
136  extern unsigned struct_timeb_sz;
137  extern unsigned struct_statvfs_sz;
138
139  struct __sanitizer_iovec {
140    void *iov_base;
141    uptr iov_len;
142  };
143
144  struct __sanitizer_ifaddrs {
145    struct __sanitizer_ifaddrs *ifa_next;
146    char *ifa_name;
147    unsigned int ifa_flags;
148    void *ifa_addr;    // (struct sockaddr *)
149    void *ifa_netmask; // (struct sockaddr *)
150# undef ifa_dstaddr
151    void *ifa_dstaddr; // (struct sockaddr *)
152    void *ifa_data;
153  };
154
155  typedef unsigned __sanitizer_pthread_key_t;
156
157  struct __sanitizer_passwd {
158    char *pw_name;
159    char *pw_passwd;
160    int pw_uid;
161    int pw_gid;
162    __sanitizer_time_t pw_change;
163    char *pw_class;
164    char *pw_gecos;
165    char *pw_dir;
166    char *pw_shell;
167    __sanitizer_time_t pw_expire;
168    int pw_fields;
169  };
170
171  struct __sanitizer_group {
172    char *gr_name;
173    char *gr_passwd;
174    int gr_gid;
175    char **gr_mem;
176  };
177
178  typedef long __sanitizer_suseconds_t;
179
180  struct __sanitizer_timeval {
181    __sanitizer_time_t tv_sec;
182    __sanitizer_suseconds_t tv_usec;
183  };
184
185  struct __sanitizer_itimerval {
186    struct __sanitizer_timeval it_interval;
187    struct __sanitizer_timeval it_value;
188  };
189
190  struct __sanitizer_timeb {
191    __sanitizer_time_t time;
192    unsigned short millitm;
193    short timezone;
194    short dstflag;
195  };
196
197  struct __sanitizer_ether_addr {
198    u8 octet[6];
199  };
200
201  struct __sanitizer_tm {
202    int tm_sec;
203    int tm_min;
204    int tm_hour;
205    int tm_mday;
206    int tm_mon;
207    int tm_year;
208    int tm_wday;
209    int tm_yday;
210    int tm_isdst;
211    long int tm_gmtoff;
212    const char *tm_zone;
213  };
214
215  struct __sanitizer_msghdr {
216    void *msg_name;
217    unsigned msg_namelen;
218    struct __sanitizer_iovec *msg_iov;
219    unsigned msg_iovlen;
220    void *msg_control;
221    unsigned msg_controllen;
222    int msg_flags;
223  };
224
225  struct __sanitizer_cmsghdr {
226    unsigned cmsg_len;
227    int cmsg_level;
228    int cmsg_type;
229  };
230
231  struct __sanitizer_dirent {
232#if defined(__INO64)
233    unsigned long long d_fileno;
234    unsigned long long d_off;
235#else
236    unsigned int d_fileno;
237#endif
238    unsigned short d_reclen;
239    // more fields that we don't care about
240  };
241
242// 'clock_t' is 32 bits wide on x64 FreeBSD
243  typedef int __sanitizer_clock_t;
244  typedef int __sanitizer_clockid_t;
245
246#if defined(_LP64) || defined(__x86_64__) || defined(__powerpc__)\
247                   || defined(__mips__)
248  typedef unsigned __sanitizer___kernel_uid_t;
249  typedef unsigned __sanitizer___kernel_gid_t;
250#else
251  typedef unsigned short __sanitizer___kernel_uid_t;
252  typedef unsigned short __sanitizer___kernel_gid_t;
253#endif
254  typedef long long __sanitizer___kernel_off_t;
255
256#if defined(__powerpc__) || defined(__mips__)
257  typedef unsigned int __sanitizer___kernel_old_uid_t;
258  typedef unsigned int __sanitizer___kernel_old_gid_t;
259#else
260  typedef unsigned short __sanitizer___kernel_old_uid_t;
261  typedef unsigned short __sanitizer___kernel_old_gid_t;
262#endif
263
264  typedef long long __sanitizer___kernel_loff_t;
265  typedef struct {
266    unsigned long fds_bits[1024 / (8 * sizeof(long))];
267  } __sanitizer___kernel_fd_set;
268
269  // This thing depends on the platform. We are only interested in the upper
270  // limit. Verified with a compiler assert in .cc.
271  const int pthread_attr_t_max_sz = 128;
272  union __sanitizer_pthread_attr_t {
273    char size[pthread_attr_t_max_sz]; // NOLINT
274    void *align;
275  };
276
277  const unsigned old_sigset_t_sz = sizeof(unsigned long);
278
279  struct __sanitizer_sigset_t {
280     // uint32_t * 4
281     unsigned int __bits[4];
282  };
283
284  typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t;
285
286  struct __sanitizer_siginfo {
287    // The size is determined by looking at sizeof of real siginfo_t on linux.
288    u64 opaque[128 / sizeof(u64)];
289  };
290
291  using __sanitizer_sighandler_ptr = void (*)(int sig);
292  using __sanitizer_sigactionhandler_ptr =
293      void (*)(int sig, __sanitizer_siginfo *siginfo, void *uctx);
294
295  struct __sanitizer_sigaction {
296    union {
297      __sanitizer_sigactionhandler_ptr sigaction;
298      __sanitizer_sighandler_ptr handler;
299    };
300    int sa_flags;
301    __sanitizer_sigset_t sa_mask;
302  };
303
304  struct __sanitizer_sem_t {
305    u32 data[4];
306  };
307
308  extern const uptr sig_ign;
309  extern const uptr sig_dfl;
310  extern const uptr sig_err;
311  extern const uptr sa_siginfo;
312
313  extern int af_inet;
314  extern int af_inet6;
315  uptr __sanitizer_in_addr_sz(int af);
316
317  struct __sanitizer_dl_phdr_info {
318    uptr dlpi_addr;
319    const char *dlpi_name;
320    const void *dlpi_phdr;
321    short dlpi_phnum;
322  };
323
324  extern unsigned struct_ElfW_Phdr_sz;
325
326  struct __sanitizer_addrinfo {
327    int ai_flags;
328    int ai_family;
329    int ai_socktype;
330    int ai_protocol;
331    unsigned ai_addrlen;
332    char *ai_canonname;
333    void *ai_addr;
334    struct __sanitizer_addrinfo *ai_next;
335  };
336
337  struct __sanitizer_hostent {
338    char *h_name;
339    char **h_aliases;
340    int h_addrtype;
341    int h_length;
342    char **h_addr_list;
343  };
344
345  struct __sanitizer_pollfd {
346    int fd;
347    short events;
348    short revents;
349  };
350
351  typedef unsigned __sanitizer_nfds_t;
352
353  struct __sanitizer_glob_t {
354    uptr gl_pathc;
355    uptr gl_matchc;
356    uptr gl_offs;
357    int gl_flags;
358    char **gl_pathv;
359    int (*gl_errfunc)(const char*, int);
360    void (*gl_closedir)(void *dirp);
361    struct dirent *(*gl_readdir)(void *dirp);
362    void *(*gl_opendir)(const char*);
363    int (*gl_lstat)(const char*, void* /* struct stat* */);
364    int (*gl_stat)(const char*, void* /* struct stat* */);
365  };
366
367  extern int glob_nomatch;
368  extern int glob_altdirfunc;
369
370  extern unsigned path_max;
371
372  struct __sanitizer_wordexp_t {
373    uptr we_wordc;
374    char **we_wordv;
375    uptr we_offs;
376    char *we_strings;
377    uptr we_nbytes;
378  };
379
380  typedef void __sanitizer_FILE;
381
382  extern unsigned struct_shminfo_sz;
383  extern unsigned struct_shm_info_sz;
384  extern int shmctl_ipc_stat;
385  extern int shmctl_ipc_info;
386  extern int shmctl_shm_info;
387  extern int shmctl_shm_stat;
388
389  extern unsigned struct_utmpx_sz;
390
391  extern int map_fixed;
392
393  // ioctl arguments
394  struct __sanitizer_ifconf {
395    int ifc_len;
396    union {
397      void *ifcu_req;
398    } ifc_ifcu;
399  };
400
401#define IOC_NRBITS 8
402#define IOC_TYPEBITS 8
403#if defined(__powerpc__) || defined(__powerpc64__) || defined(__mips__)
404#define IOC_SIZEBITS 13
405#define IOC_DIRBITS 3
406#define IOC_NONE 1U
407#define IOC_WRITE 4U
408#define IOC_READ 2U
409#else
410#define IOC_SIZEBITS 14
411#define IOC_DIRBITS 2
412#define IOC_NONE 0U
413#define IOC_WRITE 1U
414#define IOC_READ 2U
415#endif
416#define IOC_NRMASK ((1 << IOC_NRBITS) - 1)
417#define IOC_TYPEMASK ((1 << IOC_TYPEBITS) - 1)
418#define IOC_SIZEMASK ((1 << IOC_SIZEBITS) - 1)
419#if defined(IOC_DIRMASK)
420#undef IOC_DIRMASK
421#endif
422#define IOC_DIRMASK ((1 << IOC_DIRBITS) - 1)
423#define IOC_NRSHIFT 0
424#define IOC_TYPESHIFT (IOC_NRSHIFT + IOC_NRBITS)
425#define IOC_SIZESHIFT (IOC_TYPESHIFT + IOC_TYPEBITS)
426#define IOC_DIRSHIFT (IOC_SIZESHIFT + IOC_SIZEBITS)
427#define EVIOC_EV_MAX 0x1f
428#define EVIOC_ABS_MAX 0x3f
429
430#define IOC_DIR(nr) (((nr) >> IOC_DIRSHIFT) & IOC_DIRMASK)
431#define IOC_TYPE(nr) (((nr) >> IOC_TYPESHIFT) & IOC_TYPEMASK)
432#define IOC_NR(nr) (((nr) >> IOC_NRSHIFT) & IOC_NRMASK)
433#define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK)
434
435  extern unsigned struct_ifreq_sz;
436  extern unsigned struct_termios_sz;
437  extern unsigned struct_winsize_sz;
438
439  extern unsigned struct_copr_buffer_sz;
440  extern unsigned struct_copr_debug_buf_sz;
441  extern unsigned struct_copr_msg_sz;
442  extern unsigned struct_midi_info_sz;
443  extern unsigned struct_mtget_sz;
444  extern unsigned struct_mtop_sz;
445  extern unsigned struct_rtentry_sz;
446  extern unsigned struct_sbi_instrument_sz;
447  extern unsigned struct_seq_event_rec_sz;
448  extern unsigned struct_synth_info_sz;
449  extern unsigned struct_vt_mode_sz;
450
451  extern const unsigned long __sanitizer_bufsiz;
452  extern unsigned struct_audio_buf_info_sz;
453  extern unsigned struct_ppp_stats_sz;
454  extern unsigned struct_sioc_sg_req_sz;
455  extern unsigned struct_sioc_vif_req_sz;
456
457  // ioctl request identifiers
458
459  // A special value to mark ioctls that are not present on the target platform,
460  // when it can not be determined without including any system headers.
461  extern const unsigned IOCTL_NOT_PRESENT;
462
463  extern unsigned IOCTL_FIOASYNC;
464  extern unsigned IOCTL_FIOCLEX;
465  extern unsigned IOCTL_FIOGETOWN;
466  extern unsigned IOCTL_FIONBIO;
467  extern unsigned IOCTL_FIONCLEX;
468  extern unsigned IOCTL_FIOSETOWN;
469  extern unsigned IOCTL_SIOCADDMULTI;
470  extern unsigned IOCTL_SIOCATMARK;
471  extern unsigned IOCTL_SIOCDELMULTI;
472  extern unsigned IOCTL_SIOCGIFADDR;
473  extern unsigned IOCTL_SIOCGIFBRDADDR;
474  extern unsigned IOCTL_SIOCGIFCONF;
475  extern unsigned IOCTL_SIOCGIFDSTADDR;
476  extern unsigned IOCTL_SIOCGIFFLAGS;
477  extern unsigned IOCTL_SIOCGIFMETRIC;
478  extern unsigned IOCTL_SIOCGIFMTU;
479  extern unsigned IOCTL_SIOCGIFNETMASK;
480  extern unsigned IOCTL_SIOCGPGRP;
481  extern unsigned IOCTL_SIOCSIFADDR;
482  extern unsigned IOCTL_SIOCSIFBRDADDR;
483  extern unsigned IOCTL_SIOCSIFDSTADDR;
484  extern unsigned IOCTL_SIOCSIFFLAGS;
485  extern unsigned IOCTL_SIOCSIFMETRIC;
486  extern unsigned IOCTL_SIOCSIFMTU;
487  extern unsigned IOCTL_SIOCSIFNETMASK;
488  extern unsigned IOCTL_SIOCSPGRP;
489  extern unsigned IOCTL_TIOCCONS;
490  extern unsigned IOCTL_TIOCEXCL;
491  extern unsigned IOCTL_TIOCGETD;
492  extern unsigned IOCTL_TIOCGPGRP;
493  extern unsigned IOCTL_TIOCGWINSZ;
494  extern unsigned IOCTL_TIOCMBIC;
495  extern unsigned IOCTL_TIOCMBIS;
496  extern unsigned IOCTL_TIOCMGET;
497  extern unsigned IOCTL_TIOCMSET;
498  extern unsigned IOCTL_TIOCNOTTY;
499  extern unsigned IOCTL_TIOCNXCL;
500  extern unsigned IOCTL_TIOCOUTQ;
501  extern unsigned IOCTL_TIOCPKT;
502  extern unsigned IOCTL_TIOCSCTTY;
503  extern unsigned IOCTL_TIOCSETD;
504  extern unsigned IOCTL_TIOCSPGRP;
505  extern unsigned IOCTL_TIOCSTI;
506  extern unsigned IOCTL_TIOCSWINSZ;
507  extern unsigned IOCTL_SIOCGETSGCNT;
508  extern unsigned IOCTL_SIOCGETVIFCNT;
509  extern unsigned IOCTL_MTIOCGET;
510  extern unsigned IOCTL_MTIOCTOP;
511  extern unsigned IOCTL_SIOCADDRT;
512  extern unsigned IOCTL_SIOCDELRT;
513  extern unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE;
514  extern unsigned IOCTL_SNDCTL_DSP_GETFMTS;
515  extern unsigned IOCTL_SNDCTL_DSP_NONBLOCK;
516  extern unsigned IOCTL_SNDCTL_DSP_POST;
517  extern unsigned IOCTL_SNDCTL_DSP_RESET;
518  extern unsigned IOCTL_SNDCTL_DSP_SETFMT;
519  extern unsigned IOCTL_SNDCTL_DSP_SETFRAGMENT;
520  extern unsigned IOCTL_SNDCTL_DSP_SPEED;
521  extern unsigned IOCTL_SNDCTL_DSP_STEREO;
522  extern unsigned IOCTL_SNDCTL_DSP_SUBDIVIDE;
523  extern unsigned IOCTL_SNDCTL_DSP_SYNC;
524  extern unsigned IOCTL_SNDCTL_FM_4OP_ENABLE;
525  extern unsigned IOCTL_SNDCTL_FM_LOAD_INSTR;
526  extern unsigned IOCTL_SNDCTL_MIDI_INFO;
527  extern unsigned IOCTL_SNDCTL_MIDI_PRETIME;
528  extern unsigned IOCTL_SNDCTL_SEQ_CTRLRATE;
529  extern unsigned IOCTL_SNDCTL_SEQ_GETINCOUNT;
530  extern unsigned IOCTL_SNDCTL_SEQ_GETOUTCOUNT;
531  extern unsigned IOCTL_SNDCTL_SEQ_NRMIDIS;
532  extern unsigned IOCTL_SNDCTL_SEQ_NRSYNTHS;
533  extern unsigned IOCTL_SNDCTL_SEQ_OUTOFBAND;
534  extern unsigned IOCTL_SNDCTL_SEQ_PANIC;
535  extern unsigned IOCTL_SNDCTL_SEQ_PERCMODE;
536  extern unsigned IOCTL_SNDCTL_SEQ_RESET;
537  extern unsigned IOCTL_SNDCTL_SEQ_RESETSAMPLES;
538  extern unsigned IOCTL_SNDCTL_SEQ_SYNC;
539  extern unsigned IOCTL_SNDCTL_SEQ_TESTMIDI;
540  extern unsigned IOCTL_SNDCTL_SEQ_THRESHOLD;
541  extern unsigned IOCTL_SNDCTL_SYNTH_INFO;
542  extern unsigned IOCTL_SNDCTL_SYNTH_MEMAVL;
543  extern unsigned IOCTL_SNDCTL_TMR_CONTINUE;
544  extern unsigned IOCTL_SNDCTL_TMR_METRONOME;
545  extern unsigned IOCTL_SNDCTL_TMR_SELECT;
546  extern unsigned IOCTL_SNDCTL_TMR_SOURCE;
547  extern unsigned IOCTL_SNDCTL_TMR_START;
548  extern unsigned IOCTL_SNDCTL_TMR_STOP;
549  extern unsigned IOCTL_SNDCTL_TMR_TEMPO;
550  extern unsigned IOCTL_SNDCTL_TMR_TIMEBASE;
551  extern unsigned IOCTL_SOUND_MIXER_READ_ALTPCM;
552  extern unsigned IOCTL_SOUND_MIXER_READ_BASS;
553  extern unsigned IOCTL_SOUND_MIXER_READ_CAPS;
554  extern unsigned IOCTL_SOUND_MIXER_READ_CD;
555  extern unsigned IOCTL_SOUND_MIXER_READ_DEVMASK;
556  extern unsigned IOCTL_SOUND_MIXER_READ_ENHANCE;
557  extern unsigned IOCTL_SOUND_MIXER_READ_IGAIN;
558  extern unsigned IOCTL_SOUND_MIXER_READ_IMIX;
559  extern unsigned IOCTL_SOUND_MIXER_READ_LINE1;
560  extern unsigned IOCTL_SOUND_MIXER_READ_LINE2;
561  extern unsigned IOCTL_SOUND_MIXER_READ_LINE3;
562  extern unsigned IOCTL_SOUND_MIXER_READ_LINE;
563  extern unsigned IOCTL_SOUND_MIXER_READ_LOUD;
564  extern unsigned IOCTL_SOUND_MIXER_READ_MIC;
565  extern unsigned IOCTL_SOUND_MIXER_READ_MUTE;
566  extern unsigned IOCTL_SOUND_MIXER_READ_OGAIN;
567  extern unsigned IOCTL_SOUND_MIXER_READ_PCM;
568  extern unsigned IOCTL_SOUND_MIXER_READ_RECLEV;
569  extern unsigned IOCTL_SOUND_MIXER_READ_RECMASK;
570  extern unsigned IOCTL_SOUND_MIXER_READ_RECSRC;
571  extern unsigned IOCTL_SOUND_MIXER_READ_SPEAKER;
572  extern unsigned IOCTL_SOUND_MIXER_READ_STEREODEVS;
573  extern unsigned IOCTL_SOUND_MIXER_READ_SYNTH;
574  extern unsigned IOCTL_SOUND_MIXER_READ_TREBLE;
575  extern unsigned IOCTL_SOUND_MIXER_READ_VOLUME;
576  extern unsigned IOCTL_SOUND_MIXER_WRITE_ALTPCM;
577  extern unsigned IOCTL_SOUND_MIXER_WRITE_BASS;
578  extern unsigned IOCTL_SOUND_MIXER_WRITE_CD;
579  extern unsigned IOCTL_SOUND_MIXER_WRITE_ENHANCE;
580  extern unsigned IOCTL_SOUND_MIXER_WRITE_IGAIN;
581  extern unsigned IOCTL_SOUND_MIXER_WRITE_IMIX;
582  extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE1;
583  extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE2;
584  extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE3;
585  extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE;
586  extern unsigned IOCTL_SOUND_MIXER_WRITE_LOUD;
587  extern unsigned IOCTL_SOUND_MIXER_WRITE_MIC;
588  extern unsigned IOCTL_SOUND_MIXER_WRITE_MUTE;
589  extern unsigned IOCTL_SOUND_MIXER_WRITE_OGAIN;
590  extern unsigned IOCTL_SOUND_MIXER_WRITE_PCM;
591  extern unsigned IOCTL_SOUND_MIXER_WRITE_RECLEV;
592  extern unsigned IOCTL_SOUND_MIXER_WRITE_RECSRC;
593  extern unsigned IOCTL_SOUND_MIXER_WRITE_SPEAKER;
594  extern unsigned IOCTL_SOUND_MIXER_WRITE_SYNTH;
595  extern unsigned IOCTL_SOUND_MIXER_WRITE_TREBLE;
596  extern unsigned IOCTL_SOUND_MIXER_WRITE_VOLUME;
597  extern unsigned IOCTL_SOUND_PCM_READ_BITS;
598  extern unsigned IOCTL_SOUND_PCM_READ_CHANNELS;
599  extern unsigned IOCTL_SOUND_PCM_READ_FILTER;
600  extern unsigned IOCTL_SOUND_PCM_READ_RATE;
601  extern unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS;
602  extern unsigned IOCTL_SOUND_PCM_WRITE_FILTER;
603  extern unsigned IOCTL_VT_ACTIVATE;
604  extern unsigned IOCTL_VT_GETMODE;
605  extern unsigned IOCTL_VT_OPENQRY;
606  extern unsigned IOCTL_VT_RELDISP;
607  extern unsigned IOCTL_VT_SETMODE;
608  extern unsigned IOCTL_VT_WAITACTIVE;
609  extern unsigned IOCTL_GIO_SCRNMAP;
610  extern unsigned IOCTL_KDDISABIO;
611  extern unsigned IOCTL_KDENABIO;
612  extern unsigned IOCTL_KDGETLED;
613  extern unsigned IOCTL_KDGETMODE;
614  extern unsigned IOCTL_KDGKBMODE;
615  extern unsigned IOCTL_KDGKBTYPE;
616  extern unsigned IOCTL_KDMKTONE;
617  extern unsigned IOCTL_KDSETLED;
618  extern unsigned IOCTL_KDSETMODE;
619  extern unsigned IOCTL_KDSKBMODE;
620
621  extern const int si_SEGV_MAPERR;
622  extern const int si_SEGV_ACCERR;
623
624  struct __sanitizer_cap_rights {
625    u64 cr_rights[2];
626  };
627
628  typedef struct __sanitizer_cap_rights __sanitizer_cap_rights_t;
629  extern unsigned struct_cap_rights_sz;
630
631  extern unsigned struct_fstab_sz;
632  extern unsigned struct_StringList_sz;
633} // namespace __sanitizer
634
635#define CHECK_TYPE_SIZE(TYPE) \
636  COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
637
638#define CHECK_SIZE_AND_OFFSET(CLASS, MEMBER)                       \
639  COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *) NULL)->MEMBER) == \
640                 sizeof(((CLASS *) NULL)->MEMBER));                \
641  COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==          \
642                 offsetof(CLASS, MEMBER))
643
644// For sigaction, which is a function and struct at the same time,
645// and thus requires explicit "struct" in sizeof() expression.
646#define CHECK_STRUCT_SIZE_AND_OFFSET(CLASS, MEMBER)                       \
647  COMPILER_CHECK(sizeof(((struct __sanitizer_##CLASS *) NULL)->MEMBER) == \
648                 sizeof(((struct CLASS *) NULL)->MEMBER));                \
649  COMPILER_CHECK(offsetof(struct __sanitizer_##CLASS, MEMBER) ==          \
650                 offsetof(struct CLASS, MEMBER))
651
652#define SIGACTION_SYMNAME sigaction
653
654#endif
655
656#endif // SANITIZER_FREEBSD
657