• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- sanitizer_platform_limits_posix.h ---------------------------------===//
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 #ifndef SANITIZER_PLATFORM_LIMITS_POSIX_H
16 #define SANITIZER_PLATFORM_LIMITS_POSIX_H
17 
18 #include "sanitizer_internal_defs.h"
19 #include "sanitizer_platform.h"
20 
21 namespace __sanitizer {
22   extern unsigned struct_utsname_sz;
23   extern unsigned struct_stat_sz;
24 #if !SANITIZER_FREEBSD && !SANITIZER_IOS
25   extern unsigned struct_stat64_sz;
26 #endif
27   extern unsigned struct_rusage_sz;
28   extern unsigned siginfo_t_sz;
29   extern unsigned struct_itimerval_sz;
30   extern unsigned pthread_t_sz;
31   extern unsigned pthread_cond_t_sz;
32   extern unsigned pid_t_sz;
33   extern unsigned timeval_sz;
34   extern unsigned uid_t_sz;
35   extern unsigned gid_t_sz;
36   extern unsigned mbstate_t_sz;
37   extern unsigned struct_timezone_sz;
38   extern unsigned struct_tms_sz;
39   extern unsigned struct_itimerspec_sz;
40   extern unsigned struct_sigevent_sz;
41   extern unsigned struct_sched_param_sz;
42   extern unsigned struct_statfs64_sz;
43 
44 #if !SANITIZER_ANDROID
45   extern unsigned struct_statfs_sz;
46   extern unsigned struct_sockaddr_sz;
47   extern unsigned ucontext_t_sz;
48 #endif // !SANITIZER_ANDROID
49 
50 #if SANITIZER_LINUX
51 
52 #if defined(__x86_64__)
53   const unsigned struct_kernel_stat_sz = 144;
54   const unsigned struct_kernel_stat64_sz = 0;
55 #elif defined(__i386__)
56   const unsigned struct_kernel_stat_sz = 64;
57   const unsigned struct_kernel_stat64_sz = 96;
58 #elif defined(__arm__)
59   const unsigned struct_kernel_stat_sz = 64;
60   const unsigned struct_kernel_stat64_sz = 104;
61 #elif defined(__aarch64__)
62   const unsigned struct_kernel_stat_sz = 128;
63   const unsigned struct_kernel_stat64_sz = 104;
64 #elif defined(__powerpc__) && !defined(__powerpc64__)
65   const unsigned struct_kernel_stat_sz = 72;
66   const unsigned struct_kernel_stat64_sz = 104;
67 #elif defined(__powerpc64__)
68   const unsigned struct_kernel_stat_sz = 144;
69   const unsigned struct_kernel_stat64_sz = 104;
70 #elif defined(__mips__)
71   #if SANITIZER_WORDSIZE == 64
72   const unsigned struct_kernel_stat_sz = 216;
73   #else
74   const unsigned struct_kernel_stat_sz = 144;
75   #endif
76   const unsigned struct_kernel_stat64_sz = 104;
77 #endif
78   struct __sanitizer_perf_event_attr {
79     unsigned type;
80     unsigned size;
81     // More fields that vary with the kernel version.
82   };
83 
84   extern unsigned struct_epoll_event_sz;
85   extern unsigned struct_sysinfo_sz;
86   extern unsigned __user_cap_header_struct_sz;
87   extern unsigned __user_cap_data_struct_sz;
88   extern unsigned struct_new_utsname_sz;
89   extern unsigned struct_old_utsname_sz;
90   extern unsigned struct_oldold_utsname_sz;
91 
92   const unsigned struct_kexec_segment_sz = 4 * sizeof(unsigned long);
93 #endif  // SANITIZER_LINUX
94 
95 #if SANITIZER_LINUX || SANITIZER_FREEBSD
96 
97 #if defined(__powerpc64__)
98   const unsigned struct___old_kernel_stat_sz = 0;
99 #else
100   const unsigned struct___old_kernel_stat_sz = 32;
101 #endif
102 
103   extern unsigned struct_rlimit_sz;
104   extern unsigned struct_utimbuf_sz;
105   extern unsigned struct_timespec_sz;
106 
107   struct __sanitizer_iocb {
108     u64   aio_data;
109     u32   aio_key_or_aio_reserved1; // Simply crazy.
110     u32   aio_reserved1_or_aio_key; // Luckily, we don't need these.
111     u16   aio_lio_opcode;
112     s16   aio_reqprio;
113     u32   aio_fildes;
114     u64   aio_buf;
115     u64   aio_nbytes;
116     s64   aio_offset;
117     u64   aio_reserved2;
118     u64   aio_reserved3;
119   };
120 
121   struct __sanitizer_io_event {
122     u64 data;
123     u64 obj;
124     u64 res;
125     u64 res2;
126   };
127 
128   const unsigned iocb_cmd_pread = 0;
129   const unsigned iocb_cmd_pwrite = 1;
130   const unsigned iocb_cmd_preadv = 7;
131   const unsigned iocb_cmd_pwritev = 8;
132 
133   struct __sanitizer___sysctl_args {
134     int *name;
135     int nlen;
136     void *oldval;
137     uptr *oldlenp;
138     void *newval;
139     uptr newlen;
140     unsigned long ___unused[4];
141   };
142 
143   const unsigned old_sigset_t_sz = sizeof(unsigned long);
144 #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
145 
146 #if SANITIZER_ANDROID
147   struct __sanitizer_mallinfo {
148     uptr v[10];
149   };
150 #endif
151 
152 #if SANITIZER_LINUX && !SANITIZER_ANDROID
153   struct __sanitizer_mallinfo {
154     int v[10];
155   };
156 
157   extern unsigned struct_ustat_sz;
158   extern unsigned struct_rlimit64_sz;
159   extern unsigned struct_statvfs64_sz;
160 
161   struct __sanitizer_ipc_perm {
162     int __key;
163     int uid;
164     int gid;
165     int cuid;
166     int cgid;
167 #ifdef __powerpc__
168     unsigned mode;
169     unsigned __seq;
170     u64 __unused1;
171     u64 __unused2;
172 #elif defined(__mips__)
173     unsigned int mode;
174     unsigned short __seq;
175     unsigned short __pad1;
176     unsigned long __unused1;
177     unsigned long __unused2;
178 #else
179     unsigned short mode;
180     unsigned short __pad1;
181     unsigned short __seq;
182     unsigned short __pad2;
183 #if defined(__x86_64__) && !defined(_LP64)
184     u64 __unused1;
185     u64 __unused2;
186 #else
187     unsigned long __unused1;
188     unsigned long __unused2;
189 #endif
190 #endif
191   };
192 
193   struct __sanitizer_shmid_ds {
194     __sanitizer_ipc_perm shm_perm;
195   #ifndef __powerpc__
196     uptr shm_segsz;
197   #elif !defined(__powerpc64__)
198     uptr __unused0;
199   #endif
200   #if defined(__x86_64__) && !defined(_LP64)
201     u64 shm_atime;
202     u64 shm_dtime;
203     u64 shm_ctime;
204   #else
205     uptr shm_atime;
206   #if !defined(_LP64) && !defined(__mips__)
207     uptr __unused1;
208   #endif
209     uptr shm_dtime;
210   #if !defined(_LP64) && !defined(__mips__)
211     uptr __unused2;
212   #endif
213     uptr shm_ctime;
214   #if !defined(_LP64) && !defined(__mips__)
215     uptr __unused3;
216   #endif
217   #endif
218   #ifdef __powerpc__
219     uptr shm_segsz;
220   #endif
221     int shm_cpid;
222     int shm_lpid;
223   #if defined(__x86_64__) && !defined(_LP64)
224     u64 shm_nattch;
225     u64 __unused4;
226     u64 __unused5;
227   #else
228     uptr shm_nattch;
229     uptr __unused4;
230     uptr __unused5;
231   #endif
232   };
233 #elif SANITIZER_FREEBSD
234   struct __sanitizer_ipc_perm {
235     unsigned int cuid;
236     unsigned int cgid;
237     unsigned int uid;
238     unsigned int gid;
239     unsigned short mode;
240     unsigned short seq;
241     long key;
242   };
243 
244   struct __sanitizer_shmid_ds {
245     __sanitizer_ipc_perm shm_perm;
246     unsigned long shm_segsz;
247     unsigned int shm_lpid;
248     unsigned int shm_cpid;
249     int shm_nattch;
250     unsigned long shm_atime;
251     unsigned long shm_dtime;
252     unsigned long shm_ctime;
253   };
254 #endif
255 
256 #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
257   extern unsigned struct_msqid_ds_sz;
258   extern unsigned struct_mq_attr_sz;
259   extern unsigned struct_timex_sz;
260   extern unsigned struct_statvfs_sz;
261 #endif  // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
262 
263   struct __sanitizer_iovec {
264     void *iov_base;
265     uptr iov_len;
266   };
267 
268 #if !SANITIZER_ANDROID
269   struct __sanitizer_ifaddrs {
270     struct __sanitizer_ifaddrs *ifa_next;
271     char *ifa_name;
272     unsigned int ifa_flags;
273     void *ifa_addr;    // (struct sockaddr *)
274     void *ifa_netmask; // (struct sockaddr *)
275     // This is a union on Linux.
276 # ifdef ifa_dstaddr
277 # undef ifa_dstaddr
278 # endif
279     void *ifa_dstaddr; // (struct sockaddr *)
280     void *ifa_data;
281   };
282 #endif  // !SANITIZER_ANDROID
283 
284 #if SANITIZER_MAC
285   typedef unsigned long __sanitizer_pthread_key_t;
286 #else
287   typedef unsigned __sanitizer_pthread_key_t;
288 #endif
289 
290 #if SANITIZER_LINUX && !SANITIZER_ANDROID
291 
292   struct __sanitizer_XDR {
293     int x_op;
294     void *x_ops;
295     uptr x_public;
296     uptr x_private;
297     uptr x_base;
298     unsigned x_handy;
299   };
300 
301   const int __sanitizer_XDR_ENCODE = 0;
302   const int __sanitizer_XDR_DECODE = 1;
303   const int __sanitizer_XDR_FREE = 2;
304 #endif
305 
306   struct __sanitizer_passwd {
307     char *pw_name;
308     char *pw_passwd;
309     int pw_uid;
310     int pw_gid;
311 #if SANITIZER_MAC || SANITIZER_FREEBSD
312     long pw_change;
313     char *pw_class;
314 #endif
315 #if !SANITIZER_ANDROID
316     char *pw_gecos;
317 #endif
318     char *pw_dir;
319     char *pw_shell;
320 #if SANITIZER_MAC || SANITIZER_FREEBSD
321     long pw_expire;
322 #endif
323 #if SANITIZER_FREEBSD
324     int pw_fields;
325 #endif
326   };
327 
328   struct __sanitizer_group {
329     char *gr_name;
330     char *gr_passwd;
331     int gr_gid;
332     char **gr_mem;
333   };
334 
335 #if defined(__x86_64__) && !defined(_LP64)
336   typedef long long __sanitizer_time_t;
337 #else
338   typedef long __sanitizer_time_t;
339 #endif
340 
341   struct __sanitizer_timeb {
342     __sanitizer_time_t time;
343     unsigned short millitm;
344     short timezone;
345     short dstflag;
346   };
347 
348   struct __sanitizer_ether_addr {
349     u8 octet[6];
350   };
351 
352   struct __sanitizer_tm {
353     int tm_sec;
354     int tm_min;
355     int tm_hour;
356     int tm_mday;
357     int tm_mon;
358     int tm_year;
359     int tm_wday;
360     int tm_yday;
361     int tm_isdst;
362     long int tm_gmtoff;
363     const char *tm_zone;
364   };
365 
366 #if SANITIZER_LINUX
367   struct __sanitizer_mntent {
368     char *mnt_fsname;
369     char *mnt_dir;
370     char *mnt_type;
371     char *mnt_opts;
372     int mnt_freq;
373     int mnt_passno;
374   };
375 #endif
376 
377 #if SANITIZER_ANDROID || SANITIZER_MAC || SANITIZER_FREEBSD
378   struct __sanitizer_msghdr {
379     void *msg_name;
380     unsigned msg_namelen;
381     struct __sanitizer_iovec *msg_iov;
382     unsigned msg_iovlen;
383     void *msg_control;
384     unsigned msg_controllen;
385     int msg_flags;
386   };
387   struct __sanitizer_cmsghdr {
388     unsigned cmsg_len;
389     int cmsg_level;
390     int cmsg_type;
391   };
392 #else
393   struct __sanitizer_msghdr {
394     void *msg_name;
395     unsigned msg_namelen;
396     struct __sanitizer_iovec *msg_iov;
397     uptr msg_iovlen;
398     void *msg_control;
399     uptr msg_controllen;
400     int msg_flags;
401   };
402   struct __sanitizer_cmsghdr {
403     uptr cmsg_len;
404     int cmsg_level;
405     int cmsg_type;
406   };
407 #endif
408 
409 #if SANITIZER_MAC
410   struct __sanitizer_dirent {
411     unsigned long long d_ino;
412     unsigned long long d_seekoff;
413     unsigned short d_reclen;
414     // more fields that we don't care about
415   };
416 #elif SANITIZER_FREEBSD
417   struct __sanitizer_dirent {
418     unsigned int d_fileno;
419     unsigned short d_reclen;
420     // more fields that we don't care about
421   };
422 #elif SANITIZER_ANDROID || defined(__x86_64__)
423   struct __sanitizer_dirent {
424     unsigned long long d_ino;
425     unsigned long long d_off;
426     unsigned short d_reclen;
427     // more fields that we don't care about
428   };
429 #else
430   struct __sanitizer_dirent {
431     uptr d_ino;
432     uptr d_off;
433     unsigned short d_reclen;
434     // more fields that we don't care about
435   };
436 #endif
437 
438 #if SANITIZER_LINUX && !SANITIZER_ANDROID
439   struct __sanitizer_dirent64 {
440     unsigned long long d_ino;
441     unsigned long long d_off;
442     unsigned short d_reclen;
443     // more fields that we don't care about
444   };
445 #endif
446 
447 // 'clock_t' is 32 bits wide on x64 FreeBSD
448 #if SANITIZER_FREEBSD
449   typedef int __sanitizer_clock_t;
450 #elif defined(__x86_64__) && !defined(_LP64)
451   typedef long long __sanitizer_clock_t;
452 #else
453   typedef long __sanitizer_clock_t;
454 #endif
455 
456 #if SANITIZER_LINUX
457   typedef int __sanitizer_clockid_t;
458 #endif
459 
460 #if SANITIZER_LINUX || SANITIZER_FREEBSD
461 #if defined(_LP64) || defined(__x86_64__) || defined(__powerpc__)\
462                    || defined(__mips__)
463   typedef unsigned __sanitizer___kernel_uid_t;
464   typedef unsigned __sanitizer___kernel_gid_t;
465 #else
466   typedef unsigned short __sanitizer___kernel_uid_t;
467   typedef unsigned short __sanitizer___kernel_gid_t;
468 #endif
469 #if defined(__x86_64__) && !defined(_LP64)
470   typedef long long __sanitizer___kernel_off_t;
471 #else
472   typedef long __sanitizer___kernel_off_t;
473 #endif
474 
475 #if defined(__powerpc__) || defined(__aarch64__) || defined(__mips__)
476   typedef unsigned int __sanitizer___kernel_old_uid_t;
477   typedef unsigned int __sanitizer___kernel_old_gid_t;
478 #else
479   typedef unsigned short __sanitizer___kernel_old_uid_t;
480   typedef unsigned short __sanitizer___kernel_old_gid_t;
481 #endif
482 
483   typedef long long __sanitizer___kernel_loff_t;
484   typedef struct {
485     unsigned long fds_bits[1024 / (8 * sizeof(long))];
486   } __sanitizer___kernel_fd_set;
487 #endif
488 
489   // This thing depends on the platform. We are only interested in the upper
490   // limit. Verified with a compiler assert in .cc.
491   const int pthread_attr_t_max_sz = 128;
492   union __sanitizer_pthread_attr_t {
493     char size[pthread_attr_t_max_sz]; // NOLINT
494     void *align;
495   };
496 
497 #if SANITIZER_ANDROID
498   typedef unsigned long __sanitizer_sigset_t;
499 #elif SANITIZER_MAC
500   typedef unsigned __sanitizer_sigset_t;
501 #elif SANITIZER_LINUX
502   struct __sanitizer_sigset_t {
503     // The size is determined by looking at sizeof of real sigset_t on linux.
504     uptr val[128 / sizeof(uptr)];
505   };
506 #elif SANITIZER_FREEBSD
507   struct __sanitizer_sigset_t {
508      // uint32_t * 4
509      unsigned int __bits[4];
510   };
511 #endif
512 
513   // Linux system headers define the 'sa_handler' and 'sa_sigaction' macros.
514   struct __sanitizer_sigaction {
515 #if defined(__mips__) && !SANITIZER_FREEBSD
516     unsigned int sa_flags;
517 #endif
518     union {
519       void (*sigaction)(int sig, void *siginfo, void *uctx);
520       void (*handler)(int sig);
521     };
522 #if SANITIZER_FREEBSD
523     int sa_flags;
524     __sanitizer_sigset_t sa_mask;
525 #else
526     __sanitizer_sigset_t sa_mask;
527 #ifndef __mips__
528     int sa_flags;
529 #endif
530 #endif
531 #if SANITIZER_LINUX
532     void (*sa_restorer)();
533 #endif
534 #if defined(__mips__) && (SANITIZER_WORDSIZE == 32)
535     int sa_resv[1];
536 #endif
537   };
538 
539 #if SANITIZER_FREEBSD
540   typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t;
541 #else
542   struct __sanitizer_kernel_sigset_t {
543     u8 sig[8];
544   };
545 #endif
546 
547   // Linux system headers define the 'sa_handler' and 'sa_sigaction' macros.
548   struct __sanitizer_kernel_sigaction_t {
549     union {
550       void (*handler)(int signo);
551       void (*sigaction)(int signo, void *info, void *ctx);
552     };
553     unsigned long sa_flags;
554     void (*sa_restorer)(void);
555     __sanitizer_kernel_sigset_t sa_mask;
556   };
557 
558   extern uptr sig_ign;
559   extern uptr sig_dfl;
560   extern uptr sa_siginfo;
561 
562 #if SANITIZER_LINUX
563   extern int e_tabsz;
564 #endif
565 
566   extern int af_inet;
567   extern int af_inet6;
568   uptr __sanitizer_in_addr_sz(int af);
569 
570 #if SANITIZER_LINUX || SANITIZER_FREEBSD
571   struct __sanitizer_dl_phdr_info {
572     uptr dlpi_addr;
573     const char *dlpi_name;
574     const void *dlpi_phdr;
575     short dlpi_phnum;
576   };
577 #endif
578 
579   struct __sanitizer_addrinfo {
580     int ai_flags;
581     int ai_family;
582     int ai_socktype;
583     int ai_protocol;
584 #if SANITIZER_ANDROID || SANITIZER_MAC || SANITIZER_FREEBSD
585     unsigned ai_addrlen;
586     char *ai_canonname;
587     void *ai_addr;
588 #else // LINUX
589     unsigned ai_addrlen;
590     void *ai_addr;
591     char *ai_canonname;
592 #endif
593     struct __sanitizer_addrinfo *ai_next;
594   };
595 
596   struct __sanitizer_hostent {
597     char *h_name;
598     char **h_aliases;
599     int h_addrtype;
600     int h_length;
601     char **h_addr_list;
602   };
603 
604   struct __sanitizer_pollfd {
605     int fd;
606     short events;
607     short revents;
608   };
609 
610 #if SANITIZER_ANDROID || SANITIZER_MAC || SANITIZER_FREEBSD
611   typedef unsigned __sanitizer_nfds_t;
612 #else
613   typedef unsigned long __sanitizer_nfds_t;
614 #endif
615 
616 #if !SANITIZER_ANDROID
617 # if SANITIZER_LINUX
618   struct __sanitizer_glob_t {
619     uptr gl_pathc;
620     char **gl_pathv;
621     uptr gl_offs;
622     int gl_flags;
623 
624     void (*gl_closedir)(void *dirp);
625     void *(*gl_readdir)(void *dirp);
626     void *(*gl_opendir)(const char *);
627     int (*gl_lstat)(const char *, void *);
628     int (*gl_stat)(const char *, void *);
629   };
630 # elif SANITIZER_FREEBSD
631   struct __sanitizer_glob_t {
632     uptr gl_pathc;
633     uptr gl_matchc;
634     uptr gl_offs;
635     int gl_flags;
636     char **gl_pathv;
637     int (*gl_errfunc)(const char*, int);
638     void (*gl_closedir)(void *dirp);
639     struct dirent *(*gl_readdir)(void *dirp);
640     void *(*gl_opendir)(const char*);
641     int (*gl_lstat)(const char*, void* /* struct stat* */);
642     int (*gl_stat)(const char*, void* /* struct stat* */);
643   };
644 # endif  // SANITIZER_FREEBSD
645 
646 # if SANITIZER_LINUX || SANITIZER_FREEBSD
647   extern int glob_nomatch;
648   extern int glob_altdirfunc;
649 # endif
650 #endif  // !SANITIZER_ANDROID
651 
652   extern unsigned path_max;
653 
654   struct __sanitizer_wordexp_t {
655     uptr we_wordc;
656     char **we_wordv;
657     uptr we_offs;
658 #if SANITIZER_FREEBSD
659     char *we_strings;
660     uptr we_nbytes;
661 #endif
662   };
663 
664 #if SANITIZER_LINUX && !SANITIZER_ANDROID
665   struct __sanitizer_FILE {
666     int _flags;
667     char *_IO_read_ptr;
668     char *_IO_read_end;
669     char *_IO_read_base;
670     char *_IO_write_base;
671     char *_IO_write_ptr;
672     char *_IO_write_end;
673     char *_IO_buf_base;
674     char *_IO_buf_end;
675     char *_IO_save_base;
676     char *_IO_backup_base;
677     char *_IO_save_end;
678     void *_markers;
679     __sanitizer_FILE *_chain;
680     int _fileno;
681   };
682 # define SANITIZER_HAS_STRUCT_FILE 1
683 #else
684   typedef void __sanitizer_FILE;
685 # define SANITIZER_HAS_STRUCT_FILE 0
686 #endif
687 
688 #if SANITIZER_LINUX && !SANITIZER_ANDROID && \
689     (defined(__i386) || defined(__x86_64))
690   extern unsigned struct_user_regs_struct_sz;
691   extern unsigned struct_user_fpregs_struct_sz;
692   extern unsigned struct_user_fpxregs_struct_sz;
693 
694   extern int ptrace_peektext;
695   extern int ptrace_peekdata;
696   extern int ptrace_peekuser;
697   extern int ptrace_getregs;
698   extern int ptrace_setregs;
699   extern int ptrace_getfpregs;
700   extern int ptrace_setfpregs;
701   extern int ptrace_getfpxregs;
702   extern int ptrace_setfpxregs;
703   extern int ptrace_getsiginfo;
704   extern int ptrace_setsiginfo;
705   extern int ptrace_getregset;
706   extern int ptrace_setregset;
707   extern int ptrace_geteventmsg;
708 #endif
709 
710 #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
711   extern unsigned struct_shminfo_sz;
712   extern unsigned struct_shm_info_sz;
713   extern int shmctl_ipc_stat;
714   extern int shmctl_ipc_info;
715   extern int shmctl_shm_info;
716   extern int shmctl_shm_stat;
717 #endif
718 
719   extern int map_fixed;
720 
721   // ioctl arguments
722   struct __sanitizer_ifconf {
723     int ifc_len;
724     union {
725       void *ifcu_req;
726     } ifc_ifcu;
727 #if SANITIZER_MAC
728   } __attribute__((packed));
729 #else
730   };
731 #endif
732 
733 #if SANITIZER_LINUX && !SANITIZER_ANDROID
734 struct __sanitizer__obstack_chunk {
735   char *limit;
736   struct __sanitizer__obstack_chunk *prev;
737 };
738 
739 struct __sanitizer_obstack {
740   long chunk_size;
741   struct __sanitizer__obstack_chunk *chunk;
742   char *object_base;
743   char *next_free;
744   uptr more_fields[7];
745 };
746 #endif
747 
748 #define IOC_NRBITS 8
749 #define IOC_TYPEBITS 8
750 #if defined(__powerpc__) || defined(__powerpc64__) || defined(__mips__)
751 #define IOC_SIZEBITS 13
752 #define IOC_DIRBITS 3
753 #define IOC_NONE 1U
754 #define IOC_WRITE 4U
755 #define IOC_READ 2U
756 #else
757 #define IOC_SIZEBITS 14
758 #define IOC_DIRBITS 2
759 #define IOC_NONE 0U
760 #define IOC_WRITE 1U
761 #define IOC_READ 2U
762 #endif
763 #define IOC_NRMASK ((1 << IOC_NRBITS) - 1)
764 #define IOC_TYPEMASK ((1 << IOC_TYPEBITS) - 1)
765 #define IOC_SIZEMASK ((1 << IOC_SIZEBITS) - 1)
766 #if defined(IOC_DIRMASK)
767 #undef IOC_DIRMASK
768 #endif
769 #define IOC_DIRMASK ((1 << IOC_DIRBITS) - 1)
770 #define IOC_NRSHIFT 0
771 #define IOC_TYPESHIFT (IOC_NRSHIFT + IOC_NRBITS)
772 #define IOC_SIZESHIFT (IOC_TYPESHIFT + IOC_TYPEBITS)
773 #define IOC_DIRSHIFT (IOC_SIZESHIFT + IOC_SIZEBITS)
774 #define EVIOC_EV_MAX 0x1f
775 #define EVIOC_ABS_MAX 0x3f
776 
777 #define IOC_DIR(nr) (((nr) >> IOC_DIRSHIFT) & IOC_DIRMASK)
778 #define IOC_TYPE(nr) (((nr) >> IOC_TYPESHIFT) & IOC_TYPEMASK)
779 #define IOC_NR(nr) (((nr) >> IOC_NRSHIFT) & IOC_NRMASK)
780 #define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK)
781 
782   extern unsigned struct_arpreq_sz;
783   extern unsigned struct_ifreq_sz;
784   extern unsigned struct_termios_sz;
785   extern unsigned struct_winsize_sz;
786 
787 #if SANITIZER_LINUX
788   extern unsigned struct_cdrom_msf_sz;
789   extern unsigned struct_cdrom_multisession_sz;
790   extern unsigned struct_cdrom_read_audio_sz;
791   extern unsigned struct_cdrom_subchnl_sz;
792   extern unsigned struct_cdrom_ti_sz;
793   extern unsigned struct_cdrom_tocentry_sz;
794   extern unsigned struct_cdrom_tochdr_sz;
795   extern unsigned struct_cdrom_volctrl_sz;
796   extern unsigned struct_ff_effect_sz;
797   extern unsigned struct_floppy_drive_params_sz;
798   extern unsigned struct_floppy_drive_struct_sz;
799   extern unsigned struct_floppy_fdc_state_sz;
800   extern unsigned struct_floppy_max_errors_sz;
801   extern unsigned struct_floppy_raw_cmd_sz;
802   extern unsigned struct_floppy_struct_sz;
803   extern unsigned struct_floppy_write_errors_sz;
804   extern unsigned struct_format_descr_sz;
805   extern unsigned struct_hd_driveid_sz;
806   extern unsigned struct_hd_geometry_sz;
807   extern unsigned struct_input_absinfo_sz;
808   extern unsigned struct_input_id_sz;
809   extern unsigned struct_mtpos_sz;
810   extern unsigned struct_termio_sz;
811   extern unsigned struct_vt_consize_sz;
812   extern unsigned struct_vt_sizes_sz;
813   extern unsigned struct_vt_stat_sz;
814 #endif  // SANITIZER_LINUX
815 
816 #if SANITIZER_LINUX || SANITIZER_FREEBSD
817   extern unsigned struct_copr_buffer_sz;
818   extern unsigned struct_copr_debug_buf_sz;
819   extern unsigned struct_copr_msg_sz;
820   extern unsigned struct_midi_info_sz;
821   extern unsigned struct_mtget_sz;
822   extern unsigned struct_mtop_sz;
823   extern unsigned struct_rtentry_sz;
824   extern unsigned struct_sbi_instrument_sz;
825   extern unsigned struct_seq_event_rec_sz;
826   extern unsigned struct_synth_info_sz;
827   extern unsigned struct_vt_mode_sz;
828 #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
829 
830 #if SANITIZER_LINUX && !SANITIZER_ANDROID
831   extern unsigned struct_ax25_parms_struct_sz;
832   extern unsigned struct_cyclades_monitor_sz;
833   extern unsigned struct_input_keymap_entry_sz;
834   extern unsigned struct_ipx_config_data_sz;
835   extern unsigned struct_kbdiacrs_sz;
836   extern unsigned struct_kbentry_sz;
837   extern unsigned struct_kbkeycode_sz;
838   extern unsigned struct_kbsentry_sz;
839   extern unsigned struct_mtconfiginfo_sz;
840   extern unsigned struct_nr_parms_struct_sz;
841   extern unsigned struct_scc_modem_sz;
842   extern unsigned struct_scc_stat_sz;
843   extern unsigned struct_serial_multiport_struct_sz;
844   extern unsigned struct_serial_struct_sz;
845   extern unsigned struct_sockaddr_ax25_sz;
846   extern unsigned struct_unimapdesc_sz;
847   extern unsigned struct_unimapinit_sz;
848 #endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
849 
850 #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
851   extern unsigned struct_audio_buf_info_sz;
852   extern unsigned struct_ppp_stats_sz;
853 #endif  // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
854 
855 #if !SANITIZER_ANDROID && !SANITIZER_MAC
856   extern unsigned struct_sioc_sg_req_sz;
857   extern unsigned struct_sioc_vif_req_sz;
858 #endif
859 
860   // ioctl request identifiers
861 
862   // A special value to mark ioctls that are not present on the target platform,
863   // when it can not be determined without including any system headers.
864   extern unsigned IOCTL_NOT_PRESENT;
865 
866   extern unsigned IOCTL_FIOASYNC;
867   extern unsigned IOCTL_FIOCLEX;
868   extern unsigned IOCTL_FIOGETOWN;
869   extern unsigned IOCTL_FIONBIO;
870   extern unsigned IOCTL_FIONCLEX;
871   extern unsigned IOCTL_FIOSETOWN;
872   extern unsigned IOCTL_SIOCADDMULTI;
873   extern unsigned IOCTL_SIOCATMARK;
874   extern unsigned IOCTL_SIOCDELMULTI;
875   extern unsigned IOCTL_SIOCGIFADDR;
876   extern unsigned IOCTL_SIOCGIFBRDADDR;
877   extern unsigned IOCTL_SIOCGIFCONF;
878   extern unsigned IOCTL_SIOCGIFDSTADDR;
879   extern unsigned IOCTL_SIOCGIFFLAGS;
880   extern unsigned IOCTL_SIOCGIFMETRIC;
881   extern unsigned IOCTL_SIOCGIFMTU;
882   extern unsigned IOCTL_SIOCGIFNETMASK;
883   extern unsigned IOCTL_SIOCGPGRP;
884   extern unsigned IOCTL_SIOCSIFADDR;
885   extern unsigned IOCTL_SIOCSIFBRDADDR;
886   extern unsigned IOCTL_SIOCSIFDSTADDR;
887   extern unsigned IOCTL_SIOCSIFFLAGS;
888   extern unsigned IOCTL_SIOCSIFMETRIC;
889   extern unsigned IOCTL_SIOCSIFMTU;
890   extern unsigned IOCTL_SIOCSIFNETMASK;
891   extern unsigned IOCTL_SIOCSPGRP;
892   extern unsigned IOCTL_TIOCCONS;
893   extern unsigned IOCTL_TIOCEXCL;
894   extern unsigned IOCTL_TIOCGETD;
895   extern unsigned IOCTL_TIOCGPGRP;
896   extern unsigned IOCTL_TIOCGWINSZ;
897   extern unsigned IOCTL_TIOCMBIC;
898   extern unsigned IOCTL_TIOCMBIS;
899   extern unsigned IOCTL_TIOCMGET;
900   extern unsigned IOCTL_TIOCMSET;
901   extern unsigned IOCTL_TIOCNOTTY;
902   extern unsigned IOCTL_TIOCNXCL;
903   extern unsigned IOCTL_TIOCOUTQ;
904   extern unsigned IOCTL_TIOCPKT;
905   extern unsigned IOCTL_TIOCSCTTY;
906   extern unsigned IOCTL_TIOCSETD;
907   extern unsigned IOCTL_TIOCSPGRP;
908   extern unsigned IOCTL_TIOCSTI;
909   extern unsigned IOCTL_TIOCSWINSZ;
910 #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
911   extern unsigned IOCTL_SIOCGETSGCNT;
912   extern unsigned IOCTL_SIOCGETVIFCNT;
913 #endif
914 #if SANITIZER_LINUX
915   extern unsigned IOCTL_EVIOCGABS;
916   extern unsigned IOCTL_EVIOCGBIT;
917   extern unsigned IOCTL_EVIOCGEFFECTS;
918   extern unsigned IOCTL_EVIOCGID;
919   extern unsigned IOCTL_EVIOCGKEY;
920   extern unsigned IOCTL_EVIOCGKEYCODE;
921   extern unsigned IOCTL_EVIOCGLED;
922   extern unsigned IOCTL_EVIOCGNAME;
923   extern unsigned IOCTL_EVIOCGPHYS;
924   extern unsigned IOCTL_EVIOCGRAB;
925   extern unsigned IOCTL_EVIOCGREP;
926   extern unsigned IOCTL_EVIOCGSND;
927   extern unsigned IOCTL_EVIOCGSW;
928   extern unsigned IOCTL_EVIOCGUNIQ;
929   extern unsigned IOCTL_EVIOCGVERSION;
930   extern unsigned IOCTL_EVIOCRMFF;
931   extern unsigned IOCTL_EVIOCSABS;
932   extern unsigned IOCTL_EVIOCSFF;
933   extern unsigned IOCTL_EVIOCSKEYCODE;
934   extern unsigned IOCTL_EVIOCSREP;
935   extern unsigned IOCTL_BLKFLSBUF;
936   extern unsigned IOCTL_BLKGETSIZE;
937   extern unsigned IOCTL_BLKRAGET;
938   extern unsigned IOCTL_BLKRASET;
939   extern unsigned IOCTL_BLKROGET;
940   extern unsigned IOCTL_BLKROSET;
941   extern unsigned IOCTL_BLKRRPART;
942   extern unsigned IOCTL_CDROMAUDIOBUFSIZ;
943   extern unsigned IOCTL_CDROMEJECT;
944   extern unsigned IOCTL_CDROMEJECT_SW;
945   extern unsigned IOCTL_CDROMMULTISESSION;
946   extern unsigned IOCTL_CDROMPAUSE;
947   extern unsigned IOCTL_CDROMPLAYMSF;
948   extern unsigned IOCTL_CDROMPLAYTRKIND;
949   extern unsigned IOCTL_CDROMREADAUDIO;
950   extern unsigned IOCTL_CDROMREADCOOKED;
951   extern unsigned IOCTL_CDROMREADMODE1;
952   extern unsigned IOCTL_CDROMREADMODE2;
953   extern unsigned IOCTL_CDROMREADRAW;
954   extern unsigned IOCTL_CDROMREADTOCENTRY;
955   extern unsigned IOCTL_CDROMREADTOCHDR;
956   extern unsigned IOCTL_CDROMRESET;
957   extern unsigned IOCTL_CDROMRESUME;
958   extern unsigned IOCTL_CDROMSEEK;
959   extern unsigned IOCTL_CDROMSTART;
960   extern unsigned IOCTL_CDROMSTOP;
961   extern unsigned IOCTL_CDROMSUBCHNL;
962   extern unsigned IOCTL_CDROMVOLCTRL;
963   extern unsigned IOCTL_CDROMVOLREAD;
964   extern unsigned IOCTL_CDROM_GET_UPC;
965   extern unsigned IOCTL_FDCLRPRM;
966   extern unsigned IOCTL_FDDEFPRM;
967   extern unsigned IOCTL_FDFLUSH;
968   extern unsigned IOCTL_FDFMTBEG;
969   extern unsigned IOCTL_FDFMTEND;
970   extern unsigned IOCTL_FDFMTTRK;
971   extern unsigned IOCTL_FDGETDRVPRM;
972   extern unsigned IOCTL_FDGETDRVSTAT;
973   extern unsigned IOCTL_FDGETDRVTYP;
974   extern unsigned IOCTL_FDGETFDCSTAT;
975   extern unsigned IOCTL_FDGETMAXERRS;
976   extern unsigned IOCTL_FDGETPRM;
977   extern unsigned IOCTL_FDMSGOFF;
978   extern unsigned IOCTL_FDMSGON;
979   extern unsigned IOCTL_FDPOLLDRVSTAT;
980   extern unsigned IOCTL_FDRAWCMD;
981   extern unsigned IOCTL_FDRESET;
982   extern unsigned IOCTL_FDSETDRVPRM;
983   extern unsigned IOCTL_FDSETEMSGTRESH;
984   extern unsigned IOCTL_FDSETMAXERRS;
985   extern unsigned IOCTL_FDSETPRM;
986   extern unsigned IOCTL_FDTWADDLE;
987   extern unsigned IOCTL_FDWERRORCLR;
988   extern unsigned IOCTL_FDWERRORGET;
989   extern unsigned IOCTL_HDIO_DRIVE_CMD;
990   extern unsigned IOCTL_HDIO_GETGEO;
991   extern unsigned IOCTL_HDIO_GET_32BIT;
992   extern unsigned IOCTL_HDIO_GET_DMA;
993   extern unsigned IOCTL_HDIO_GET_IDENTITY;
994   extern unsigned IOCTL_HDIO_GET_KEEPSETTINGS;
995   extern unsigned IOCTL_HDIO_GET_MULTCOUNT;
996   extern unsigned IOCTL_HDIO_GET_NOWERR;
997   extern unsigned IOCTL_HDIO_GET_UNMASKINTR;
998   extern unsigned IOCTL_HDIO_SET_32BIT;
999   extern unsigned IOCTL_HDIO_SET_DMA;
1000   extern unsigned IOCTL_HDIO_SET_KEEPSETTINGS;
1001   extern unsigned IOCTL_HDIO_SET_MULTCOUNT;
1002   extern unsigned IOCTL_HDIO_SET_NOWERR;
1003   extern unsigned IOCTL_HDIO_SET_UNMASKINTR;
1004   extern unsigned IOCTL_MTIOCPOS;
1005   extern unsigned IOCTL_PPPIOCGASYNCMAP;
1006   extern unsigned IOCTL_PPPIOCGDEBUG;
1007   extern unsigned IOCTL_PPPIOCGFLAGS;
1008   extern unsigned IOCTL_PPPIOCGUNIT;
1009   extern unsigned IOCTL_PPPIOCGXASYNCMAP;
1010   extern unsigned IOCTL_PPPIOCSASYNCMAP;
1011   extern unsigned IOCTL_PPPIOCSDEBUG;
1012   extern unsigned IOCTL_PPPIOCSFLAGS;
1013   extern unsigned IOCTL_PPPIOCSMAXCID;
1014   extern unsigned IOCTL_PPPIOCSMRU;
1015   extern unsigned IOCTL_PPPIOCSXASYNCMAP;
1016   extern unsigned IOCTL_SIOCDARP;
1017   extern unsigned IOCTL_SIOCDRARP;
1018   extern unsigned IOCTL_SIOCGARP;
1019   extern unsigned IOCTL_SIOCGIFENCAP;
1020   extern unsigned IOCTL_SIOCGIFHWADDR;
1021   extern unsigned IOCTL_SIOCGIFMAP;
1022   extern unsigned IOCTL_SIOCGIFMEM;
1023   extern unsigned IOCTL_SIOCGIFNAME;
1024   extern unsigned IOCTL_SIOCGIFSLAVE;
1025   extern unsigned IOCTL_SIOCGRARP;
1026   extern unsigned IOCTL_SIOCGSTAMP;
1027   extern unsigned IOCTL_SIOCSARP;
1028   extern unsigned IOCTL_SIOCSIFENCAP;
1029   extern unsigned IOCTL_SIOCSIFHWADDR;
1030   extern unsigned IOCTL_SIOCSIFLINK;
1031   extern unsigned IOCTL_SIOCSIFMAP;
1032   extern unsigned IOCTL_SIOCSIFMEM;
1033   extern unsigned IOCTL_SIOCSIFSLAVE;
1034   extern unsigned IOCTL_SIOCSRARP;
1035   extern unsigned IOCTL_SNDCTL_COPR_HALT;
1036   extern unsigned IOCTL_SNDCTL_COPR_LOAD;
1037   extern unsigned IOCTL_SNDCTL_COPR_RCODE;
1038   extern unsigned IOCTL_SNDCTL_COPR_RCVMSG;
1039   extern unsigned IOCTL_SNDCTL_COPR_RDATA;
1040   extern unsigned IOCTL_SNDCTL_COPR_RESET;
1041   extern unsigned IOCTL_SNDCTL_COPR_RUN;
1042   extern unsigned IOCTL_SNDCTL_COPR_SENDMSG;
1043   extern unsigned IOCTL_SNDCTL_COPR_WCODE;
1044   extern unsigned IOCTL_SNDCTL_COPR_WDATA;
1045   extern unsigned IOCTL_TCFLSH;
1046   extern unsigned IOCTL_TCGETA;
1047   extern unsigned IOCTL_TCGETS;
1048   extern unsigned IOCTL_TCSBRK;
1049   extern unsigned IOCTL_TCSBRKP;
1050   extern unsigned IOCTL_TCSETA;
1051   extern unsigned IOCTL_TCSETAF;
1052   extern unsigned IOCTL_TCSETAW;
1053   extern unsigned IOCTL_TCSETS;
1054   extern unsigned IOCTL_TCSETSF;
1055   extern unsigned IOCTL_TCSETSW;
1056   extern unsigned IOCTL_TCXONC;
1057   extern unsigned IOCTL_TIOCGLCKTRMIOS;
1058   extern unsigned IOCTL_TIOCGSOFTCAR;
1059   extern unsigned IOCTL_TIOCINQ;
1060   extern unsigned IOCTL_TIOCLINUX;
1061   extern unsigned IOCTL_TIOCSERCONFIG;
1062   extern unsigned IOCTL_TIOCSERGETLSR;
1063   extern unsigned IOCTL_TIOCSERGWILD;
1064   extern unsigned IOCTL_TIOCSERSWILD;
1065   extern unsigned IOCTL_TIOCSLCKTRMIOS;
1066   extern unsigned IOCTL_TIOCSSOFTCAR;
1067   extern unsigned IOCTL_VT_DISALLOCATE;
1068   extern unsigned IOCTL_VT_GETSTATE;
1069   extern unsigned IOCTL_VT_RESIZE;
1070   extern unsigned IOCTL_VT_RESIZEX;
1071   extern unsigned IOCTL_VT_SENDSIG;
1072 #endif  // SANITIZER_LINUX
1073 #if SANITIZER_LINUX || SANITIZER_FREEBSD
1074   extern unsigned IOCTL_MTIOCGET;
1075   extern unsigned IOCTL_MTIOCTOP;
1076   extern unsigned IOCTL_SIOCADDRT;
1077   extern unsigned IOCTL_SIOCDELRT;
1078   extern unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE;
1079   extern unsigned IOCTL_SNDCTL_DSP_GETFMTS;
1080   extern unsigned IOCTL_SNDCTL_DSP_NONBLOCK;
1081   extern unsigned IOCTL_SNDCTL_DSP_POST;
1082   extern unsigned IOCTL_SNDCTL_DSP_RESET;
1083   extern unsigned IOCTL_SNDCTL_DSP_SETFMT;
1084   extern unsigned IOCTL_SNDCTL_DSP_SETFRAGMENT;
1085   extern unsigned IOCTL_SNDCTL_DSP_SPEED;
1086   extern unsigned IOCTL_SNDCTL_DSP_STEREO;
1087   extern unsigned IOCTL_SNDCTL_DSP_SUBDIVIDE;
1088   extern unsigned IOCTL_SNDCTL_DSP_SYNC;
1089   extern unsigned IOCTL_SNDCTL_FM_4OP_ENABLE;
1090   extern unsigned IOCTL_SNDCTL_FM_LOAD_INSTR;
1091   extern unsigned IOCTL_SNDCTL_MIDI_INFO;
1092   extern unsigned IOCTL_SNDCTL_MIDI_PRETIME;
1093   extern unsigned IOCTL_SNDCTL_SEQ_CTRLRATE;
1094   extern unsigned IOCTL_SNDCTL_SEQ_GETINCOUNT;
1095   extern unsigned IOCTL_SNDCTL_SEQ_GETOUTCOUNT;
1096   extern unsigned IOCTL_SNDCTL_SEQ_NRMIDIS;
1097   extern unsigned IOCTL_SNDCTL_SEQ_NRSYNTHS;
1098   extern unsigned IOCTL_SNDCTL_SEQ_OUTOFBAND;
1099   extern unsigned IOCTL_SNDCTL_SEQ_PANIC;
1100   extern unsigned IOCTL_SNDCTL_SEQ_PERCMODE;
1101   extern unsigned IOCTL_SNDCTL_SEQ_RESET;
1102   extern unsigned IOCTL_SNDCTL_SEQ_RESETSAMPLES;
1103   extern unsigned IOCTL_SNDCTL_SEQ_SYNC;
1104   extern unsigned IOCTL_SNDCTL_SEQ_TESTMIDI;
1105   extern unsigned IOCTL_SNDCTL_SEQ_THRESHOLD;
1106   extern unsigned IOCTL_SNDCTL_SYNTH_INFO;
1107   extern unsigned IOCTL_SNDCTL_SYNTH_MEMAVL;
1108   extern unsigned IOCTL_SNDCTL_TMR_CONTINUE;
1109   extern unsigned IOCTL_SNDCTL_TMR_METRONOME;
1110   extern unsigned IOCTL_SNDCTL_TMR_SELECT;
1111   extern unsigned IOCTL_SNDCTL_TMR_SOURCE;
1112   extern unsigned IOCTL_SNDCTL_TMR_START;
1113   extern unsigned IOCTL_SNDCTL_TMR_STOP;
1114   extern unsigned IOCTL_SNDCTL_TMR_TEMPO;
1115   extern unsigned IOCTL_SNDCTL_TMR_TIMEBASE;
1116   extern unsigned IOCTL_SOUND_MIXER_READ_ALTPCM;
1117   extern unsigned IOCTL_SOUND_MIXER_READ_BASS;
1118   extern unsigned IOCTL_SOUND_MIXER_READ_CAPS;
1119   extern unsigned IOCTL_SOUND_MIXER_READ_CD;
1120   extern unsigned IOCTL_SOUND_MIXER_READ_DEVMASK;
1121   extern unsigned IOCTL_SOUND_MIXER_READ_ENHANCE;
1122   extern unsigned IOCTL_SOUND_MIXER_READ_IGAIN;
1123   extern unsigned IOCTL_SOUND_MIXER_READ_IMIX;
1124   extern unsigned IOCTL_SOUND_MIXER_READ_LINE1;
1125   extern unsigned IOCTL_SOUND_MIXER_READ_LINE2;
1126   extern unsigned IOCTL_SOUND_MIXER_READ_LINE3;
1127   extern unsigned IOCTL_SOUND_MIXER_READ_LINE;
1128   extern unsigned IOCTL_SOUND_MIXER_READ_LOUD;
1129   extern unsigned IOCTL_SOUND_MIXER_READ_MIC;
1130   extern unsigned IOCTL_SOUND_MIXER_READ_MUTE;
1131   extern unsigned IOCTL_SOUND_MIXER_READ_OGAIN;
1132   extern unsigned IOCTL_SOUND_MIXER_READ_PCM;
1133   extern unsigned IOCTL_SOUND_MIXER_READ_RECLEV;
1134   extern unsigned IOCTL_SOUND_MIXER_READ_RECMASK;
1135   extern unsigned IOCTL_SOUND_MIXER_READ_RECSRC;
1136   extern unsigned IOCTL_SOUND_MIXER_READ_SPEAKER;
1137   extern unsigned IOCTL_SOUND_MIXER_READ_STEREODEVS;
1138   extern unsigned IOCTL_SOUND_MIXER_READ_SYNTH;
1139   extern unsigned IOCTL_SOUND_MIXER_READ_TREBLE;
1140   extern unsigned IOCTL_SOUND_MIXER_READ_VOLUME;
1141   extern unsigned IOCTL_SOUND_MIXER_WRITE_ALTPCM;
1142   extern unsigned IOCTL_SOUND_MIXER_WRITE_BASS;
1143   extern unsigned IOCTL_SOUND_MIXER_WRITE_CD;
1144   extern unsigned IOCTL_SOUND_MIXER_WRITE_ENHANCE;
1145   extern unsigned IOCTL_SOUND_MIXER_WRITE_IGAIN;
1146   extern unsigned IOCTL_SOUND_MIXER_WRITE_IMIX;
1147   extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE1;
1148   extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE2;
1149   extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE3;
1150   extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE;
1151   extern unsigned IOCTL_SOUND_MIXER_WRITE_LOUD;
1152   extern unsigned IOCTL_SOUND_MIXER_WRITE_MIC;
1153   extern unsigned IOCTL_SOUND_MIXER_WRITE_MUTE;
1154   extern unsigned IOCTL_SOUND_MIXER_WRITE_OGAIN;
1155   extern unsigned IOCTL_SOUND_MIXER_WRITE_PCM;
1156   extern unsigned IOCTL_SOUND_MIXER_WRITE_RECLEV;
1157   extern unsigned IOCTL_SOUND_MIXER_WRITE_RECSRC;
1158   extern unsigned IOCTL_SOUND_MIXER_WRITE_SPEAKER;
1159   extern unsigned IOCTL_SOUND_MIXER_WRITE_SYNTH;
1160   extern unsigned IOCTL_SOUND_MIXER_WRITE_TREBLE;
1161   extern unsigned IOCTL_SOUND_MIXER_WRITE_VOLUME;
1162   extern unsigned IOCTL_SOUND_PCM_READ_BITS;
1163   extern unsigned IOCTL_SOUND_PCM_READ_CHANNELS;
1164   extern unsigned IOCTL_SOUND_PCM_READ_FILTER;
1165   extern unsigned IOCTL_SOUND_PCM_READ_RATE;
1166   extern unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS;
1167   extern unsigned IOCTL_SOUND_PCM_WRITE_FILTER;
1168   extern unsigned IOCTL_VT_ACTIVATE;
1169   extern unsigned IOCTL_VT_GETMODE;
1170   extern unsigned IOCTL_VT_OPENQRY;
1171   extern unsigned IOCTL_VT_RELDISP;
1172   extern unsigned IOCTL_VT_SETMODE;
1173   extern unsigned IOCTL_VT_WAITACTIVE;
1174 #endif  // SANITIZER_LINUX || SANITIZER_FREEBSD
1175 
1176 #if SANITIZER_LINUX && !SANITIZER_ANDROID
1177   extern unsigned IOCTL_CYGETDEFTHRESH;
1178   extern unsigned IOCTL_CYGETDEFTIMEOUT;
1179   extern unsigned IOCTL_CYGETMON;
1180   extern unsigned IOCTL_CYGETTHRESH;
1181   extern unsigned IOCTL_CYGETTIMEOUT;
1182   extern unsigned IOCTL_CYSETDEFTHRESH;
1183   extern unsigned IOCTL_CYSETDEFTIMEOUT;
1184   extern unsigned IOCTL_CYSETTHRESH;
1185   extern unsigned IOCTL_CYSETTIMEOUT;
1186   extern unsigned IOCTL_EQL_EMANCIPATE;
1187   extern unsigned IOCTL_EQL_ENSLAVE;
1188   extern unsigned IOCTL_EQL_GETMASTRCFG;
1189   extern unsigned IOCTL_EQL_GETSLAVECFG;
1190   extern unsigned IOCTL_EQL_SETMASTRCFG;
1191   extern unsigned IOCTL_EQL_SETSLAVECFG;
1192   extern unsigned IOCTL_EVIOCGKEYCODE_V2;
1193   extern unsigned IOCTL_EVIOCGPROP;
1194   extern unsigned IOCTL_EVIOCSKEYCODE_V2;
1195   extern unsigned IOCTL_FS_IOC_GETFLAGS;
1196   extern unsigned IOCTL_FS_IOC_GETVERSION;
1197   extern unsigned IOCTL_FS_IOC_SETFLAGS;
1198   extern unsigned IOCTL_FS_IOC_SETVERSION;
1199   extern unsigned IOCTL_GIO_CMAP;
1200   extern unsigned IOCTL_GIO_FONT;
1201   extern unsigned IOCTL_GIO_UNIMAP;
1202   extern unsigned IOCTL_GIO_UNISCRNMAP;
1203   extern unsigned IOCTL_KDADDIO;
1204   extern unsigned IOCTL_KDDELIO;
1205   extern unsigned IOCTL_KDGETKEYCODE;
1206   extern unsigned IOCTL_KDGKBDIACR;
1207   extern unsigned IOCTL_KDGKBENT;
1208   extern unsigned IOCTL_KDGKBLED;
1209   extern unsigned IOCTL_KDGKBMETA;
1210   extern unsigned IOCTL_KDGKBSENT;
1211   extern unsigned IOCTL_KDMAPDISP;
1212   extern unsigned IOCTL_KDSETKEYCODE;
1213   extern unsigned IOCTL_KDSIGACCEPT;
1214   extern unsigned IOCTL_KDSKBDIACR;
1215   extern unsigned IOCTL_KDSKBENT;
1216   extern unsigned IOCTL_KDSKBLED;
1217   extern unsigned IOCTL_KDSKBMETA;
1218   extern unsigned IOCTL_KDSKBSENT;
1219   extern unsigned IOCTL_KDUNMAPDISP;
1220   extern unsigned IOCTL_LPABORT;
1221   extern unsigned IOCTL_LPABORTOPEN;
1222   extern unsigned IOCTL_LPCAREFUL;
1223   extern unsigned IOCTL_LPCHAR;
1224   extern unsigned IOCTL_LPGETIRQ;
1225   extern unsigned IOCTL_LPGETSTATUS;
1226   extern unsigned IOCTL_LPRESET;
1227   extern unsigned IOCTL_LPSETIRQ;
1228   extern unsigned IOCTL_LPTIME;
1229   extern unsigned IOCTL_LPWAIT;
1230   extern unsigned IOCTL_MTIOCGETCONFIG;
1231   extern unsigned IOCTL_MTIOCSETCONFIG;
1232   extern unsigned IOCTL_PIO_CMAP;
1233   extern unsigned IOCTL_PIO_FONT;
1234   extern unsigned IOCTL_PIO_UNIMAP;
1235   extern unsigned IOCTL_PIO_UNIMAPCLR;
1236   extern unsigned IOCTL_PIO_UNISCRNMAP;
1237   extern unsigned IOCTL_SCSI_IOCTL_GET_IDLUN;
1238   extern unsigned IOCTL_SCSI_IOCTL_PROBE_HOST;
1239   extern unsigned IOCTL_SCSI_IOCTL_TAGGED_DISABLE;
1240   extern unsigned IOCTL_SCSI_IOCTL_TAGGED_ENABLE;
1241   extern unsigned IOCTL_SIOCAIPXITFCRT;
1242   extern unsigned IOCTL_SIOCAIPXPRISLT;
1243   extern unsigned IOCTL_SIOCAX25ADDUID;
1244   extern unsigned IOCTL_SIOCAX25DELUID;
1245   extern unsigned IOCTL_SIOCAX25GETPARMS;
1246   extern unsigned IOCTL_SIOCAX25GETUID;
1247   extern unsigned IOCTL_SIOCAX25NOUID;
1248   extern unsigned IOCTL_SIOCAX25SETPARMS;
1249   extern unsigned IOCTL_SIOCDEVPLIP;
1250   extern unsigned IOCTL_SIOCIPXCFGDATA;
1251   extern unsigned IOCTL_SIOCNRDECOBS;
1252   extern unsigned IOCTL_SIOCNRGETPARMS;
1253   extern unsigned IOCTL_SIOCNRRTCTL;
1254   extern unsigned IOCTL_SIOCNRSETPARMS;
1255   extern unsigned IOCTL_SNDCTL_DSP_GETISPACE;
1256   extern unsigned IOCTL_SNDCTL_DSP_GETOSPACE;
1257   extern unsigned IOCTL_TIOCGSERIAL;
1258   extern unsigned IOCTL_TIOCSERGETMULTI;
1259   extern unsigned IOCTL_TIOCSERSETMULTI;
1260   extern unsigned IOCTL_TIOCSSERIAL;
1261 #endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
1262 
1263 #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
1264   extern unsigned IOCTL_GIO_SCRNMAP;
1265   extern unsigned IOCTL_KDDISABIO;
1266   extern unsigned IOCTL_KDENABIO;
1267   extern unsigned IOCTL_KDGETLED;
1268   extern unsigned IOCTL_KDGETMODE;
1269   extern unsigned IOCTL_KDGKBMODE;
1270   extern unsigned IOCTL_KDGKBTYPE;
1271   extern unsigned IOCTL_KDMKTONE;
1272   extern unsigned IOCTL_KDSETLED;
1273   extern unsigned IOCTL_KDSETMODE;
1274   extern unsigned IOCTL_KDSKBMODE;
1275   extern unsigned IOCTL_KIOCSOUND;
1276   extern unsigned IOCTL_PIO_SCRNMAP;
1277 #endif
1278 
1279   extern const int errno_EINVAL;
1280   extern const int errno_EOWNERDEAD;
1281 
1282   extern const int si_SEGV_MAPERR;
1283   extern const int si_SEGV_ACCERR;
1284 }  // namespace __sanitizer
1285 
1286 #define CHECK_TYPE_SIZE(TYPE) \
1287   COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
1288 
1289 #define CHECK_SIZE_AND_OFFSET(CLASS, MEMBER)                       \
1290   COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *) NULL)->MEMBER) == \
1291                  sizeof(((CLASS *) NULL)->MEMBER));                \
1292   COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==          \
1293                  offsetof(CLASS, MEMBER))
1294 
1295 // For sigaction, which is a function and struct at the same time,
1296 // and thus requires explicit "struct" in sizeof() expression.
1297 #define CHECK_STRUCT_SIZE_AND_OFFSET(CLASS, MEMBER)                       \
1298   COMPILER_CHECK(sizeof(((struct __sanitizer_##CLASS *) NULL)->MEMBER) == \
1299                  sizeof(((struct CLASS *) NULL)->MEMBER));                \
1300   COMPILER_CHECK(offsetof(struct __sanitizer_##CLASS, MEMBER) ==          \
1301                  offsetof(struct CLASS, MEMBER))
1302 
1303 #endif
1304