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