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#include "sanitizer_platform_limits_posix.h"
22
23// Get sys/_types.h, because that tells us whether 64-bit inodes are
24// used in struct dirent below.
25#include <sys/_types.h>
26
27namespace __sanitizer {
28void *__sanitizer_get_link_map_by_dlopen_handle(void *handle);
29#define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \
30  (link_map *)__sanitizer_get_link_map_by_dlopen_handle(handle)
31
32extern unsigned struct_utsname_sz;
33extern unsigned struct_stat_sz;
34#if defined(__powerpc64__)
35const unsigned struct___old_kernel_stat_sz = 0;
36#else
37const unsigned struct___old_kernel_stat_sz = 32;
38#endif
39extern unsigned struct_rusage_sz;
40extern unsigned siginfo_t_sz;
41extern unsigned struct_itimerval_sz;
42extern unsigned pthread_t_sz;
43extern unsigned pthread_mutex_t_sz;
44extern unsigned pthread_cond_t_sz;
45extern unsigned pid_t_sz;
46extern unsigned timeval_sz;
47extern unsigned uid_t_sz;
48extern unsigned gid_t_sz;
49extern unsigned fpos_t_sz;
50extern unsigned mbstate_t_sz;
51extern unsigned struct_timezone_sz;
52extern unsigned struct_tms_sz;
53extern unsigned struct_itimerspec_sz;
54extern unsigned struct_sigevent_sz;
55extern unsigned struct_stack_t_sz;
56extern unsigned struct_sched_param_sz;
57extern unsigned struct_statfs64_sz;
58extern unsigned struct_statfs_sz;
59extern unsigned struct_sockaddr_sz;
60extern unsigned ucontext_t_sz;
61extern unsigned struct_rlimit_sz;
62extern unsigned struct_utimbuf_sz;
63extern unsigned struct_timespec_sz;
64extern unsigned struct_regmatch_sz;
65extern unsigned struct_regex_sz;
66extern unsigned struct_FTS_sz;
67extern unsigned struct_FTSENT_sz;
68extern const int unvis_valid;
69extern const int unvis_validpush;
70
71struct __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
85struct __sanitizer_io_event {
86  u64 data;
87  u64 obj;
88  u64 res;
89  u64 res2;
90};
91
92const unsigned iocb_cmd_pread = 0;
93const unsigned iocb_cmd_pwrite = 1;
94const unsigned iocb_cmd_preadv = 7;
95const unsigned iocb_cmd_pwritev = 8;
96
97struct __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
107struct __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__)
118typedef long long __sanitizer_time_t;
119#else
120typedef long __sanitizer_time_t;
121#endif
122
123struct __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
134extern unsigned struct_msqid_ds_sz;
135extern unsigned struct_mq_attr_sz;
136extern unsigned struct_timeb_sz;
137extern unsigned struct_statvfs_sz;
138
139struct __sanitizer_iovec {
140  void *iov_base;
141  uptr iov_len;
142};
143
144struct __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
155typedef unsigned __sanitizer_pthread_key_t;
156
157struct __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
171struct __sanitizer_group {
172  char *gr_name;
173  char *gr_passwd;
174  int gr_gid;
175  char **gr_mem;
176};
177
178typedef long __sanitizer_suseconds_t;
179
180struct __sanitizer_timeval {
181  __sanitizer_time_t tv_sec;
182  __sanitizer_suseconds_t tv_usec;
183};
184
185struct __sanitizer_itimerval {
186  struct __sanitizer_timeval it_interval;
187  struct __sanitizer_timeval it_value;
188};
189
190struct __sanitizer_timeb {
191  __sanitizer_time_t time;
192  unsigned short millitm;
193  short timezone;
194  short dstflag;
195};
196
197struct __sanitizer_ether_addr {
198  u8 octet[6];
199};
200
201struct __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
215struct __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
225struct __sanitizer_cmsghdr {
226  unsigned cmsg_len;
227  int cmsg_level;
228  int cmsg_type;
229};
230
231struct __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
243typedef int __sanitizer_clock_t;
244typedef int __sanitizer_clockid_t;
245
246#if defined(_LP64) || defined(__x86_64__) || defined(__powerpc__) || \
247    defined(__mips__)
248typedef unsigned __sanitizer___kernel_uid_t;
249typedef unsigned __sanitizer___kernel_gid_t;
250#else
251typedef unsigned short __sanitizer___kernel_uid_t;
252typedef unsigned short __sanitizer___kernel_gid_t;
253#endif
254typedef long long __sanitizer___kernel_off_t;
255
256#if defined(__powerpc__) || defined(__mips__)
257typedef unsigned int __sanitizer___kernel_old_uid_t;
258typedef unsigned int __sanitizer___kernel_old_gid_t;
259#else
260typedef unsigned short __sanitizer___kernel_old_uid_t;
261typedef unsigned short __sanitizer___kernel_old_gid_t;
262#endif
263
264typedef long long __sanitizer___kernel_loff_t;
265typedef 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 .cpp.
271union __sanitizer_pthread_attr_t {
272  char size[128];
273  void *align;
274};
275
276const unsigned old_sigset_t_sz = sizeof(unsigned long);
277
278struct __sanitizer_sigset_t {
279  // uint32_t * 4
280  unsigned int __bits[4];
281};
282
283typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t;
284
285struct __sanitizer_siginfo {
286  // The size is determined by looking at sizeof of real siginfo_t on linux.
287  u64 opaque[128 / sizeof(u64)];
288};
289
290using __sanitizer_sighandler_ptr = void (*)(int sig);
291using __sanitizer_sigactionhandler_ptr = void (*)(int sig,
292                                                  __sanitizer_siginfo *siginfo,
293                                                  void *uctx);
294
295struct __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
304struct __sanitizer_sem_t {
305  u32 data[4];
306};
307
308extern const uptr sig_ign;
309extern const uptr sig_dfl;
310extern const uptr sig_err;
311extern const uptr sa_siginfo;
312
313extern int af_inet;
314extern int af_inet6;
315uptr __sanitizer_in_addr_sz(int af);
316
317struct __sanitizer_dl_phdr_info {
318  uptr dlpi_addr;
319  const char *dlpi_name;
320  const void *dlpi_phdr;
321  short dlpi_phnum;
322};
323
324extern unsigned struct_ElfW_Phdr_sz;
325
326struct __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
337struct __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
345struct __sanitizer_pollfd {
346  int fd;
347  short events;
348  short revents;
349};
350
351typedef unsigned __sanitizer_nfds_t;
352
353struct __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
367extern int glob_nomatch;
368extern int glob_altdirfunc;
369
370extern unsigned path_max;
371
372struct __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
380typedef void __sanitizer_FILE;
381
382extern unsigned struct_shminfo_sz;
383extern unsigned struct_shm_info_sz;
384extern int shmctl_ipc_stat;
385extern int shmctl_ipc_info;
386extern int shmctl_shm_info;
387extern int shmctl_shm_stat;
388
389extern unsigned struct_utmpx_sz;
390
391extern int map_fixed;
392
393// ioctl arguments
394struct __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
435extern unsigned struct_ifreq_sz;
436extern unsigned struct_termios_sz;
437extern unsigned struct_winsize_sz;
438
439extern unsigned struct_copr_buffer_sz;
440extern unsigned struct_copr_debug_buf_sz;
441extern unsigned struct_copr_msg_sz;
442extern unsigned struct_midi_info_sz;
443extern unsigned struct_mtget_sz;
444extern unsigned struct_mtop_sz;
445extern unsigned struct_rtentry_sz;
446extern unsigned struct_sbi_instrument_sz;
447extern unsigned struct_seq_event_rec_sz;
448extern unsigned struct_synth_info_sz;
449extern unsigned struct_vt_mode_sz;
450
451extern const unsigned long __sanitizer_bufsiz;
452extern unsigned struct_audio_buf_info_sz;
453extern unsigned struct_ppp_stats_sz;
454extern unsigned struct_sioc_sg_req_sz;
455extern 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.
461extern const unsigned IOCTL_NOT_PRESENT;
462
463extern unsigned IOCTL_FIOASYNC;
464extern unsigned IOCTL_FIOCLEX;
465extern unsigned IOCTL_FIOGETOWN;
466extern unsigned IOCTL_FIONBIO;
467extern unsigned IOCTL_FIONCLEX;
468extern unsigned IOCTL_FIOSETOWN;
469extern unsigned IOCTL_SIOCADDMULTI;
470extern unsigned IOCTL_SIOCATMARK;
471extern unsigned IOCTL_SIOCDELMULTI;
472extern unsigned IOCTL_SIOCGIFADDR;
473extern unsigned IOCTL_SIOCGIFBRDADDR;
474extern unsigned IOCTL_SIOCGIFCONF;
475extern unsigned IOCTL_SIOCGIFDSTADDR;
476extern unsigned IOCTL_SIOCGIFFLAGS;
477extern unsigned IOCTL_SIOCGIFMETRIC;
478extern unsigned IOCTL_SIOCGIFMTU;
479extern unsigned IOCTL_SIOCGIFNETMASK;
480extern unsigned IOCTL_SIOCGPGRP;
481extern unsigned IOCTL_SIOCSIFADDR;
482extern unsigned IOCTL_SIOCSIFBRDADDR;
483extern unsigned IOCTL_SIOCSIFDSTADDR;
484extern unsigned IOCTL_SIOCSIFFLAGS;
485extern unsigned IOCTL_SIOCSIFMETRIC;
486extern unsigned IOCTL_SIOCSIFMTU;
487extern unsigned IOCTL_SIOCSIFNETMASK;
488extern unsigned IOCTL_SIOCSPGRP;
489extern unsigned IOCTL_TIOCCONS;
490extern unsigned IOCTL_TIOCEXCL;
491extern unsigned IOCTL_TIOCGETD;
492extern unsigned IOCTL_TIOCGPGRP;
493extern unsigned IOCTL_TIOCGWINSZ;
494extern unsigned IOCTL_TIOCMBIC;
495extern unsigned IOCTL_TIOCMBIS;
496extern unsigned IOCTL_TIOCMGET;
497extern unsigned IOCTL_TIOCMSET;
498extern unsigned IOCTL_TIOCNOTTY;
499extern unsigned IOCTL_TIOCNXCL;
500extern unsigned IOCTL_TIOCOUTQ;
501extern unsigned IOCTL_TIOCPKT;
502extern unsigned IOCTL_TIOCSCTTY;
503extern unsigned IOCTL_TIOCSETD;
504extern unsigned IOCTL_TIOCSPGRP;
505extern unsigned IOCTL_TIOCSTI;
506extern unsigned IOCTL_TIOCSWINSZ;
507extern unsigned IOCTL_SIOCGETSGCNT;
508extern unsigned IOCTL_SIOCGETVIFCNT;
509extern unsigned IOCTL_MTIOCGET;
510extern unsigned IOCTL_MTIOCTOP;
511extern unsigned IOCTL_SIOCADDRT;
512extern unsigned IOCTL_SIOCDELRT;
513extern unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE;
514extern unsigned IOCTL_SNDCTL_DSP_GETFMTS;
515extern unsigned IOCTL_SNDCTL_DSP_NONBLOCK;
516extern unsigned IOCTL_SNDCTL_DSP_POST;
517extern unsigned IOCTL_SNDCTL_DSP_RESET;
518extern unsigned IOCTL_SNDCTL_DSP_SETFMT;
519extern unsigned IOCTL_SNDCTL_DSP_SETFRAGMENT;
520extern unsigned IOCTL_SNDCTL_DSP_SPEED;
521extern unsigned IOCTL_SNDCTL_DSP_STEREO;
522extern unsigned IOCTL_SNDCTL_DSP_SUBDIVIDE;
523extern unsigned IOCTL_SNDCTL_DSP_SYNC;
524extern unsigned IOCTL_SNDCTL_FM_4OP_ENABLE;
525extern unsigned IOCTL_SNDCTL_FM_LOAD_INSTR;
526extern unsigned IOCTL_SNDCTL_MIDI_INFO;
527extern unsigned IOCTL_SNDCTL_MIDI_PRETIME;
528extern unsigned IOCTL_SNDCTL_SEQ_CTRLRATE;
529extern unsigned IOCTL_SNDCTL_SEQ_GETINCOUNT;
530extern unsigned IOCTL_SNDCTL_SEQ_GETOUTCOUNT;
531extern unsigned IOCTL_SNDCTL_SEQ_NRMIDIS;
532extern unsigned IOCTL_SNDCTL_SEQ_NRSYNTHS;
533extern unsigned IOCTL_SNDCTL_SEQ_OUTOFBAND;
534extern unsigned IOCTL_SNDCTL_SEQ_PANIC;
535extern unsigned IOCTL_SNDCTL_SEQ_PERCMODE;
536extern unsigned IOCTL_SNDCTL_SEQ_RESET;
537extern unsigned IOCTL_SNDCTL_SEQ_RESETSAMPLES;
538extern unsigned IOCTL_SNDCTL_SEQ_SYNC;
539extern unsigned IOCTL_SNDCTL_SEQ_TESTMIDI;
540extern unsigned IOCTL_SNDCTL_SEQ_THRESHOLD;
541extern unsigned IOCTL_SNDCTL_SYNTH_INFO;
542extern unsigned IOCTL_SNDCTL_SYNTH_MEMAVL;
543extern unsigned IOCTL_SNDCTL_TMR_CONTINUE;
544extern unsigned IOCTL_SNDCTL_TMR_METRONOME;
545extern unsigned IOCTL_SNDCTL_TMR_SELECT;
546extern unsigned IOCTL_SNDCTL_TMR_SOURCE;
547extern unsigned IOCTL_SNDCTL_TMR_START;
548extern unsigned IOCTL_SNDCTL_TMR_STOP;
549extern unsigned IOCTL_SNDCTL_TMR_TEMPO;
550extern unsigned IOCTL_SNDCTL_TMR_TIMEBASE;
551extern unsigned IOCTL_SOUND_MIXER_READ_ALTPCM;
552extern unsigned IOCTL_SOUND_MIXER_READ_BASS;
553extern unsigned IOCTL_SOUND_MIXER_READ_CAPS;
554extern unsigned IOCTL_SOUND_MIXER_READ_CD;
555extern unsigned IOCTL_SOUND_MIXER_READ_DEVMASK;
556extern unsigned IOCTL_SOUND_MIXER_READ_ENHANCE;
557extern unsigned IOCTL_SOUND_MIXER_READ_IGAIN;
558extern unsigned IOCTL_SOUND_MIXER_READ_IMIX;
559extern unsigned IOCTL_SOUND_MIXER_READ_LINE1;
560extern unsigned IOCTL_SOUND_MIXER_READ_LINE2;
561extern unsigned IOCTL_SOUND_MIXER_READ_LINE3;
562extern unsigned IOCTL_SOUND_MIXER_READ_LINE;
563extern unsigned IOCTL_SOUND_MIXER_READ_LOUD;
564extern unsigned IOCTL_SOUND_MIXER_READ_MIC;
565extern unsigned IOCTL_SOUND_MIXER_READ_MUTE;
566extern unsigned IOCTL_SOUND_MIXER_READ_OGAIN;
567extern unsigned IOCTL_SOUND_MIXER_READ_PCM;
568extern unsigned IOCTL_SOUND_MIXER_READ_RECLEV;
569extern unsigned IOCTL_SOUND_MIXER_READ_RECMASK;
570extern unsigned IOCTL_SOUND_MIXER_READ_RECSRC;
571extern unsigned IOCTL_SOUND_MIXER_READ_SPEAKER;
572extern unsigned IOCTL_SOUND_MIXER_READ_STEREODEVS;
573extern unsigned IOCTL_SOUND_MIXER_READ_SYNTH;
574extern unsigned IOCTL_SOUND_MIXER_READ_TREBLE;
575extern unsigned IOCTL_SOUND_MIXER_READ_VOLUME;
576extern unsigned IOCTL_SOUND_MIXER_WRITE_ALTPCM;
577extern unsigned IOCTL_SOUND_MIXER_WRITE_BASS;
578extern unsigned IOCTL_SOUND_MIXER_WRITE_CD;
579extern unsigned IOCTL_SOUND_MIXER_WRITE_ENHANCE;
580extern unsigned IOCTL_SOUND_MIXER_WRITE_IGAIN;
581extern unsigned IOCTL_SOUND_MIXER_WRITE_IMIX;
582extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE1;
583extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE2;
584extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE3;
585extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE;
586extern unsigned IOCTL_SOUND_MIXER_WRITE_LOUD;
587extern unsigned IOCTL_SOUND_MIXER_WRITE_MIC;
588extern unsigned IOCTL_SOUND_MIXER_WRITE_MUTE;
589extern unsigned IOCTL_SOUND_MIXER_WRITE_OGAIN;
590extern unsigned IOCTL_SOUND_MIXER_WRITE_PCM;
591extern unsigned IOCTL_SOUND_MIXER_WRITE_RECLEV;
592extern unsigned IOCTL_SOUND_MIXER_WRITE_RECSRC;
593extern unsigned IOCTL_SOUND_MIXER_WRITE_SPEAKER;
594extern unsigned IOCTL_SOUND_MIXER_WRITE_SYNTH;
595extern unsigned IOCTL_SOUND_MIXER_WRITE_TREBLE;
596extern unsigned IOCTL_SOUND_MIXER_WRITE_VOLUME;
597extern unsigned IOCTL_SOUND_PCM_READ_BITS;
598extern unsigned IOCTL_SOUND_PCM_READ_CHANNELS;
599extern unsigned IOCTL_SOUND_PCM_READ_FILTER;
600extern unsigned IOCTL_SOUND_PCM_READ_RATE;
601extern unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS;
602extern unsigned IOCTL_SOUND_PCM_WRITE_FILTER;
603extern unsigned IOCTL_VT_ACTIVATE;
604extern unsigned IOCTL_VT_GETMODE;
605extern unsigned IOCTL_VT_OPENQRY;
606extern unsigned IOCTL_VT_RELDISP;
607extern unsigned IOCTL_VT_SETMODE;
608extern unsigned IOCTL_VT_WAITACTIVE;
609extern unsigned IOCTL_GIO_SCRNMAP;
610extern unsigned IOCTL_KDDISABIO;
611extern unsigned IOCTL_KDENABIO;
612extern unsigned IOCTL_KDGETLED;
613extern unsigned IOCTL_KDGETMODE;
614extern unsigned IOCTL_KDGKBMODE;
615extern unsigned IOCTL_KDGKBTYPE;
616extern unsigned IOCTL_KDMKTONE;
617extern unsigned IOCTL_KDSETLED;
618extern unsigned IOCTL_KDSETMODE;
619extern unsigned IOCTL_KDSKBMODE;
620
621extern const int si_SEGV_MAPERR;
622extern const int si_SEGV_ACCERR;
623
624struct __sanitizer_cap_rights {
625  u64 cr_rights[2];
626};
627
628typedef struct __sanitizer_cap_rights __sanitizer_cap_rights_t;
629extern unsigned struct_cap_rights_sz;
630
631extern unsigned struct_fstab_sz;
632extern 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