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