1 //===-- sanitizer_platform_limits_posix.cpp -------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file is a part of Sanitizer common code.
11 // Sizes and layouts of platform-specific POSIX data structures.
12 //===----------------------------------------------------------------------===//
14 #if defined(__linux__) || defined(__APPLE__)
15 // Tests in this file assume that off_t-dependent data structures match the
16 // libc ABI. For example, struct dirent here is what readdir() function (as
17 // exported from libc) returns, and not the user-facing "dirent", which
18 // depends on _FILE_OFFSET_BITS setting.
19 // To get this "true" dirent definition, we undefine _FILE_OFFSET_BITS below.
20 #undef _FILE_OFFSET_BITS
24 // Must go after undef _FILE_OFFSET_BITS.
25 #include "sanitizer_platform.h"
27 #if SANITIZER_LINUX || SANITIZER_APPLE
28 // Must go after undef _FILE_OFFSET_BITS.
29 #include "sanitizer_glibc_version.h"
31 #include <arpa/inet.h>
44 #include <sys/resource.h>
45 #include <sys/socket.h>
48 #include <sys/times.h>
49 #include <sys/types.h>
50 #include <sys/utsname.h>
60 #include <net/route.h>
63 #if !SANITIZER_ANDROID
64 #include <sys/mount.h>
65 #include <sys/timeb.h>
72 #include <netinet/ether.h>
73 #include <sys/sysinfo.h>
75 #include <linux/cdrom.h>
80 #include <linux/hdreg.h>
81 #include <linux/input.h>
82 #include <linux/ioctl.h>
83 #include <linux/soundcard.h>
84 #include <linux/sysctl.h>
85 #include <linux/utsname.h>
86 #include <linux/posix_types.h>
87 #include <net/if_arp.h>
96 # include <sys/ptrace.h>
97 # if defined(__mips64) || defined(__aarch64__) || defined(__arm__) || \
98 defined(__hexagon__) || defined(__loongarch__) || SANITIZER_RISCV64 || \
100 # include <asm/ptrace.h>
102 typedef struct user_fpregs elf_fpregset_t
;
103 # define ARM_VFPREGS_SIZE_ASAN (32 * 8 /*fpregs*/ + 4 /*fpscr*/)
104 # if !defined(ARM_VFPREGS_SIZE)
105 # define ARM_VFPREGS_SIZE ARM_VFPREGS_SIZE_ASAN
109 # include <semaphore.h>
112 #if !SANITIZER_ANDROID
114 #include <sys/ucontext.h>
121 # include <linux/filter.h>
122 # include <net/if_ppp.h>
123 # include <netax25/ax25.h>
124 # include <netipx/ipx.h>
125 # include <netrom/netrom.h>
126 # include <obstack.h>
128 # include <rpc/xdr.h>
130 # include <scsi/scsi.h>
132 #include <linux/if_ppp.h>
133 #include <linux/kd.h>
134 #include <linux/ppp_defs.h>
135 #endif // SANITIZER_GLIBC
137 #if SANITIZER_ANDROID
138 #include <linux/mtio.h>
143 #include <sys/mtio.h>
145 #include <sys/statvfs.h>
146 #include <sys/timex.h>
147 #if defined(__mips64)
148 # include <sys/procfs.h>
150 #include <sys/user.h>
151 #include <linux/if_eql.h>
152 #include <linux/if_plip.h>
153 #include <linux/lp.h>
154 #include <linux/mroute.h>
155 #include <linux/mroute6.h>
156 #include <linux/scc.h>
157 #include <linux/serial.h>
160 #endif // SANITIZER_ANDROID
164 #include <sys/epoll.h>
165 #include <linux/capability.h>
168 #endif // SANITIZER_LINUX
171 #include <net/ethernet.h>
172 #include <sys/filio.h>
173 #include <sys/sockio.h>
176 // Include these after system headers to avoid name clashes and ambiguities.
177 # include "sanitizer_common.h"
178 # include "sanitizer_internal_defs.h"
179 # include "sanitizer_platform_interceptors.h"
180 # include "sanitizer_platform_limits_posix.h"
182 namespace __sanitizer
{
183 unsigned struct_utsname_sz
= sizeof(struct utsname
);
184 unsigned struct_stat_sz
= sizeof(struct stat
);
185 #if SANITIZER_HAS_STAT64
186 unsigned struct_stat64_sz
= sizeof(struct stat64
);
187 #endif // SANITIZER_HAS_STAT64
188 unsigned struct_rusage_sz
= sizeof(struct rusage
);
189 unsigned struct_tm_sz
= sizeof(struct tm
);
190 unsigned struct_passwd_sz
= sizeof(struct passwd
);
191 unsigned struct_group_sz
= sizeof(struct group
);
192 unsigned siginfo_t_sz
= sizeof(siginfo_t
);
193 unsigned struct_sigaction_sz
= sizeof(struct sigaction
);
194 unsigned struct_stack_t_sz
= sizeof(stack_t
);
195 unsigned struct_itimerval_sz
= sizeof(struct itimerval
);
196 unsigned pthread_t_sz
= sizeof(pthread_t
);
197 unsigned pthread_mutex_t_sz
= sizeof(pthread_mutex_t
);
198 unsigned pthread_cond_t_sz
= sizeof(pthread_cond_t
);
199 unsigned pid_t_sz
= sizeof(pid_t
);
200 unsigned timeval_sz
= sizeof(timeval
);
201 unsigned uid_t_sz
= sizeof(uid_t
);
202 unsigned gid_t_sz
= sizeof(gid_t
);
203 unsigned mbstate_t_sz
= sizeof(mbstate_t);
204 unsigned sigset_t_sz
= sizeof(sigset_t
);
205 unsigned struct_timezone_sz
= sizeof(struct timezone
);
206 unsigned struct_tms_sz
= sizeof(struct tms
);
207 unsigned struct_sigevent_sz
= sizeof(struct sigevent
);
208 unsigned struct_sched_param_sz
= sizeof(struct sched_param
);
209 unsigned struct_regex_sz
= sizeof(regex_t
);
210 unsigned struct_regmatch_sz
= sizeof(regmatch_t
);
212 #if SANITIZER_HAS_STATFS64
213 unsigned struct_statfs64_sz
= sizeof(struct statfs64
);
214 #endif // SANITIZER_HAS_STATFS64
216 #if SANITIZER_GLIBC || SANITIZER_FREEBSD || SANITIZER_NETBSD || SANITIZER_APPLE
217 unsigned struct_fstab_sz
= sizeof(struct fstab
);
218 #endif // SANITIZER_GLIBC || SANITIZER_FREEBSD || SANITIZER_NETBSD ||
220 #if !SANITIZER_ANDROID
221 unsigned struct_statfs_sz
= sizeof(struct statfs
);
222 unsigned struct_sockaddr_sz
= sizeof(struct sockaddr
);
224 unsigned ucontext_t_sz(void *ctx
) {
225 # if SANITIZER_GLIBC && SANITIZER_X64
226 // Added in Linux kernel 3.4.0, merged to glibc in 2.16
227 # ifndef FP_XSTATE_MAGIC1
228 # define FP_XSTATE_MAGIC1 0x46505853U
230 // See kernel arch/x86/kernel/fpu/signal.c for details.
231 const auto *fpregs
= static_cast<ucontext_t
*>(ctx
)->uc_mcontext
.fpregs
;
232 // The member names differ across header versions, but the actual layout
233 // is always the same. So avoid using members, just use arithmetic.
234 const uint32_t *after_xmm
=
235 reinterpret_cast<const uint32_t *>(fpregs
+ 1) - 24;
236 if (after_xmm
[12] == FP_XSTATE_MAGIC1
)
237 return reinterpret_cast<const char *>(fpregs
) + after_xmm
[13] -
238 static_cast<const char *>(ctx
);
240 return sizeof(ucontext_t
);
242 # endif // !SANITIZER_ANDROID
245 unsigned struct_epoll_event_sz
= sizeof(struct epoll_event
);
246 unsigned struct_sysinfo_sz
= sizeof(struct sysinfo
);
247 unsigned __user_cap_header_struct_sz
=
248 sizeof(struct __user_cap_header_struct
);
249 unsigned __user_cap_data_struct_sz(void *hdrp
) {
252 switch (((struct __user_cap_header_struct
*)hdrp
)->version
) {
253 case _LINUX_CAPABILITY_VERSION_1
:
254 u32s
= _LINUX_CAPABILITY_U32S_1
;
256 case _LINUX_CAPABILITY_VERSION_2
:
257 u32s
= _LINUX_CAPABILITY_U32S_2
;
259 case _LINUX_CAPABILITY_VERSION_3
:
260 u32s
= _LINUX_CAPABILITY_U32S_3
;
264 return sizeof(struct __user_cap_data_struct
) * u32s
;
266 unsigned struct_new_utsname_sz
= sizeof(struct new_utsname
);
267 unsigned struct_old_utsname_sz
= sizeof(struct old_utsname
);
268 unsigned struct_oldold_utsname_sz
= sizeof(struct oldold_utsname
);
269 #endif // SANITIZER_LINUX
272 unsigned struct_rlimit_sz
= sizeof(struct rlimit
);
273 unsigned struct_timespec_sz
= sizeof(struct timespec
);
274 unsigned struct_utimbuf_sz
= sizeof(struct utimbuf
);
275 unsigned struct_itimerspec_sz
= sizeof(struct itimerspec
);
276 #endif // SANITIZER_LINUX
279 // Use pre-computed size of struct ustat to avoid <sys/ustat.h> which
280 // has been removed from glibc 2.28.
281 #if defined(__aarch64__) || defined(__s390x__) || defined(__mips64) || \
282 defined(__powerpc64__) || defined(__arch64__) || defined(__sparcv9) || \
283 defined(__x86_64__) || SANITIZER_RISCV64
284 #define SIZEOF_STRUCT_USTAT 32
285 # elif defined(__arm__) || defined(__i386__) || defined(__mips__) || \
286 defined(__powerpc__) || defined(__s390__) || defined(__sparc__) || \
288 # define SIZEOF_STRUCT_USTAT 20
289 # elif defined(__loongarch__)
290 // Not used. The minimum Glibc version available for LoongArch is 2.36
291 // so ustat() wrapper is already gone.
292 # define SIZEOF_STRUCT_USTAT 0
294 # error Unknown size of struct ustat
296 unsigned struct_ustat_sz
= SIZEOF_STRUCT_USTAT
;
297 unsigned struct_rlimit64_sz
= sizeof(struct rlimit64
);
298 unsigned struct_statvfs64_sz
= sizeof(struct statvfs64
);
299 #endif // SANITIZER_GLIBC
301 #if SANITIZER_LINUX && !SANITIZER_ANDROID
302 unsigned struct_timex_sz
= sizeof(struct timex
);
303 unsigned struct_msqid_ds_sz
= sizeof(struct msqid_ds
);
304 unsigned struct_mq_attr_sz
= sizeof(struct mq_attr
);
305 unsigned struct_statvfs_sz
= sizeof(struct statvfs
);
306 #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
308 const uptr sig_ign
= (uptr
)SIG_IGN
;
309 const uptr sig_dfl
= (uptr
)SIG_DFL
;
310 const uptr sig_err
= (uptr
)SIG_ERR
;
311 const uptr sa_siginfo
= (uptr
)SA_SIGINFO
;
314 int e_tabsz
= (int)E_TABSZ
;
318 #if SANITIZER_LINUX && !SANITIZER_ANDROID
319 unsigned struct_shminfo_sz
= sizeof(struct shminfo
);
320 unsigned struct_shm_info_sz
= sizeof(struct shm_info
);
321 int shmctl_ipc_stat
= (int)IPC_STAT
;
322 int shmctl_ipc_info
= (int)IPC_INFO
;
323 int shmctl_shm_info
= (int)SHM_INFO
;
324 int shmctl_shm_stat
= (int)SHM_STAT
;
327 #if !SANITIZER_APPLE && !SANITIZER_FREEBSD
328 unsigned struct_utmp_sz
= sizeof(struct utmp
);
330 #if !SANITIZER_ANDROID
331 unsigned struct_utmpx_sz
= sizeof(struct utmpx
);
334 int map_fixed
= MAP_FIXED
;
336 int af_inet
= (int)AF_INET
;
337 int af_inet6
= (int)AF_INET6
;
339 uptr
__sanitizer_in_addr_sz(int af
) {
341 return sizeof(struct in_addr
);
342 else if (af
== AF_INET6
)
343 return sizeof(struct in6_addr
);
349 unsigned struct_ElfW_Phdr_sz
= sizeof(ElfW(Phdr
));
350 #elif SANITIZER_FREEBSD
351 unsigned struct_ElfW_Phdr_sz
= sizeof(Elf_Phdr
);
355 int glob_nomatch
= GLOB_NOMATCH
;
356 int glob_altdirfunc
= GLOB_ALTDIRFUNC
;
359 # if !SANITIZER_ANDROID
360 const int wordexp_wrde_dooffs
= WRDE_DOOFFS
;
361 # endif // !SANITIZER_ANDROID
363 # if SANITIZER_LINUX && !SANITIZER_ANDROID && \
364 (defined(__i386) || defined(__x86_64) || defined(__mips64) || \
365 defined(__powerpc64__) || defined(__aarch64__) || defined(__arm__) || \
366 defined(__s390__) || defined(__loongarch__) || SANITIZER_RISCV64 || \
368 # if defined(__mips64) || defined(__powerpc64__) || defined(__arm__)
369 unsigned struct_user_regs_struct_sz
= sizeof(struct pt_regs
);
370 unsigned struct_user_fpregs_struct_sz
= sizeof(elf_fpregset_t
);
371 #elif SANITIZER_RISCV64
372 unsigned struct_user_regs_struct_sz
= sizeof(struct user_regs_struct
);
373 unsigned struct_user_fpregs_struct_sz
= sizeof(struct __riscv_q_ext_state
);
374 #elif defined(__aarch64__)
375 unsigned struct_user_regs_struct_sz
= sizeof(struct user_pt_regs
);
376 unsigned struct_user_fpregs_struct_sz
= sizeof(struct user_fpsimd_state
);
377 #elif defined(__loongarch__)
378 unsigned struct_user_regs_struct_sz
= sizeof(struct user_pt_regs
);
379 unsigned struct_user_fpregs_struct_sz
= sizeof(struct user_fp_state
);
380 #elif defined(__s390__)
381 unsigned struct_user_regs_struct_sz
= sizeof(struct _user_regs_struct
);
382 unsigned struct_user_fpregs_struct_sz
= sizeof(struct _user_fpregs_struct
);
383 # elif defined(__sparc__)
384 unsigned struct_user_regs_struct_sz
= sizeof(struct sunos_regs
);
385 unsigned struct_user_fpregs_struct_sz
= sizeof(struct sunos_fp
);
387 unsigned struct_user_regs_struct_sz
= sizeof(struct user_regs_struct
);
388 unsigned struct_user_fpregs_struct_sz
= sizeof(struct user_fpregs_struct
);
389 # endif // __mips64 || __powerpc64__ || __aarch64__ || __loongarch__
390 # if defined(__x86_64) || defined(__mips64) || defined(__powerpc64__) || \
391 defined(__aarch64__) || defined(__arm__) || defined(__s390__) || \
392 defined(__loongarch__) || SANITIZER_RISCV64 || defined(__sparc__)
393 unsigned struct_user_fpxregs_struct_sz
= 0;
395 unsigned struct_user_fpxregs_struct_sz
= sizeof(struct user_fpxregs_struct
);
396 #endif // __x86_64 || __mips64 || __powerpc64__ || __aarch64__ || __arm__
397 // || __s390__ || __loongarch__ || SANITIZER_RISCV64 || __sparc__
399 unsigned struct_user_vfpregs_struct_sz
= ARM_VFPREGS_SIZE
;
401 unsigned struct_user_vfpregs_struct_sz
= 0;
404 int ptrace_peektext
= PTRACE_PEEKTEXT
;
405 int ptrace_peekdata
= PTRACE_PEEKDATA
;
406 int ptrace_peekuser
= PTRACE_PEEKUSER
;
407 #if (defined(PTRACE_GETREGS) && defined(PTRACE_SETREGS)) || \
408 (defined(PT_GETREGS) && defined(PT_SETREGS))
409 int ptrace_getregs
= PTRACE_GETREGS
;
410 int ptrace_setregs
= PTRACE_SETREGS
;
412 int ptrace_getregs
= -1;
413 int ptrace_setregs
= -1;
415 #if (defined(PTRACE_GETFPREGS) && defined(PTRACE_SETFPREGS)) || \
416 (defined(PT_GETFPREGS) && defined(PT_SETFPREGS))
417 int ptrace_getfpregs
= PTRACE_GETFPREGS
;
418 int ptrace_setfpregs
= PTRACE_SETFPREGS
;
420 int ptrace_getfpregs
= -1;
421 int ptrace_setfpregs
= -1;
423 #if (defined(PTRACE_GETFPXREGS) && defined(PTRACE_SETFPXREGS)) || \
424 (defined(PT_GETFPXREGS) && defined(PT_SETFPXREGS))
425 int ptrace_getfpxregs
= PTRACE_GETFPXREGS
;
426 int ptrace_setfpxregs
= PTRACE_SETFPXREGS
;
428 int ptrace_getfpxregs
= -1;
429 int ptrace_setfpxregs
= -1;
430 #endif // PTRACE_GETFPXREGS/PTRACE_SETFPXREGS
431 #if defined(PTRACE_GETVFPREGS) && defined(PTRACE_SETVFPREGS)
432 int ptrace_getvfpregs
= PTRACE_GETVFPREGS
;
433 int ptrace_setvfpregs
= PTRACE_SETVFPREGS
;
435 int ptrace_getvfpregs
= -1;
436 int ptrace_setvfpregs
= -1;
438 int ptrace_geteventmsg
= PTRACE_GETEVENTMSG
;
439 #if (defined(PTRACE_GETSIGINFO) && defined(PTRACE_SETSIGINFO)) || \
440 (defined(PT_GETSIGINFO) && defined(PT_SETSIGINFO))
441 int ptrace_getsiginfo
= PTRACE_GETSIGINFO
;
442 int ptrace_setsiginfo
= PTRACE_SETSIGINFO
;
444 int ptrace_getsiginfo
= -1;
445 int ptrace_setsiginfo
= -1;
446 #endif // PTRACE_GETSIGINFO/PTRACE_SETSIGINFO
447 #if defined(PTRACE_GETREGSET) && defined(PTRACE_SETREGSET)
448 int ptrace_getregset
= PTRACE_GETREGSET
;
449 int ptrace_setregset
= PTRACE_SETREGSET
;
451 int ptrace_getregset
= -1;
452 int ptrace_setregset
= -1;
453 #endif // PTRACE_GETREGSET/PTRACE_SETREGSET
456 unsigned path_max
= PATH_MAX
;
459 unsigned struct_ifreq_sz
= sizeof(struct ifreq
);
460 unsigned struct_termios_sz
= sizeof(struct termios
);
461 unsigned struct_winsize_sz
= sizeof(struct winsize
);
464 unsigned struct_arpreq_sz
= sizeof(struct arpreq
);
465 unsigned struct_cdrom_msf_sz
= sizeof(struct cdrom_msf
);
466 unsigned struct_cdrom_multisession_sz
= sizeof(struct cdrom_multisession
);
467 unsigned struct_cdrom_read_audio_sz
= sizeof(struct cdrom_read_audio
);
468 unsigned struct_cdrom_subchnl_sz
= sizeof(struct cdrom_subchnl
);
469 unsigned struct_cdrom_ti_sz
= sizeof(struct cdrom_ti
);
470 unsigned struct_cdrom_tocentry_sz
= sizeof(struct cdrom_tocentry
);
471 unsigned struct_cdrom_tochdr_sz
= sizeof(struct cdrom_tochdr
);
472 unsigned struct_cdrom_volctrl_sz
= sizeof(struct cdrom_volctrl
);
473 unsigned struct_ff_effect_sz
= sizeof(struct ff_effect
);
474 unsigned struct_floppy_drive_params_sz
= sizeof(struct floppy_drive_params
);
475 unsigned struct_floppy_drive_struct_sz
= sizeof(struct floppy_drive_struct
);
476 unsigned struct_floppy_fdc_state_sz
= sizeof(struct floppy_fdc_state
);
477 unsigned struct_floppy_max_errors_sz
= sizeof(struct floppy_max_errors
);
478 unsigned struct_floppy_raw_cmd_sz
= sizeof(struct floppy_raw_cmd
);
479 unsigned struct_floppy_struct_sz
= sizeof(struct floppy_struct
);
480 unsigned struct_floppy_write_errors_sz
= sizeof(struct floppy_write_errors
);
481 unsigned struct_format_descr_sz
= sizeof(struct format_descr
);
482 unsigned struct_hd_driveid_sz
= sizeof(struct hd_driveid
);
483 unsigned struct_hd_geometry_sz
= sizeof(struct hd_geometry
);
484 unsigned struct_input_absinfo_sz
= sizeof(struct input_absinfo
);
485 unsigned struct_input_id_sz
= sizeof(struct input_id
);
486 unsigned struct_mtpos_sz
= sizeof(struct mtpos
);
487 unsigned struct_rtentry_sz
= sizeof(struct rtentry
);
488 #if SANITIZER_GLIBC || SANITIZER_ANDROID
489 unsigned struct_termio_sz
= sizeof(struct termio
);
491 unsigned struct_vt_consize_sz
= sizeof(struct vt_consize
);
492 unsigned struct_vt_sizes_sz
= sizeof(struct vt_sizes
);
493 unsigned struct_vt_stat_sz
= sizeof(struct vt_stat
);
494 #endif // SANITIZER_LINUX
497 #if SOUND_VERSION >= 0x040000
498 unsigned struct_copr_buffer_sz
= 0;
499 unsigned struct_copr_debug_buf_sz
= 0;
500 unsigned struct_copr_msg_sz
= 0;
502 unsigned struct_copr_buffer_sz
= sizeof(struct copr_buffer
);
503 unsigned struct_copr_debug_buf_sz
= sizeof(struct copr_debug_buf
);
504 unsigned struct_copr_msg_sz
= sizeof(struct copr_msg
);
506 unsigned struct_midi_info_sz
= sizeof(struct midi_info
);
507 unsigned struct_mtget_sz
= sizeof(struct mtget
);
508 unsigned struct_mtop_sz
= sizeof(struct mtop
);
509 unsigned struct_sbi_instrument_sz
= sizeof(struct sbi_instrument
);
510 unsigned struct_seq_event_rec_sz
= sizeof(struct seq_event_rec
);
511 unsigned struct_synth_info_sz
= sizeof(struct synth_info
);
512 unsigned struct_vt_mode_sz
= sizeof(struct vt_mode
);
513 #endif // SANITIZER_LINUX
516 unsigned struct_ax25_parms_struct_sz
= sizeof(struct ax25_parms_struct
);
517 #if EV_VERSION > (0x010000)
518 unsigned struct_input_keymap_entry_sz
= sizeof(struct input_keymap_entry
);
520 unsigned struct_input_keymap_entry_sz
= 0;
522 unsigned struct_ipx_config_data_sz
= sizeof(struct ipx_config_data
);
523 unsigned struct_kbdiacrs_sz
= sizeof(struct kbdiacrs
);
524 unsigned struct_kbentry_sz
= sizeof(struct kbentry
);
525 unsigned struct_kbkeycode_sz
= sizeof(struct kbkeycode
);
526 unsigned struct_kbsentry_sz
= sizeof(struct kbsentry
);
527 unsigned struct_mtconfiginfo_sz
= sizeof(struct mtconfiginfo
);
528 unsigned struct_nr_parms_struct_sz
= sizeof(struct nr_parms_struct
);
529 unsigned struct_scc_modem_sz
= sizeof(struct scc_modem
);
530 unsigned struct_scc_stat_sz
= sizeof(struct scc_stat
);
531 unsigned struct_serial_multiport_struct_sz
532 = sizeof(struct serial_multiport_struct
);
533 unsigned struct_serial_struct_sz
= sizeof(struct serial_struct
);
534 unsigned struct_sockaddr_ax25_sz
= sizeof(struct sockaddr_ax25
);
535 unsigned struct_unimapdesc_sz
= sizeof(struct unimapdesc
);
536 unsigned struct_unimapinit_sz
= sizeof(struct unimapinit
);
538 unsigned struct_audio_buf_info_sz
= sizeof(struct audio_buf_info
);
539 unsigned struct_ppp_stats_sz
= sizeof(struct ppp_stats
);
540 unsigned struct_sock_fprog_sz
= sizeof(struct sock_fprog
);
541 # endif // SANITIZER_GLIBC
543 # if !SANITIZER_ANDROID && !SANITIZER_APPLE
544 unsigned struct_sioc_sg_req_sz
= sizeof(struct sioc_sg_req
);
545 unsigned struct_sioc_vif_req_sz
= sizeof(struct sioc_vif_req
);
548 const unsigned long __sanitizer_bufsiz
= BUFSIZ
;
550 const unsigned IOCTL_NOT_PRESENT
= 0;
552 unsigned IOCTL_FIOASYNC
= FIOASYNC
;
553 unsigned IOCTL_FIOCLEX
= FIOCLEX
;
554 unsigned IOCTL_FIOGETOWN
= FIOGETOWN
;
555 unsigned IOCTL_FIONBIO
= FIONBIO
;
556 unsigned IOCTL_FIONCLEX
= FIONCLEX
;
557 unsigned IOCTL_FIOSETOWN
= FIOSETOWN
;
558 unsigned IOCTL_SIOCADDMULTI
= SIOCADDMULTI
;
559 unsigned IOCTL_SIOCATMARK
= SIOCATMARK
;
560 unsigned IOCTL_SIOCDELMULTI
= SIOCDELMULTI
;
561 unsigned IOCTL_SIOCGIFADDR
= SIOCGIFADDR
;
562 unsigned IOCTL_SIOCGIFBRDADDR
= SIOCGIFBRDADDR
;
563 unsigned IOCTL_SIOCGIFCONF
= SIOCGIFCONF
;
564 unsigned IOCTL_SIOCGIFDSTADDR
= SIOCGIFDSTADDR
;
565 unsigned IOCTL_SIOCGIFFLAGS
= SIOCGIFFLAGS
;
566 unsigned IOCTL_SIOCGIFMETRIC
= SIOCGIFMETRIC
;
567 unsigned IOCTL_SIOCGIFMTU
= SIOCGIFMTU
;
568 unsigned IOCTL_SIOCGIFNETMASK
= SIOCGIFNETMASK
;
569 unsigned IOCTL_SIOCGPGRP
= SIOCGPGRP
;
570 unsigned IOCTL_SIOCSIFADDR
= SIOCSIFADDR
;
571 unsigned IOCTL_SIOCSIFBRDADDR
= SIOCSIFBRDADDR
;
572 unsigned IOCTL_SIOCSIFDSTADDR
= SIOCSIFDSTADDR
;
573 unsigned IOCTL_SIOCSIFFLAGS
= SIOCSIFFLAGS
;
574 unsigned IOCTL_SIOCSIFMETRIC
= SIOCSIFMETRIC
;
575 unsigned IOCTL_SIOCSIFMTU
= SIOCSIFMTU
;
576 unsigned IOCTL_SIOCSIFNETMASK
= SIOCSIFNETMASK
;
577 unsigned IOCTL_SIOCSPGRP
= SIOCSPGRP
;
578 unsigned IOCTL_TIOCCONS
= TIOCCONS
;
579 unsigned IOCTL_TIOCEXCL
= TIOCEXCL
;
580 unsigned IOCTL_TIOCGETD
= TIOCGETD
;
581 unsigned IOCTL_TIOCGPGRP
= TIOCGPGRP
;
582 unsigned IOCTL_TIOCGWINSZ
= TIOCGWINSZ
;
583 unsigned IOCTL_TIOCMBIC
= TIOCMBIC
;
584 unsigned IOCTL_TIOCMBIS
= TIOCMBIS
;
585 unsigned IOCTL_TIOCMGET
= TIOCMGET
;
586 unsigned IOCTL_TIOCMSET
= TIOCMSET
;
587 unsigned IOCTL_TIOCNOTTY
= TIOCNOTTY
;
588 unsigned IOCTL_TIOCNXCL
= TIOCNXCL
;
589 unsigned IOCTL_TIOCOUTQ
= TIOCOUTQ
;
590 unsigned IOCTL_TIOCPKT
= TIOCPKT
;
591 unsigned IOCTL_TIOCSCTTY
= TIOCSCTTY
;
592 unsigned IOCTL_TIOCSETD
= TIOCSETD
;
593 unsigned IOCTL_TIOCSPGRP
= TIOCSPGRP
;
594 unsigned IOCTL_TIOCSTI
= TIOCSTI
;
595 unsigned IOCTL_TIOCSWINSZ
= TIOCSWINSZ
;
596 #if SANITIZER_LINUX && !SANITIZER_ANDROID
597 unsigned IOCTL_SIOCGETSGCNT
= SIOCGETSGCNT
;
598 unsigned IOCTL_SIOCGETVIFCNT
= SIOCGETVIFCNT
;
602 unsigned IOCTL_EVIOCGABS
= EVIOCGABS(0);
603 unsigned IOCTL_EVIOCGBIT
= EVIOCGBIT(0, 0);
604 unsigned IOCTL_EVIOCGEFFECTS
= EVIOCGEFFECTS
;
605 unsigned IOCTL_EVIOCGID
= EVIOCGID
;
606 unsigned IOCTL_EVIOCGKEY
= EVIOCGKEY(0);
607 unsigned IOCTL_EVIOCGKEYCODE
= EVIOCGKEYCODE
;
608 unsigned IOCTL_EVIOCGLED
= EVIOCGLED(0);
609 unsigned IOCTL_EVIOCGNAME
= EVIOCGNAME(0);
610 unsigned IOCTL_EVIOCGPHYS
= EVIOCGPHYS(0);
611 unsigned IOCTL_EVIOCGRAB
= EVIOCGRAB
;
612 unsigned IOCTL_EVIOCGREP
= EVIOCGREP
;
613 unsigned IOCTL_EVIOCGSND
= EVIOCGSND(0);
614 unsigned IOCTL_EVIOCGSW
= EVIOCGSW(0);
615 unsigned IOCTL_EVIOCGUNIQ
= EVIOCGUNIQ(0);
616 unsigned IOCTL_EVIOCGVERSION
= EVIOCGVERSION
;
617 unsigned IOCTL_EVIOCRMFF
= EVIOCRMFF
;
618 unsigned IOCTL_EVIOCSABS
= EVIOCSABS(0);
619 unsigned IOCTL_EVIOCSFF
= EVIOCSFF
;
620 unsigned IOCTL_EVIOCSKEYCODE
= EVIOCSKEYCODE
;
621 unsigned IOCTL_EVIOCSREP
= EVIOCSREP
;
622 unsigned IOCTL_BLKFLSBUF
= BLKFLSBUF
;
623 unsigned IOCTL_BLKGETSIZE
= BLKGETSIZE
;
624 unsigned IOCTL_BLKRAGET
= BLKRAGET
;
625 unsigned IOCTL_BLKRASET
= BLKRASET
;
626 unsigned IOCTL_BLKROGET
= BLKROGET
;
627 unsigned IOCTL_BLKROSET
= BLKROSET
;
628 unsigned IOCTL_BLKRRPART
= BLKRRPART
;
629 unsigned IOCTL_BLKFRASET
= BLKFRASET
;
630 unsigned IOCTL_BLKFRAGET
= BLKFRAGET
;
631 unsigned IOCTL_BLKSECTSET
= BLKSECTSET
;
632 unsigned IOCTL_BLKSECTGET
= BLKSECTGET
;
633 unsigned IOCTL_BLKSSZGET
= BLKSSZGET
;
634 unsigned IOCTL_BLKBSZGET
= BLKBSZGET
;
635 unsigned IOCTL_BLKBSZSET
= BLKBSZSET
;
636 unsigned IOCTL_BLKGETSIZE64
= BLKGETSIZE64
;
637 unsigned IOCTL_CDROMAUDIOBUFSIZ
= CDROMAUDIOBUFSIZ
;
638 unsigned IOCTL_CDROMEJECT
= CDROMEJECT
;
639 unsigned IOCTL_CDROMEJECT_SW
= CDROMEJECT_SW
;
640 unsigned IOCTL_CDROMMULTISESSION
= CDROMMULTISESSION
;
641 unsigned IOCTL_CDROMPAUSE
= CDROMPAUSE
;
642 unsigned IOCTL_CDROMPLAYMSF
= CDROMPLAYMSF
;
643 unsigned IOCTL_CDROMPLAYTRKIND
= CDROMPLAYTRKIND
;
644 unsigned IOCTL_CDROMREADAUDIO
= CDROMREADAUDIO
;
645 unsigned IOCTL_CDROMREADCOOKED
= CDROMREADCOOKED
;
646 unsigned IOCTL_CDROMREADMODE1
= CDROMREADMODE1
;
647 unsigned IOCTL_CDROMREADMODE2
= CDROMREADMODE2
;
648 unsigned IOCTL_CDROMREADRAW
= CDROMREADRAW
;
649 unsigned IOCTL_CDROMREADTOCENTRY
= CDROMREADTOCENTRY
;
650 unsigned IOCTL_CDROMREADTOCHDR
= CDROMREADTOCHDR
;
651 unsigned IOCTL_CDROMRESET
= CDROMRESET
;
652 unsigned IOCTL_CDROMRESUME
= CDROMRESUME
;
653 unsigned IOCTL_CDROMSEEK
= CDROMSEEK
;
654 unsigned IOCTL_CDROMSTART
= CDROMSTART
;
655 unsigned IOCTL_CDROMSTOP
= CDROMSTOP
;
656 unsigned IOCTL_CDROMSUBCHNL
= CDROMSUBCHNL
;
657 unsigned IOCTL_CDROMVOLCTRL
= CDROMVOLCTRL
;
658 unsigned IOCTL_CDROMVOLREAD
= CDROMVOLREAD
;
659 unsigned IOCTL_CDROM_GET_UPC
= CDROM_GET_UPC
;
660 unsigned IOCTL_FDCLRPRM
= FDCLRPRM
;
661 unsigned IOCTL_FDDEFPRM
= FDDEFPRM
;
662 unsigned IOCTL_FDFLUSH
= FDFLUSH
;
663 unsigned IOCTL_FDFMTBEG
= FDFMTBEG
;
664 unsigned IOCTL_FDFMTEND
= FDFMTEND
;
665 unsigned IOCTL_FDFMTTRK
= FDFMTTRK
;
666 unsigned IOCTL_FDGETDRVPRM
= FDGETDRVPRM
;
667 unsigned IOCTL_FDGETDRVSTAT
= FDGETDRVSTAT
;
668 unsigned IOCTL_FDGETDRVTYP
= FDGETDRVTYP
;
669 unsigned IOCTL_FDGETFDCSTAT
= FDGETFDCSTAT
;
670 unsigned IOCTL_FDGETMAXERRS
= FDGETMAXERRS
;
671 unsigned IOCTL_FDGETPRM
= FDGETPRM
;
672 unsigned IOCTL_FDMSGOFF
= FDMSGOFF
;
673 unsigned IOCTL_FDMSGON
= FDMSGON
;
674 unsigned IOCTL_FDPOLLDRVSTAT
= FDPOLLDRVSTAT
;
675 unsigned IOCTL_FDRAWCMD
= FDRAWCMD
;
676 unsigned IOCTL_FDRESET
= FDRESET
;
677 unsigned IOCTL_FDSETDRVPRM
= FDSETDRVPRM
;
678 unsigned IOCTL_FDSETEMSGTRESH
= FDSETEMSGTRESH
;
679 unsigned IOCTL_FDSETMAXERRS
= FDSETMAXERRS
;
680 unsigned IOCTL_FDSETPRM
= FDSETPRM
;
681 unsigned IOCTL_FDTWADDLE
= FDTWADDLE
;
682 unsigned IOCTL_FDWERRORCLR
= FDWERRORCLR
;
683 unsigned IOCTL_FDWERRORGET
= FDWERRORGET
;
684 unsigned IOCTL_HDIO_DRIVE_CMD
= HDIO_DRIVE_CMD
;
685 unsigned IOCTL_HDIO_GETGEO
= HDIO_GETGEO
;
686 unsigned IOCTL_HDIO_GET_32BIT
= HDIO_GET_32BIT
;
687 unsigned IOCTL_HDIO_GET_DMA
= HDIO_GET_DMA
;
688 unsigned IOCTL_HDIO_GET_IDENTITY
= HDIO_GET_IDENTITY
;
689 unsigned IOCTL_HDIO_GET_KEEPSETTINGS
= HDIO_GET_KEEPSETTINGS
;
690 unsigned IOCTL_HDIO_GET_MULTCOUNT
= HDIO_GET_MULTCOUNT
;
691 unsigned IOCTL_HDIO_GET_NOWERR
= HDIO_GET_NOWERR
;
692 unsigned IOCTL_HDIO_GET_UNMASKINTR
= HDIO_GET_UNMASKINTR
;
693 unsigned IOCTL_HDIO_SET_32BIT
= HDIO_SET_32BIT
;
694 unsigned IOCTL_HDIO_SET_DMA
= HDIO_SET_DMA
;
695 unsigned IOCTL_HDIO_SET_KEEPSETTINGS
= HDIO_SET_KEEPSETTINGS
;
696 unsigned IOCTL_HDIO_SET_MULTCOUNT
= HDIO_SET_MULTCOUNT
;
697 unsigned IOCTL_HDIO_SET_NOWERR
= HDIO_SET_NOWERR
;
698 unsigned IOCTL_HDIO_SET_UNMASKINTR
= HDIO_SET_UNMASKINTR
;
699 unsigned IOCTL_MTIOCPOS
= MTIOCPOS
;
700 unsigned IOCTL_PPPIOCGASYNCMAP
= PPPIOCGASYNCMAP
;
701 unsigned IOCTL_PPPIOCGDEBUG
= PPPIOCGDEBUG
;
702 unsigned IOCTL_PPPIOCGFLAGS
= PPPIOCGFLAGS
;
703 unsigned IOCTL_PPPIOCGUNIT
= PPPIOCGUNIT
;
704 unsigned IOCTL_PPPIOCGXASYNCMAP
= PPPIOCGXASYNCMAP
;
705 unsigned IOCTL_PPPIOCSASYNCMAP
= PPPIOCSASYNCMAP
;
706 unsigned IOCTL_PPPIOCSDEBUG
= PPPIOCSDEBUG
;
707 unsigned IOCTL_PPPIOCSFLAGS
= PPPIOCSFLAGS
;
708 unsigned IOCTL_PPPIOCSMAXCID
= PPPIOCSMAXCID
;
709 unsigned IOCTL_PPPIOCSMRU
= PPPIOCSMRU
;
710 unsigned IOCTL_PPPIOCSXASYNCMAP
= PPPIOCSXASYNCMAP
;
711 unsigned IOCTL_SIOCADDRT
= SIOCADDRT
;
712 unsigned IOCTL_SIOCDARP
= SIOCDARP
;
713 unsigned IOCTL_SIOCDELRT
= SIOCDELRT
;
714 unsigned IOCTL_SIOCDRARP
= SIOCDRARP
;
715 unsigned IOCTL_SIOCGARP
= SIOCGARP
;
716 unsigned IOCTL_SIOCGIFENCAP
= SIOCGIFENCAP
;
717 unsigned IOCTL_SIOCGIFHWADDR
= SIOCGIFHWADDR
;
718 unsigned IOCTL_SIOCGIFMAP
= SIOCGIFMAP
;
719 unsigned IOCTL_SIOCGIFMEM
= SIOCGIFMEM
;
720 unsigned IOCTL_SIOCGIFNAME
= SIOCGIFNAME
;
721 unsigned IOCTL_SIOCGIFSLAVE
= SIOCGIFSLAVE
;
722 unsigned IOCTL_SIOCGRARP
= SIOCGRARP
;
723 unsigned IOCTL_SIOCGSTAMP
= SIOCGSTAMP
;
724 unsigned IOCTL_SIOCSARP
= SIOCSARP
;
725 unsigned IOCTL_SIOCSIFENCAP
= SIOCSIFENCAP
;
726 unsigned IOCTL_SIOCSIFHWADDR
= SIOCSIFHWADDR
;
727 unsigned IOCTL_SIOCSIFLINK
= SIOCSIFLINK
;
728 unsigned IOCTL_SIOCSIFMAP
= SIOCSIFMAP
;
729 unsigned IOCTL_SIOCSIFMEM
= SIOCSIFMEM
;
730 unsigned IOCTL_SIOCSIFSLAVE
= SIOCSIFSLAVE
;
731 unsigned IOCTL_SIOCSRARP
= SIOCSRARP
;
732 # if SOUND_VERSION >= 0x040000
733 unsigned IOCTL_SNDCTL_COPR_HALT
= IOCTL_NOT_PRESENT
;
734 unsigned IOCTL_SNDCTL_COPR_LOAD
= IOCTL_NOT_PRESENT
;
735 unsigned IOCTL_SNDCTL_COPR_RCODE
= IOCTL_NOT_PRESENT
;
736 unsigned IOCTL_SNDCTL_COPR_RCVMSG
= IOCTL_NOT_PRESENT
;
737 unsigned IOCTL_SNDCTL_COPR_RDATA
= IOCTL_NOT_PRESENT
;
738 unsigned IOCTL_SNDCTL_COPR_RESET
= IOCTL_NOT_PRESENT
;
739 unsigned IOCTL_SNDCTL_COPR_RUN
= IOCTL_NOT_PRESENT
;
740 unsigned IOCTL_SNDCTL_COPR_SENDMSG
= IOCTL_NOT_PRESENT
;
741 unsigned IOCTL_SNDCTL_COPR_WCODE
= IOCTL_NOT_PRESENT
;
742 unsigned IOCTL_SNDCTL_COPR_WDATA
= IOCTL_NOT_PRESENT
;
743 unsigned IOCTL_SOUND_PCM_READ_BITS
= IOCTL_NOT_PRESENT
;
744 unsigned IOCTL_SOUND_PCM_READ_CHANNELS
= IOCTL_NOT_PRESENT
;
745 unsigned IOCTL_SOUND_PCM_READ_FILTER
= IOCTL_NOT_PRESENT
;
746 unsigned IOCTL_SOUND_PCM_READ_RATE
= IOCTL_NOT_PRESENT
;
747 unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS
= IOCTL_NOT_PRESENT
;
748 unsigned IOCTL_SOUND_PCM_WRITE_FILTER
= IOCTL_NOT_PRESENT
;
749 # else // SOUND_VERSION
750 unsigned IOCTL_SNDCTL_COPR_HALT
= SNDCTL_COPR_HALT
;
751 unsigned IOCTL_SNDCTL_COPR_LOAD
= SNDCTL_COPR_LOAD
;
752 unsigned IOCTL_SNDCTL_COPR_RCODE
= SNDCTL_COPR_RCODE
;
753 unsigned IOCTL_SNDCTL_COPR_RCVMSG
= SNDCTL_COPR_RCVMSG
;
754 unsigned IOCTL_SNDCTL_COPR_RDATA
= SNDCTL_COPR_RDATA
;
755 unsigned IOCTL_SNDCTL_COPR_RESET
= SNDCTL_COPR_RESET
;
756 unsigned IOCTL_SNDCTL_COPR_RUN
= SNDCTL_COPR_RUN
;
757 unsigned IOCTL_SNDCTL_COPR_SENDMSG
= SNDCTL_COPR_SENDMSG
;
758 unsigned IOCTL_SNDCTL_COPR_WCODE
= SNDCTL_COPR_WCODE
;
759 unsigned IOCTL_SNDCTL_COPR_WDATA
= SNDCTL_COPR_WDATA
;
760 unsigned IOCTL_SOUND_PCM_READ_BITS
= SOUND_PCM_READ_BITS
;
761 unsigned IOCTL_SOUND_PCM_READ_CHANNELS
= SOUND_PCM_READ_CHANNELS
;
762 unsigned IOCTL_SOUND_PCM_READ_FILTER
= SOUND_PCM_READ_FILTER
;
763 unsigned IOCTL_SOUND_PCM_READ_RATE
= SOUND_PCM_READ_RATE
;
764 unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS
= SOUND_PCM_WRITE_CHANNELS
;
765 unsigned IOCTL_SOUND_PCM_WRITE_FILTER
= SOUND_PCM_WRITE_FILTER
;
766 #endif // SOUND_VERSION
767 unsigned IOCTL_TCFLSH
= TCFLSH
;
768 unsigned IOCTL_TCGETA
= TCGETA
;
769 unsigned IOCTL_TCGETS
= TCGETS
;
770 unsigned IOCTL_TCSBRK
= TCSBRK
;
771 unsigned IOCTL_TCSBRKP
= TCSBRKP
;
772 unsigned IOCTL_TCSETA
= TCSETA
;
773 unsigned IOCTL_TCSETAF
= TCSETAF
;
774 unsigned IOCTL_TCSETAW
= TCSETAW
;
775 unsigned IOCTL_TCSETS
= TCSETS
;
776 unsigned IOCTL_TCSETSF
= TCSETSF
;
777 unsigned IOCTL_TCSETSW
= TCSETSW
;
778 unsigned IOCTL_TCXONC
= TCXONC
;
779 unsigned IOCTL_TIOCGLCKTRMIOS
= TIOCGLCKTRMIOS
;
780 unsigned IOCTL_TIOCGSOFTCAR
= TIOCGSOFTCAR
;
781 unsigned IOCTL_TIOCINQ
= TIOCINQ
;
782 unsigned IOCTL_TIOCLINUX
= TIOCLINUX
;
783 unsigned IOCTL_TIOCSERCONFIG
= TIOCSERCONFIG
;
784 unsigned IOCTL_TIOCSERGETLSR
= TIOCSERGETLSR
;
785 unsigned IOCTL_TIOCSERGWILD
= TIOCSERGWILD
;
786 unsigned IOCTL_TIOCSERSWILD
= TIOCSERSWILD
;
787 unsigned IOCTL_TIOCSLCKTRMIOS
= TIOCSLCKTRMIOS
;
788 unsigned IOCTL_TIOCSSOFTCAR
= TIOCSSOFTCAR
;
789 unsigned IOCTL_VT_DISALLOCATE
= VT_DISALLOCATE
;
790 unsigned IOCTL_VT_GETSTATE
= VT_GETSTATE
;
791 unsigned IOCTL_VT_RESIZE
= VT_RESIZE
;
792 unsigned IOCTL_VT_RESIZEX
= VT_RESIZEX
;
793 unsigned IOCTL_VT_SENDSIG
= VT_SENDSIG
;
794 unsigned IOCTL_MTIOCGET
= MTIOCGET
;
795 unsigned IOCTL_MTIOCTOP
= MTIOCTOP
;
796 unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE
= SNDCTL_DSP_GETBLKSIZE
;
797 unsigned IOCTL_SNDCTL_DSP_GETFMTS
= SNDCTL_DSP_GETFMTS
;
798 unsigned IOCTL_SNDCTL_DSP_NONBLOCK
= SNDCTL_DSP_NONBLOCK
;
799 unsigned IOCTL_SNDCTL_DSP_POST
= SNDCTL_DSP_POST
;
800 unsigned IOCTL_SNDCTL_DSP_RESET
= SNDCTL_DSP_RESET
;
801 unsigned IOCTL_SNDCTL_DSP_SETFMT
= SNDCTL_DSP_SETFMT
;
802 unsigned IOCTL_SNDCTL_DSP_SETFRAGMENT
= SNDCTL_DSP_SETFRAGMENT
;
803 unsigned IOCTL_SNDCTL_DSP_SPEED
= SNDCTL_DSP_SPEED
;
804 unsigned IOCTL_SNDCTL_DSP_STEREO
= SNDCTL_DSP_STEREO
;
805 unsigned IOCTL_SNDCTL_DSP_SUBDIVIDE
= SNDCTL_DSP_SUBDIVIDE
;
806 unsigned IOCTL_SNDCTL_DSP_SYNC
= SNDCTL_DSP_SYNC
;
807 unsigned IOCTL_SNDCTL_FM_4OP_ENABLE
= SNDCTL_FM_4OP_ENABLE
;
808 unsigned IOCTL_SNDCTL_FM_LOAD_INSTR
= SNDCTL_FM_LOAD_INSTR
;
809 unsigned IOCTL_SNDCTL_MIDI_INFO
= SNDCTL_MIDI_INFO
;
810 unsigned IOCTL_SNDCTL_MIDI_PRETIME
= SNDCTL_MIDI_PRETIME
;
811 unsigned IOCTL_SNDCTL_SEQ_CTRLRATE
= SNDCTL_SEQ_CTRLRATE
;
812 unsigned IOCTL_SNDCTL_SEQ_GETINCOUNT
= SNDCTL_SEQ_GETINCOUNT
;
813 unsigned IOCTL_SNDCTL_SEQ_GETOUTCOUNT
= SNDCTL_SEQ_GETOUTCOUNT
;
814 unsigned IOCTL_SNDCTL_SEQ_NRMIDIS
= SNDCTL_SEQ_NRMIDIS
;
815 unsigned IOCTL_SNDCTL_SEQ_NRSYNTHS
= SNDCTL_SEQ_NRSYNTHS
;
816 unsigned IOCTL_SNDCTL_SEQ_OUTOFBAND
= SNDCTL_SEQ_OUTOFBAND
;
817 unsigned IOCTL_SNDCTL_SEQ_PANIC
= SNDCTL_SEQ_PANIC
;
818 unsigned IOCTL_SNDCTL_SEQ_PERCMODE
= SNDCTL_SEQ_PERCMODE
;
819 unsigned IOCTL_SNDCTL_SEQ_RESET
= SNDCTL_SEQ_RESET
;
820 unsigned IOCTL_SNDCTL_SEQ_RESETSAMPLES
= SNDCTL_SEQ_RESETSAMPLES
;
821 unsigned IOCTL_SNDCTL_SEQ_SYNC
= SNDCTL_SEQ_SYNC
;
822 unsigned IOCTL_SNDCTL_SEQ_TESTMIDI
= SNDCTL_SEQ_TESTMIDI
;
823 unsigned IOCTL_SNDCTL_SEQ_THRESHOLD
= SNDCTL_SEQ_THRESHOLD
;
824 unsigned IOCTL_SNDCTL_SYNTH_INFO
= SNDCTL_SYNTH_INFO
;
825 unsigned IOCTL_SNDCTL_SYNTH_MEMAVL
= SNDCTL_SYNTH_MEMAVL
;
826 unsigned IOCTL_SNDCTL_TMR_CONTINUE
= SNDCTL_TMR_CONTINUE
;
827 unsigned IOCTL_SNDCTL_TMR_METRONOME
= SNDCTL_TMR_METRONOME
;
828 unsigned IOCTL_SNDCTL_TMR_SELECT
= SNDCTL_TMR_SELECT
;
829 unsigned IOCTL_SNDCTL_TMR_SOURCE
= SNDCTL_TMR_SOURCE
;
830 unsigned IOCTL_SNDCTL_TMR_START
= SNDCTL_TMR_START
;
831 unsigned IOCTL_SNDCTL_TMR_STOP
= SNDCTL_TMR_STOP
;
832 unsigned IOCTL_SNDCTL_TMR_TEMPO
= SNDCTL_TMR_TEMPO
;
833 unsigned IOCTL_SNDCTL_TMR_TIMEBASE
= SNDCTL_TMR_TIMEBASE
;
834 unsigned IOCTL_SOUND_MIXER_READ_ALTPCM
= SOUND_MIXER_READ_ALTPCM
;
835 unsigned IOCTL_SOUND_MIXER_READ_BASS
= SOUND_MIXER_READ_BASS
;
836 unsigned IOCTL_SOUND_MIXER_READ_CAPS
= SOUND_MIXER_READ_CAPS
;
837 unsigned IOCTL_SOUND_MIXER_READ_CD
= SOUND_MIXER_READ_CD
;
838 unsigned IOCTL_SOUND_MIXER_READ_DEVMASK
= SOUND_MIXER_READ_DEVMASK
;
839 unsigned IOCTL_SOUND_MIXER_READ_ENHANCE
= SOUND_MIXER_READ_ENHANCE
;
840 unsigned IOCTL_SOUND_MIXER_READ_IGAIN
= SOUND_MIXER_READ_IGAIN
;
841 unsigned IOCTL_SOUND_MIXER_READ_IMIX
= SOUND_MIXER_READ_IMIX
;
842 unsigned IOCTL_SOUND_MIXER_READ_LINE
= SOUND_MIXER_READ_LINE
;
843 unsigned IOCTL_SOUND_MIXER_READ_LINE1
= SOUND_MIXER_READ_LINE1
;
844 unsigned IOCTL_SOUND_MIXER_READ_LINE2
= SOUND_MIXER_READ_LINE2
;
845 unsigned IOCTL_SOUND_MIXER_READ_LINE3
= SOUND_MIXER_READ_LINE3
;
846 unsigned IOCTL_SOUND_MIXER_READ_LOUD
= SOUND_MIXER_READ_LOUD
;
847 unsigned IOCTL_SOUND_MIXER_READ_MIC
= SOUND_MIXER_READ_MIC
;
848 unsigned IOCTL_SOUND_MIXER_READ_MUTE
= SOUND_MIXER_READ_MUTE
;
849 unsigned IOCTL_SOUND_MIXER_READ_OGAIN
= SOUND_MIXER_READ_OGAIN
;
850 unsigned IOCTL_SOUND_MIXER_READ_PCM
= SOUND_MIXER_READ_PCM
;
851 unsigned IOCTL_SOUND_MIXER_READ_RECLEV
= SOUND_MIXER_READ_RECLEV
;
852 unsigned IOCTL_SOUND_MIXER_READ_RECMASK
= SOUND_MIXER_READ_RECMASK
;
853 unsigned IOCTL_SOUND_MIXER_READ_RECSRC
= SOUND_MIXER_READ_RECSRC
;
854 unsigned IOCTL_SOUND_MIXER_READ_SPEAKER
= SOUND_MIXER_READ_SPEAKER
;
855 unsigned IOCTL_SOUND_MIXER_READ_STEREODEVS
= SOUND_MIXER_READ_STEREODEVS
;
856 unsigned IOCTL_SOUND_MIXER_READ_SYNTH
= SOUND_MIXER_READ_SYNTH
;
857 unsigned IOCTL_SOUND_MIXER_READ_TREBLE
= SOUND_MIXER_READ_TREBLE
;
858 unsigned IOCTL_SOUND_MIXER_READ_VOLUME
= SOUND_MIXER_READ_VOLUME
;
859 unsigned IOCTL_SOUND_MIXER_WRITE_ALTPCM
= SOUND_MIXER_WRITE_ALTPCM
;
860 unsigned IOCTL_SOUND_MIXER_WRITE_BASS
= SOUND_MIXER_WRITE_BASS
;
861 unsigned IOCTL_SOUND_MIXER_WRITE_CD
= SOUND_MIXER_WRITE_CD
;
862 unsigned IOCTL_SOUND_MIXER_WRITE_ENHANCE
= SOUND_MIXER_WRITE_ENHANCE
;
863 unsigned IOCTL_SOUND_MIXER_WRITE_IGAIN
= SOUND_MIXER_WRITE_IGAIN
;
864 unsigned IOCTL_SOUND_MIXER_WRITE_IMIX
= SOUND_MIXER_WRITE_IMIX
;
865 unsigned IOCTL_SOUND_MIXER_WRITE_LINE
= SOUND_MIXER_WRITE_LINE
;
866 unsigned IOCTL_SOUND_MIXER_WRITE_LINE1
= SOUND_MIXER_WRITE_LINE1
;
867 unsigned IOCTL_SOUND_MIXER_WRITE_LINE2
= SOUND_MIXER_WRITE_LINE2
;
868 unsigned IOCTL_SOUND_MIXER_WRITE_LINE3
= SOUND_MIXER_WRITE_LINE3
;
869 unsigned IOCTL_SOUND_MIXER_WRITE_LOUD
= SOUND_MIXER_WRITE_LOUD
;
870 unsigned IOCTL_SOUND_MIXER_WRITE_MIC
= SOUND_MIXER_WRITE_MIC
;
871 unsigned IOCTL_SOUND_MIXER_WRITE_MUTE
= SOUND_MIXER_WRITE_MUTE
;
872 unsigned IOCTL_SOUND_MIXER_WRITE_OGAIN
= SOUND_MIXER_WRITE_OGAIN
;
873 unsigned IOCTL_SOUND_MIXER_WRITE_PCM
= SOUND_MIXER_WRITE_PCM
;
874 unsigned IOCTL_SOUND_MIXER_WRITE_RECLEV
= SOUND_MIXER_WRITE_RECLEV
;
875 unsigned IOCTL_SOUND_MIXER_WRITE_RECSRC
= SOUND_MIXER_WRITE_RECSRC
;
876 unsigned IOCTL_SOUND_MIXER_WRITE_SPEAKER
= SOUND_MIXER_WRITE_SPEAKER
;
877 unsigned IOCTL_SOUND_MIXER_WRITE_SYNTH
= SOUND_MIXER_WRITE_SYNTH
;
878 unsigned IOCTL_SOUND_MIXER_WRITE_TREBLE
= SOUND_MIXER_WRITE_TREBLE
;
879 unsigned IOCTL_SOUND_MIXER_WRITE_VOLUME
= SOUND_MIXER_WRITE_VOLUME
;
880 unsigned IOCTL_VT_ACTIVATE
= VT_ACTIVATE
;
881 unsigned IOCTL_VT_GETMODE
= VT_GETMODE
;
882 unsigned IOCTL_VT_OPENQRY
= VT_OPENQRY
;
883 unsigned IOCTL_VT_RELDISP
= VT_RELDISP
;
884 unsigned IOCTL_VT_SETMODE
= VT_SETMODE
;
885 unsigned IOCTL_VT_WAITACTIVE
= VT_WAITACTIVE
;
886 #endif // SANITIZER_LINUX
888 #if SANITIZER_LINUX && !SANITIZER_ANDROID
889 unsigned IOCTL_EQL_EMANCIPATE
= EQL_EMANCIPATE
;
890 unsigned IOCTL_EQL_ENSLAVE
= EQL_ENSLAVE
;
891 unsigned IOCTL_EQL_GETMASTRCFG
= EQL_GETMASTRCFG
;
892 unsigned IOCTL_EQL_GETSLAVECFG
= EQL_GETSLAVECFG
;
893 unsigned IOCTL_EQL_SETMASTRCFG
= EQL_SETMASTRCFG
;
894 unsigned IOCTL_EQL_SETSLAVECFG
= EQL_SETSLAVECFG
;
895 #if EV_VERSION > (0x010000)
896 unsigned IOCTL_EVIOCGKEYCODE_V2
= EVIOCGKEYCODE_V2
;
897 unsigned IOCTL_EVIOCGPROP
= EVIOCGPROP(0);
898 unsigned IOCTL_EVIOCSKEYCODE_V2
= EVIOCSKEYCODE_V2
;
900 unsigned IOCTL_EVIOCGKEYCODE_V2
= IOCTL_NOT_PRESENT
;
901 unsigned IOCTL_EVIOCGPROP
= IOCTL_NOT_PRESENT
;
902 unsigned IOCTL_EVIOCSKEYCODE_V2
= IOCTL_NOT_PRESENT
;
904 unsigned IOCTL_FS_IOC_GETFLAGS
= _IOR('f', 1, long);
905 unsigned IOCTL_FS_IOC_GETVERSION
= _IOR('v', 1, long);
906 unsigned IOCTL_FS_IOC_SETFLAGS
= _IOW('f', 2, long);
907 unsigned IOCTL_FS_IOC_SETVERSION
= _IOW('v', 2, long);
908 unsigned IOCTL_GIO_CMAP
= GIO_CMAP
;
909 unsigned IOCTL_GIO_FONT
= GIO_FONT
;
910 unsigned IOCTL_GIO_UNIMAP
= GIO_UNIMAP
;
911 unsigned IOCTL_GIO_UNISCRNMAP
= GIO_UNISCRNMAP
;
912 unsigned IOCTL_KDADDIO
= KDADDIO
;
913 unsigned IOCTL_KDDELIO
= KDDELIO
;
914 unsigned IOCTL_KDGETKEYCODE
= KDGETKEYCODE
;
915 unsigned IOCTL_KDGKBDIACR
= KDGKBDIACR
;
916 unsigned IOCTL_KDGKBENT
= KDGKBENT
;
917 unsigned IOCTL_KDGKBLED
= KDGKBLED
;
918 unsigned IOCTL_KDGKBMETA
= KDGKBMETA
;
919 unsigned IOCTL_KDGKBSENT
= KDGKBSENT
;
920 unsigned IOCTL_KDMAPDISP
= KDMAPDISP
;
921 unsigned IOCTL_KDSETKEYCODE
= KDSETKEYCODE
;
922 unsigned IOCTL_KDSIGACCEPT
= KDSIGACCEPT
;
923 unsigned IOCTL_KDSKBDIACR
= KDSKBDIACR
;
924 unsigned IOCTL_KDSKBENT
= KDSKBENT
;
925 unsigned IOCTL_KDSKBLED
= KDSKBLED
;
926 unsigned IOCTL_KDSKBMETA
= KDSKBMETA
;
927 unsigned IOCTL_KDSKBSENT
= KDSKBSENT
;
928 unsigned IOCTL_KDUNMAPDISP
= KDUNMAPDISP
;
929 unsigned IOCTL_LPABORT
= LPABORT
;
930 unsigned IOCTL_LPABORTOPEN
= LPABORTOPEN
;
931 unsigned IOCTL_LPCAREFUL
= LPCAREFUL
;
932 unsigned IOCTL_LPCHAR
= LPCHAR
;
933 unsigned IOCTL_LPGETIRQ
= LPGETIRQ
;
934 unsigned IOCTL_LPGETSTATUS
= LPGETSTATUS
;
935 unsigned IOCTL_LPRESET
= LPRESET
;
936 unsigned IOCTL_LPSETIRQ
= LPSETIRQ
;
937 unsigned IOCTL_LPTIME
= LPTIME
;
938 unsigned IOCTL_LPWAIT
= LPWAIT
;
939 unsigned IOCTL_MTIOCGETCONFIG
= MTIOCGETCONFIG
;
940 unsigned IOCTL_MTIOCSETCONFIG
= MTIOCSETCONFIG
;
941 unsigned IOCTL_PIO_CMAP
= PIO_CMAP
;
942 unsigned IOCTL_PIO_FONT
= PIO_FONT
;
943 unsigned IOCTL_PIO_UNIMAP
= PIO_UNIMAP
;
944 unsigned IOCTL_PIO_UNIMAPCLR
= PIO_UNIMAPCLR
;
945 unsigned IOCTL_PIO_UNISCRNMAP
= PIO_UNISCRNMAP
;
947 unsigned IOCTL_SCSI_IOCTL_GET_IDLUN
= SCSI_IOCTL_GET_IDLUN
;
948 unsigned IOCTL_SCSI_IOCTL_PROBE_HOST
= SCSI_IOCTL_PROBE_HOST
;
949 unsigned IOCTL_SCSI_IOCTL_TAGGED_DISABLE
= SCSI_IOCTL_TAGGED_DISABLE
;
950 unsigned IOCTL_SCSI_IOCTL_TAGGED_ENABLE
= SCSI_IOCTL_TAGGED_ENABLE
;
951 unsigned IOCTL_SIOCAIPXITFCRT
= SIOCAIPXITFCRT
;
952 unsigned IOCTL_SIOCAIPXPRISLT
= SIOCAIPXPRISLT
;
953 unsigned IOCTL_SIOCAX25ADDUID
= SIOCAX25ADDUID
;
954 unsigned IOCTL_SIOCAX25DELUID
= SIOCAX25DELUID
;
955 unsigned IOCTL_SIOCAX25GETPARMS
= SIOCAX25GETPARMS
;
956 unsigned IOCTL_SIOCAX25GETUID
= SIOCAX25GETUID
;
957 unsigned IOCTL_SIOCAX25NOUID
= SIOCAX25NOUID
;
958 unsigned IOCTL_SIOCAX25SETPARMS
= SIOCAX25SETPARMS
;
959 unsigned IOCTL_SIOCDEVPLIP
= SIOCDEVPLIP
;
960 unsigned IOCTL_SIOCIPXCFGDATA
= SIOCIPXCFGDATA
;
961 unsigned IOCTL_SIOCNRDECOBS
= SIOCNRDECOBS
;
962 unsigned IOCTL_SIOCNRGETPARMS
= SIOCNRGETPARMS
;
963 unsigned IOCTL_SIOCNRRTCTL
= SIOCNRRTCTL
;
964 unsigned IOCTL_SIOCNRSETPARMS
= SIOCNRSETPARMS
;
966 unsigned IOCTL_TIOCGSERIAL
= TIOCGSERIAL
;
967 unsigned IOCTL_TIOCSERGETMULTI
= TIOCSERGETMULTI
;
968 unsigned IOCTL_TIOCSERSETMULTI
= TIOCSERSETMULTI
;
969 unsigned IOCTL_TIOCSSERIAL
= TIOCSSERIAL
;
970 #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
972 #if SANITIZER_LINUX && !SANITIZER_ANDROID
973 unsigned IOCTL_GIO_SCRNMAP
= GIO_SCRNMAP
;
974 unsigned IOCTL_KDDISABIO
= KDDISABIO
;
975 unsigned IOCTL_KDENABIO
= KDENABIO
;
976 unsigned IOCTL_KDGETLED
= KDGETLED
;
977 unsigned IOCTL_KDGETMODE
= KDGETMODE
;
978 unsigned IOCTL_KDGKBMODE
= KDGKBMODE
;
979 unsigned IOCTL_KDGKBTYPE
= KDGKBTYPE
;
980 unsigned IOCTL_KDMKTONE
= KDMKTONE
;
981 unsigned IOCTL_KDSETLED
= KDSETLED
;
982 unsigned IOCTL_KDSETMODE
= KDSETMODE
;
983 unsigned IOCTL_KDSKBMODE
= KDSKBMODE
;
984 unsigned IOCTL_KIOCSOUND
= KIOCSOUND
;
985 unsigned IOCTL_PIO_SCRNMAP
= PIO_SCRNMAP
;
986 unsigned IOCTL_SNDCTL_DSP_GETISPACE
= SNDCTL_DSP_GETISPACE
;
987 unsigned IOCTL_SNDCTL_DSP_GETOSPACE
= SNDCTL_DSP_GETOSPACE
;
988 #endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
990 const int si_SEGV_MAPERR
= SEGV_MAPERR
;
991 const int si_SEGV_ACCERR
= SEGV_ACCERR
;
992 } // namespace __sanitizer
994 using namespace __sanitizer
;
996 COMPILER_CHECK(sizeof(__sanitizer_pthread_attr_t
) >= sizeof(pthread_attr_t
));
998 COMPILER_CHECK(sizeof(socklen_t
) == sizeof(unsigned));
999 CHECK_TYPE_SIZE(pthread_key_t
);
1002 // FIXME: We define those on Linux and Mac, but only check on Linux.
1003 COMPILER_CHECK(IOC_NRBITS
== _IOC_NRBITS
);
1004 COMPILER_CHECK(IOC_TYPEBITS
== _IOC_TYPEBITS
);
1005 COMPILER_CHECK(IOC_SIZEBITS
== _IOC_SIZEBITS
);
1006 COMPILER_CHECK(IOC_DIRBITS
== _IOC_DIRBITS
);
1007 COMPILER_CHECK(IOC_NRMASK
== _IOC_NRMASK
);
1008 COMPILER_CHECK(IOC_TYPEMASK
== _IOC_TYPEMASK
);
1009 COMPILER_CHECK(IOC_SIZEMASK
== _IOC_SIZEMASK
);
1010 COMPILER_CHECK(IOC_DIRMASK
== _IOC_DIRMASK
);
1011 COMPILER_CHECK(IOC_NRSHIFT
== _IOC_NRSHIFT
);
1012 COMPILER_CHECK(IOC_TYPESHIFT
== _IOC_TYPESHIFT
);
1013 COMPILER_CHECK(IOC_SIZESHIFT
== _IOC_SIZESHIFT
);
1014 COMPILER_CHECK(IOC_DIRSHIFT
== _IOC_DIRSHIFT
);
1015 COMPILER_CHECK(IOC_NONE
== _IOC_NONE
);
1016 COMPILER_CHECK(IOC_WRITE
== _IOC_WRITE
);
1017 COMPILER_CHECK(IOC_READ
== _IOC_READ
);
1018 COMPILER_CHECK(EVIOC_ABS_MAX
== ABS_MAX
);
1019 COMPILER_CHECK(EVIOC_EV_MAX
== EV_MAX
);
1020 COMPILER_CHECK(IOC_SIZE(0x12345678) == _IOC_SIZE(0x12345678));
1021 COMPILER_CHECK(IOC_DIR(0x12345678) == _IOC_DIR(0x12345678));
1022 COMPILER_CHECK(IOC_NR(0x12345678) == _IOC_NR(0x12345678));
1023 COMPILER_CHECK(IOC_TYPE(0x12345678) == _IOC_TYPE(0x12345678));
1024 #endif // SANITIZER_LINUX
1026 #if SANITIZER_LINUX || SANITIZER_FREEBSD
1027 // There are more undocumented fields in dl_phdr_info that we are not interested
1029 COMPILER_CHECK(sizeof(__sanitizer_dl_phdr_info
) <= sizeof(dl_phdr_info
));
1030 CHECK_SIZE_AND_OFFSET(dl_phdr_info
, dlpi_addr
);
1031 CHECK_SIZE_AND_OFFSET(dl_phdr_info
, dlpi_name
);
1032 CHECK_SIZE_AND_OFFSET(dl_phdr_info
, dlpi_phdr
);
1033 CHECK_SIZE_AND_OFFSET(dl_phdr_info
, dlpi_phnum
);
1034 #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
1036 #if SANITIZER_GLIBC || SANITIZER_FREEBSD
1037 CHECK_TYPE_SIZE(glob_t
);
1038 CHECK_SIZE_AND_OFFSET(glob_t
, gl_pathc
);
1039 CHECK_SIZE_AND_OFFSET(glob_t
, gl_pathv
);
1040 CHECK_SIZE_AND_OFFSET(glob_t
, gl_offs
);
1041 CHECK_SIZE_AND_OFFSET(glob_t
, gl_flags
);
1042 CHECK_SIZE_AND_OFFSET(glob_t
, gl_closedir
);
1043 CHECK_SIZE_AND_OFFSET(glob_t
, gl_readdir
);
1044 CHECK_SIZE_AND_OFFSET(glob_t
, gl_opendir
);
1045 CHECK_SIZE_AND_OFFSET(glob_t
, gl_lstat
);
1046 CHECK_SIZE_AND_OFFSET(glob_t
, gl_stat
);
1047 #endif // SANITIZER_GLIBC || SANITIZER_FREEBSD
1049 CHECK_TYPE_SIZE(addrinfo
);
1050 CHECK_SIZE_AND_OFFSET(addrinfo
, ai_flags
);
1051 CHECK_SIZE_AND_OFFSET(addrinfo
, ai_family
);
1052 CHECK_SIZE_AND_OFFSET(addrinfo
, ai_socktype
);
1053 CHECK_SIZE_AND_OFFSET(addrinfo
, ai_protocol
);
1054 CHECK_SIZE_AND_OFFSET(addrinfo
, ai_protocol
);
1055 CHECK_SIZE_AND_OFFSET(addrinfo
, ai_addrlen
);
1056 CHECK_SIZE_AND_OFFSET(addrinfo
, ai_canonname
);
1057 CHECK_SIZE_AND_OFFSET(addrinfo
, ai_addr
);
1059 CHECK_TYPE_SIZE(hostent
);
1060 CHECK_SIZE_AND_OFFSET(hostent
, h_name
);
1061 CHECK_SIZE_AND_OFFSET(hostent
, h_aliases
);
1062 CHECK_SIZE_AND_OFFSET(hostent
, h_addrtype
);
1063 CHECK_SIZE_AND_OFFSET(hostent
, h_length
);
1064 CHECK_SIZE_AND_OFFSET(hostent
, h_addr_list
);
1066 CHECK_TYPE_SIZE(iovec
);
1067 CHECK_SIZE_AND_OFFSET(iovec
, iov_base
);
1068 CHECK_SIZE_AND_OFFSET(iovec
, iov_len
);
1070 // In POSIX, int msg_iovlen; socklen_t msg_controllen; socklen_t cmsg_len; but
1071 // many implementations don't conform to the standard. Since we pick the
1072 // non-conforming glibc definition, exclude the checks for musl (incompatible
1073 // sizes but compatible offsets).
1074 CHECK_TYPE_SIZE(msghdr
);
1075 CHECK_SIZE_AND_OFFSET(msghdr
, msg_name
);
1076 CHECK_SIZE_AND_OFFSET(msghdr
, msg_namelen
);
1077 CHECK_SIZE_AND_OFFSET(msghdr
, msg_iov
);
1078 #if SANITIZER_GLIBC || SANITIZER_ANDROID
1079 CHECK_SIZE_AND_OFFSET(msghdr
, msg_iovlen
);
1081 CHECK_SIZE_AND_OFFSET(msghdr
, msg_control
);
1082 #if SANITIZER_GLIBC || SANITIZER_ANDROID
1083 CHECK_SIZE_AND_OFFSET(msghdr
, msg_controllen
);
1085 CHECK_SIZE_AND_OFFSET(msghdr
, msg_flags
);
1087 CHECK_TYPE_SIZE(cmsghdr
);
1088 #if SANITIZER_GLIBC || SANITIZER_ANDROID
1089 CHECK_SIZE_AND_OFFSET(cmsghdr
, cmsg_len
);
1091 CHECK_SIZE_AND_OFFSET(cmsghdr
, cmsg_level
);
1092 CHECK_SIZE_AND_OFFSET(cmsghdr
, cmsg_type
);
1094 #if SANITIZER_LINUX && (__ANDROID_API__ >= 21 || __GLIBC_PREREQ (2, 14))
1095 CHECK_TYPE_SIZE(mmsghdr
);
1096 CHECK_SIZE_AND_OFFSET(mmsghdr
, msg_hdr
);
1097 CHECK_SIZE_AND_OFFSET(mmsghdr
, msg_len
);
1100 COMPILER_CHECK(sizeof(__sanitizer_dirent
) <= sizeof(dirent
));
1101 CHECK_SIZE_AND_OFFSET(dirent
, d_ino
);
1103 CHECK_SIZE_AND_OFFSET(dirent
, d_seekoff
);
1104 #elif SANITIZER_FREEBSD
1105 // There is no 'd_off' field on FreeBSD.
1107 CHECK_SIZE_AND_OFFSET(dirent
, d_off
);
1109 CHECK_SIZE_AND_OFFSET(dirent
, d_reclen
);
1112 COMPILER_CHECK(sizeof(__sanitizer_dirent64
) <= sizeof(dirent64
));
1113 CHECK_SIZE_AND_OFFSET(dirent64
, d_ino
);
1114 CHECK_SIZE_AND_OFFSET(dirent64
, d_off
);
1115 CHECK_SIZE_AND_OFFSET(dirent64
, d_reclen
);
1118 CHECK_TYPE_SIZE(ifconf
);
1119 CHECK_SIZE_AND_OFFSET(ifconf
, ifc_len
);
1120 CHECK_SIZE_AND_OFFSET(ifconf
, ifc_ifcu
);
1122 CHECK_TYPE_SIZE(pollfd
);
1123 CHECK_SIZE_AND_OFFSET(pollfd
, fd
);
1124 CHECK_SIZE_AND_OFFSET(pollfd
, events
);
1125 CHECK_SIZE_AND_OFFSET(pollfd
, revents
);
1127 CHECK_TYPE_SIZE(nfds_t
);
1129 CHECK_TYPE_SIZE(sigset_t
);
1131 COMPILER_CHECK(sizeof(__sanitizer_sigaction
) == sizeof(struct sigaction
));
1132 // Can't write checks for sa_handler and sa_sigaction due to them being
1133 // preprocessor macros.
1134 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction
, sa_mask
);
1135 #if !defined(__s390x__) || __GLIBC_PREREQ (2, 20)
1136 // On s390x glibc 2.19 and earlier sa_flags was unsigned long, and sa_resv
1138 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction
, sa_flags
);
1140 #if SANITIZER_LINUX && (!SANITIZER_ANDROID || !SANITIZER_MIPS32)
1141 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction
, sa_restorer
);
1144 #if SANITIZER_HAS_SIGINFO
1145 COMPILER_CHECK(alignof(siginfo_t
) == alignof(__sanitizer_siginfo
));
1146 using __sanitizer_siginfo_t
= __sanitizer_siginfo
;
1147 CHECK_TYPE_SIZE(siginfo_t
);
1148 CHECK_SIZE_AND_OFFSET(siginfo_t
, si_signo
);
1149 CHECK_SIZE_AND_OFFSET(siginfo_t
, si_errno
);
1150 CHECK_SIZE_AND_OFFSET(siginfo_t
, si_code
);
1154 CHECK_TYPE_SIZE(__sysctl_args
);
1155 CHECK_SIZE_AND_OFFSET(__sysctl_args
, name
);
1156 CHECK_SIZE_AND_OFFSET(__sysctl_args
, nlen
);
1157 CHECK_SIZE_AND_OFFSET(__sysctl_args
, oldval
);
1158 CHECK_SIZE_AND_OFFSET(__sysctl_args
, oldlenp
);
1159 CHECK_SIZE_AND_OFFSET(__sysctl_args
, newval
);
1160 CHECK_SIZE_AND_OFFSET(__sysctl_args
, newlen
);
1162 CHECK_TYPE_SIZE(__kernel_uid_t
);
1163 CHECK_TYPE_SIZE(__kernel_gid_t
);
1165 #if SANITIZER_USES_UID16_SYSCALLS
1166 CHECK_TYPE_SIZE(__kernel_old_uid_t
);
1167 CHECK_TYPE_SIZE(__kernel_old_gid_t
);
1170 CHECK_TYPE_SIZE(__kernel_off_t
);
1171 CHECK_TYPE_SIZE(__kernel_loff_t
);
1172 CHECK_TYPE_SIZE(__kernel_fd_set
);
1175 #if !SANITIZER_ANDROID
1176 CHECK_TYPE_SIZE(wordexp_t
);
1177 CHECK_SIZE_AND_OFFSET(wordexp_t
, we_wordc
);
1178 CHECK_SIZE_AND_OFFSET(wordexp_t
, we_wordv
);
1179 CHECK_SIZE_AND_OFFSET(wordexp_t
, we_offs
);
1182 CHECK_TYPE_SIZE(tm
);
1183 CHECK_SIZE_AND_OFFSET(tm
, tm_sec
);
1184 CHECK_SIZE_AND_OFFSET(tm
, tm_min
);
1185 CHECK_SIZE_AND_OFFSET(tm
, tm_hour
);
1186 CHECK_SIZE_AND_OFFSET(tm
, tm_mday
);
1187 CHECK_SIZE_AND_OFFSET(tm
, tm_mon
);
1188 CHECK_SIZE_AND_OFFSET(tm
, tm_year
);
1189 CHECK_SIZE_AND_OFFSET(tm
, tm_wday
);
1190 CHECK_SIZE_AND_OFFSET(tm
, tm_yday
);
1191 CHECK_SIZE_AND_OFFSET(tm
, tm_isdst
);
1192 CHECK_SIZE_AND_OFFSET(tm
, tm_gmtoff
);
1193 CHECK_SIZE_AND_OFFSET(tm
, tm_zone
);
1196 CHECK_TYPE_SIZE(mntent
);
1197 CHECK_SIZE_AND_OFFSET(mntent
, mnt_fsname
);
1198 CHECK_SIZE_AND_OFFSET(mntent
, mnt_dir
);
1199 CHECK_SIZE_AND_OFFSET(mntent
, mnt_type
);
1200 CHECK_SIZE_AND_OFFSET(mntent
, mnt_opts
);
1201 CHECK_SIZE_AND_OFFSET(mntent
, mnt_freq
);
1202 CHECK_SIZE_AND_OFFSET(mntent
, mnt_passno
);
1205 CHECK_TYPE_SIZE(ether_addr
);
1207 #if SANITIZER_GLIBC || SANITIZER_FREEBSD
1208 CHECK_TYPE_SIZE(ipc_perm
);
1209 # if SANITIZER_FREEBSD
1210 CHECK_SIZE_AND_OFFSET(ipc_perm
, key
);
1211 CHECK_SIZE_AND_OFFSET(ipc_perm
, seq
);
1213 CHECK_SIZE_AND_OFFSET(ipc_perm
, __key
);
1214 CHECK_SIZE_AND_OFFSET(ipc_perm
, __seq
);
1216 CHECK_SIZE_AND_OFFSET(ipc_perm
, uid
);
1217 CHECK_SIZE_AND_OFFSET(ipc_perm
, gid
);
1218 CHECK_SIZE_AND_OFFSET(ipc_perm
, cuid
);
1219 CHECK_SIZE_AND_OFFSET(ipc_perm
, cgid
);
1220 #if !SANITIZER_LINUX || __GLIBC_PREREQ (2, 31)
1221 /* glibc 2.30 and earlier provided 16-bit mode field instead of 32-bit
1222 on many architectures. */
1223 CHECK_SIZE_AND_OFFSET(ipc_perm
, mode
);
1226 CHECK_TYPE_SIZE(shmid_ds
);
1227 CHECK_SIZE_AND_OFFSET(shmid_ds
, shm_perm
);
1228 CHECK_SIZE_AND_OFFSET(shmid_ds
, shm_segsz
);
1229 CHECK_SIZE_AND_OFFSET(shmid_ds
, shm_atime
);
1230 CHECK_SIZE_AND_OFFSET(shmid_ds
, shm_dtime
);
1231 CHECK_SIZE_AND_OFFSET(shmid_ds
, shm_ctime
);
1232 CHECK_SIZE_AND_OFFSET(shmid_ds
, shm_cpid
);
1233 CHECK_SIZE_AND_OFFSET(shmid_ds
, shm_lpid
);
1234 CHECK_SIZE_AND_OFFSET(shmid_ds
, shm_nattch
);
1237 CHECK_TYPE_SIZE(clock_t);
1240 CHECK_TYPE_SIZE(clockid_t
);
1243 #if !SANITIZER_ANDROID
1244 CHECK_TYPE_SIZE(ifaddrs
);
1245 CHECK_SIZE_AND_OFFSET(ifaddrs
, ifa_next
);
1246 CHECK_SIZE_AND_OFFSET(ifaddrs
, ifa_name
);
1247 CHECK_SIZE_AND_OFFSET(ifaddrs
, ifa_addr
);
1248 CHECK_SIZE_AND_OFFSET(ifaddrs
, ifa_netmask
);
1249 #if SANITIZER_LINUX || SANITIZER_FREEBSD
1250 // Compare against the union, because we can't reach into the union in a
1255 # if SANITIZER_FREEBSD
1256 CHECK_SIZE_AND_OFFSET(ifaddrs
, ifa_dstaddr
);
1258 COMPILER_CHECK(sizeof(((__sanitizer_ifaddrs
*)nullptr)->ifa_dstaddr
) ==
1259 sizeof(((ifaddrs
*)nullptr)->ifa_ifu
));
1260 COMPILER_CHECK(offsetof(__sanitizer_ifaddrs
, ifa_dstaddr
) ==
1261 offsetof(ifaddrs
, ifa_ifu
));
1262 # endif // SANITIZER_FREEBSD
1264 CHECK_SIZE_AND_OFFSET(ifaddrs
, ifa_dstaddr
);
1265 #endif // SANITIZER_LINUX
1266 CHECK_SIZE_AND_OFFSET(ifaddrs
, ifa_data
);
1269 #if SANITIZER_GLIBC || SANITIZER_ANDROID
1270 COMPILER_CHECK(sizeof(__sanitizer_struct_mallinfo
) == sizeof(struct mallinfo
));
1273 #if !SANITIZER_ANDROID
1274 CHECK_TYPE_SIZE(timeb
);
1275 CHECK_SIZE_AND_OFFSET(timeb
, time
);
1276 CHECK_SIZE_AND_OFFSET(timeb
, millitm
);
1277 CHECK_SIZE_AND_OFFSET(timeb
, timezone
);
1278 CHECK_SIZE_AND_OFFSET(timeb
, dstflag
);
1281 CHECK_TYPE_SIZE(passwd
);
1282 CHECK_SIZE_AND_OFFSET(passwd
, pw_name
);
1283 CHECK_SIZE_AND_OFFSET(passwd
, pw_passwd
);
1284 CHECK_SIZE_AND_OFFSET(passwd
, pw_uid
);
1285 CHECK_SIZE_AND_OFFSET(passwd
, pw_gid
);
1286 CHECK_SIZE_AND_OFFSET(passwd
, pw_dir
);
1287 CHECK_SIZE_AND_OFFSET(passwd
, pw_shell
);
1289 #if !SANITIZER_ANDROID
1290 CHECK_SIZE_AND_OFFSET(passwd
, pw_gecos
);
1294 CHECK_SIZE_AND_OFFSET(passwd
, pw_change
);
1295 CHECK_SIZE_AND_OFFSET(passwd
, pw_expire
);
1296 CHECK_SIZE_AND_OFFSET(passwd
, pw_class
);
1300 CHECK_TYPE_SIZE(group
);
1301 CHECK_SIZE_AND_OFFSET(group
, gr_name
);
1302 CHECK_SIZE_AND_OFFSET(group
, gr_passwd
);
1303 CHECK_SIZE_AND_OFFSET(group
, gr_gid
);
1304 CHECK_SIZE_AND_OFFSET(group
, gr_mem
);
1306 #if HAVE_RPC_XDR_H && !SANITIZER_APPLE
1307 CHECK_TYPE_SIZE(XDR
);
1308 CHECK_SIZE_AND_OFFSET(XDR
, x_op
);
1309 CHECK_SIZE_AND_OFFSET(XDR
, x_ops
);
1310 CHECK_SIZE_AND_OFFSET(XDR
, x_public
);
1311 CHECK_SIZE_AND_OFFSET(XDR
, x_private
);
1312 CHECK_SIZE_AND_OFFSET(XDR
, x_base
);
1313 CHECK_SIZE_AND_OFFSET(XDR
, x_handy
);
1314 COMPILER_CHECK(__sanitizer_XDR_ENCODE
== XDR_ENCODE
);
1315 COMPILER_CHECK(__sanitizer_XDR_DECODE
== XDR_DECODE
);
1316 COMPILER_CHECK(__sanitizer_XDR_FREE
== XDR_FREE
);
1320 COMPILER_CHECK(sizeof(__sanitizer_FILE
) <= sizeof(FILE));
1321 CHECK_SIZE_AND_OFFSET(FILE, _flags
);
1322 CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr
);
1323 CHECK_SIZE_AND_OFFSET(FILE, _IO_read_end
);
1324 CHECK_SIZE_AND_OFFSET(FILE, _IO_read_base
);
1325 CHECK_SIZE_AND_OFFSET(FILE, _IO_write_ptr
);
1326 CHECK_SIZE_AND_OFFSET(FILE, _IO_write_end
);
1327 CHECK_SIZE_AND_OFFSET(FILE, _IO_write_base
);
1328 CHECK_SIZE_AND_OFFSET(FILE, _IO_buf_base
);
1329 CHECK_SIZE_AND_OFFSET(FILE, _IO_buf_end
);
1330 CHECK_SIZE_AND_OFFSET(FILE, _IO_save_base
);
1331 CHECK_SIZE_AND_OFFSET(FILE, _IO_backup_base
);
1332 CHECK_SIZE_AND_OFFSET(FILE, _IO_save_end
);
1333 CHECK_SIZE_AND_OFFSET(FILE, _markers
);
1334 CHECK_SIZE_AND_OFFSET(FILE, _chain
);
1335 CHECK_SIZE_AND_OFFSET(FILE, _fileno
);
1337 COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk
) <= sizeof(_obstack_chunk
));
1338 CHECK_SIZE_AND_OFFSET(_obstack_chunk
, limit
);
1339 CHECK_SIZE_AND_OFFSET(_obstack_chunk
, prev
);
1340 CHECK_TYPE_SIZE(obstack
);
1341 CHECK_SIZE_AND_OFFSET(obstack
, chunk_size
);
1342 CHECK_SIZE_AND_OFFSET(obstack
, chunk
);
1343 CHECK_SIZE_AND_OFFSET(obstack
, object_base
);
1344 CHECK_SIZE_AND_OFFSET(obstack
, next_free
);
1346 CHECK_TYPE_SIZE(cookie_io_functions_t
);
1347 CHECK_SIZE_AND_OFFSET(cookie_io_functions_t
, read
);
1348 CHECK_SIZE_AND_OFFSET(cookie_io_functions_t
, write
);
1349 CHECK_SIZE_AND_OFFSET(cookie_io_functions_t
, seek
);
1350 CHECK_SIZE_AND_OFFSET(cookie_io_functions_t
, close
);
1351 #endif // SANITIZER_GLIBC
1353 #if SANITIZER_LINUX || SANITIZER_FREEBSD
1354 CHECK_TYPE_SIZE(sem_t
);
1357 #if SANITIZER_LINUX && defined(__arm__)
1358 COMPILER_CHECK(ARM_VFPREGS_SIZE
== ARM_VFPREGS_SIZE_ASAN
);
1361 #endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_APPLE