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