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