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