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