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