[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / compiler-rt / lib / sanitizer_common / sanitizer_platform_limits_posix.h
blob7d98f8e9a9d801238c50e0381b8c283ee07aea6b
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"
21 #include "sanitizer_mallinfo.h"
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
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
42 # define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) ((link_map*)(handle))
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;
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
80 # if SANITIZER_LINUX
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.
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;
144 const unsigned struct_kexec_segment_sz = 4 * sizeof(unsigned long);
145 #endif // SANITIZER_LINUX
147 #if SANITIZER_LINUX
149 #if defined(__powerpc64__) || defined(__s390__) || defined(__loongarch__)
150 const unsigned struct___old_kernel_stat_sz = 0;
151 #elif !defined(__sparc__)
152 const unsigned struct___old_kernel_stat_sz = 32;
153 #endif
155 extern unsigned struct_rlimit_sz;
156 extern unsigned struct_utimbuf_sz;
157 extern unsigned struct_timespec_sz;
159 struct __sanitizer_iocb {
160 u64 aio_data;
161 u32 aio_key_or_aio_reserved1; // Simply crazy.
162 u32 aio_reserved1_or_aio_key; // Luckily, we don't need these.
163 u16 aio_lio_opcode;
164 s16 aio_reqprio;
165 u32 aio_fildes;
166 u64 aio_buf;
167 u64 aio_nbytes;
168 s64 aio_offset;
169 u64 aio_reserved2;
170 u64 aio_reserved3;
173 struct __sanitizer_io_event {
174 u64 data;
175 u64 obj;
176 u64 res;
177 u64 res2;
180 const unsigned iocb_cmd_pread = 0;
181 const unsigned iocb_cmd_pwrite = 1;
182 const unsigned iocb_cmd_preadv = 7;
183 const unsigned iocb_cmd_pwritev = 8;
185 struct __sanitizer___sysctl_args {
186 int *name;
187 int nlen;
188 void *oldval;
189 uptr *oldlenp;
190 void *newval;
191 uptr newlen;
192 unsigned long ___unused[4];
195 const unsigned old_sigset_t_sz = sizeof(unsigned long);
197 struct __sanitizer_sem_t {
198 #if SANITIZER_ANDROID && defined(_LP64)
199 int data[4];
200 #elif SANITIZER_ANDROID && !defined(_LP64)
201 int data;
202 #elif SANITIZER_LINUX
203 uptr data[4];
204 #endif
206 #endif // SANITIZER_LINUX
208 #if SANITIZER_LINUX && !SANITIZER_ANDROID
209 extern unsigned struct_ustat_sz;
210 extern unsigned struct_rlimit64_sz;
211 extern unsigned struct_statvfs64_sz;
213 struct __sanitizer_ipc_perm {
214 int __key;
215 int uid;
216 int gid;
217 int cuid;
218 int cgid;
219 #ifdef __powerpc__
220 unsigned mode;
221 unsigned __seq;
222 u64 __unused1;
223 u64 __unused2;
224 #elif defined(__sparc__)
225 unsigned mode;
226 unsigned short __pad2;
227 unsigned short __seq;
228 unsigned long long __unused1;
229 unsigned long long __unused2;
230 #else
231 unsigned int mode;
232 unsigned short __seq;
233 unsigned short __pad2;
234 #if defined(__x86_64__) && !defined(_LP64)
235 u64 __unused1;
236 u64 __unused2;
237 #else
238 unsigned long __unused1;
239 unsigned long __unused2;
240 #endif
241 #endif
244 struct __sanitizer_shmid_ds {
245 __sanitizer_ipc_perm shm_perm;
246 #if defined(__sparc__)
247 #if !defined(__arch64__)
248 u32 __pad1;
249 #endif
250 long shm_atime;
251 #if !defined(__arch64__)
252 u32 __pad2;
253 #endif
254 long shm_dtime;
255 #if !defined(__arch64__)
256 u32 __pad3;
257 #endif
258 long shm_ctime;
259 uptr shm_segsz;
260 int shm_cpid;
261 int shm_lpid;
262 unsigned long shm_nattch;
263 unsigned long __glibc_reserved1;
264 unsigned long __glibc_reserved2;
265 #else
266 #ifndef __powerpc__
267 uptr shm_segsz;
268 #elif !defined(__powerpc64__)
269 uptr __unused0;
270 #endif
271 #if defined(__x86_64__) && !defined(_LP64)
272 u64 shm_atime;
273 u64 shm_dtime;
274 u64 shm_ctime;
275 #else
276 uptr shm_atime;
277 #if !defined(_LP64) && !defined(__mips__)
278 uptr __unused1;
279 #endif
280 uptr shm_dtime;
281 #if !defined(_LP64) && !defined(__mips__)
282 uptr __unused2;
283 #endif
284 uptr shm_ctime;
285 #if !defined(_LP64) && !defined(__mips__)
286 uptr __unused3;
287 #endif
288 #endif
289 #ifdef __powerpc__
290 uptr shm_segsz;
291 #endif
292 int shm_cpid;
293 int shm_lpid;
294 #if defined(__x86_64__) && !defined(_LP64)
295 u64 shm_nattch;
296 u64 __unused4;
297 u64 __unused5;
298 #else
299 uptr shm_nattch;
300 uptr __unused4;
301 uptr __unused5;
302 #endif
303 #endif
305 #endif
307 #if SANITIZER_LINUX && !SANITIZER_ANDROID
308 extern unsigned struct_msqid_ds_sz;
309 extern unsigned struct_mq_attr_sz;
310 extern unsigned struct_timex_sz;
311 extern unsigned struct_statvfs_sz;
312 #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
314 struct __sanitizer_iovec {
315 void *iov_base;
316 uptr iov_len;
319 #if !SANITIZER_ANDROID
320 struct __sanitizer_ifaddrs {
321 struct __sanitizer_ifaddrs *ifa_next;
322 char *ifa_name;
323 unsigned int ifa_flags;
324 void *ifa_addr; // (struct sockaddr *)
325 void *ifa_netmask; // (struct sockaddr *)
326 // This is a union on Linux.
327 # ifdef ifa_dstaddr
328 # undef ifa_dstaddr
329 # endif
330 void *ifa_dstaddr; // (struct sockaddr *)
331 void *ifa_data;
333 #endif // !SANITIZER_ANDROID
335 #if SANITIZER_APPLE
336 typedef unsigned long __sanitizer_pthread_key_t;
337 #else
338 typedef unsigned __sanitizer_pthread_key_t;
339 #endif
341 #if SANITIZER_LINUX && !SANITIZER_ANDROID
343 struct __sanitizer_XDR {
344 int x_op;
345 void *x_ops;
346 uptr x_public;
347 uptr x_private;
348 uptr x_base;
349 unsigned x_handy;
352 const int __sanitizer_XDR_ENCODE = 0;
353 const int __sanitizer_XDR_DECODE = 1;
354 const int __sanitizer_XDR_FREE = 2;
355 #endif
357 struct __sanitizer_passwd {
358 char *pw_name;
359 char *pw_passwd;
360 int pw_uid;
361 int pw_gid;
362 #if SANITIZER_APPLE
363 long pw_change;
364 char *pw_class;
365 #endif
366 #if !(SANITIZER_ANDROID && (SANITIZER_WORDSIZE == 32))
367 char *pw_gecos;
368 #endif
369 char *pw_dir;
370 char *pw_shell;
371 #if SANITIZER_APPLE
372 long pw_expire;
373 #endif
376 struct __sanitizer_group {
377 char *gr_name;
378 char *gr_passwd;
379 int gr_gid;
380 char **gr_mem;
383 # if (SANITIZER_LINUX && !SANITIZER_GLIBC && !SANITIZER_ANDROID) || \
384 (defined(__x86_64__) && !defined(_LP64)) || defined(__hexagon__)
385 typedef long long __sanitizer_time_t;
386 #else
387 typedef long __sanitizer_time_t;
388 #endif
390 typedef long __sanitizer_suseconds_t;
392 struct __sanitizer_timespec {
393 __sanitizer_time_t tv_sec; /* seconds */
394 u64 tv_nsec; /* nanoseconds */
397 struct __sanitizer_itimerspec {
398 struct __sanitizer_timespec it_interval; /* timer period */
399 struct __sanitizer_timespec it_value; /* timer expiration */
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 typedef unsigned long long __sanitizer_eventfd_t;
537 #endif
539 #if SANITIZER_LINUX
540 # if defined(_LP64) || defined(__x86_64__) || defined(__powerpc__) || \
541 defined(__mips__) || defined(__hexagon__)
542 typedef unsigned __sanitizer___kernel_uid_t;
543 typedef unsigned __sanitizer___kernel_gid_t;
544 #else
545 typedef unsigned short __sanitizer___kernel_uid_t;
546 typedef unsigned short __sanitizer___kernel_gid_t;
547 #endif
548 #if defined(__x86_64__) && !defined(_LP64)
549 typedef long long __sanitizer___kernel_off_t;
550 #else
551 typedef long __sanitizer___kernel_off_t;
552 #endif
554 #if defined(__powerpc__) || defined(__mips__)
555 typedef unsigned int __sanitizer___kernel_old_uid_t;
556 typedef unsigned int __sanitizer___kernel_old_gid_t;
557 #else
558 typedef unsigned short __sanitizer___kernel_old_uid_t;
559 typedef unsigned short __sanitizer___kernel_old_gid_t;
560 #endif
562 typedef long long __sanitizer___kernel_loff_t;
563 typedef struct {
564 unsigned long fds_bits[1024 / (8 * sizeof(long))];
565 } __sanitizer___kernel_fd_set;
566 #endif
568 // This thing depends on the platform. We are only interested in the upper
569 // limit. Verified with a compiler assert in .cpp.
570 union __sanitizer_pthread_attr_t {
571 char size[128];
572 void *align;
575 #if SANITIZER_ANDROID
576 # if SANITIZER_MIPS
577 typedef unsigned long __sanitizer_sigset_t[16 / sizeof(unsigned long)];
578 # else
579 typedef unsigned long __sanitizer_sigset_t;
580 # endif
581 #elif SANITIZER_APPLE
582 typedef unsigned __sanitizer_sigset_t;
583 #elif SANITIZER_LINUX
584 struct __sanitizer_sigset_t {
585 // The size is determined by looking at sizeof of real sigset_t on linux.
586 uptr val[128 / sizeof(uptr)];
588 #endif
590 struct __sanitizer_siginfo_pad {
591 #if SANITIZER_X32
592 // x32 siginfo_t is aligned to 8 bytes.
593 u64 pad[128 / sizeof(u64)];
594 #else
595 // Require uptr, because siginfo_t is always pointer-size aligned on Linux.
596 uptr pad[128 / sizeof(uptr)];
597 #endif
600 #if SANITIZER_LINUX
601 # define SANITIZER_HAS_SIGINFO 1
602 union __sanitizer_siginfo {
603 struct {
604 int si_signo;
605 # if SANITIZER_MIPS
606 int si_code;
607 int si_errno;
608 # else
609 int si_errno;
610 int si_code;
611 # endif
613 __sanitizer_siginfo_pad pad;
615 #else
616 # define SANITIZER_HAS_SIGINFO 0
617 typedef __sanitizer_siginfo_pad __sanitizer_siginfo;
618 #endif
620 using __sanitizer_sighandler_ptr = void (*)(int sig);
621 using __sanitizer_sigactionhandler_ptr = void (*)(int sig,
622 __sanitizer_siginfo *siginfo,
623 void *uctx);
625 // Linux system headers define the 'sa_handler' and 'sa_sigaction' macros.
626 #if SANITIZER_ANDROID && (SANITIZER_WORDSIZE == 64)
627 struct __sanitizer_sigaction {
628 unsigned sa_flags;
629 union {
630 __sanitizer_sigactionhandler_ptr sigaction;
631 __sanitizer_sighandler_ptr handler;
633 __sanitizer_sigset_t sa_mask;
634 void (*sa_restorer)();
636 #elif SANITIZER_ANDROID && SANITIZER_MIPS32 // check this before WORDSIZE == 32
637 struct __sanitizer_sigaction {
638 unsigned sa_flags;
639 union {
640 __sanitizer_sigactionhandler_ptr sigaction;
641 __sanitizer_sighandler_ptr handler;
643 __sanitizer_sigset_t sa_mask;
645 #elif SANITIZER_ANDROID && (SANITIZER_WORDSIZE == 32)
646 struct __sanitizer_sigaction {
647 union {
648 __sanitizer_sigactionhandler_ptr sigaction;
649 __sanitizer_sighandler_ptr handler;
651 __sanitizer_sigset_t sa_mask;
652 uptr sa_flags;
653 void (*sa_restorer)();
655 #else // !SANITIZER_ANDROID
656 struct __sanitizer_sigaction {
657 #if defined(__mips__) && !SANITIZER_FREEBSD
658 unsigned int sa_flags;
659 #endif
660 union {
661 __sanitizer_sigactionhandler_ptr sigaction;
662 __sanitizer_sighandler_ptr handler;
664 #if SANITIZER_FREEBSD
665 int sa_flags;
666 __sanitizer_sigset_t sa_mask;
667 #else
668 #if defined(__s390x__)
669 int sa_resv;
670 #else
671 __sanitizer_sigset_t sa_mask;
672 #endif
673 #ifndef __mips__
674 #if defined(__sparc__)
675 #if __GLIBC_PREREQ (2, 20)
676 // On sparc glibc 2.19 and earlier sa_flags was unsigned long.
677 #if defined(__arch64__)
678 // To maintain ABI compatibility on sparc64 when switching to an int,
679 // __glibc_reserved0 was added.
680 int __glibc_reserved0;
681 #endif
682 int sa_flags;
683 #else
684 unsigned long sa_flags;
685 #endif
686 #else
687 int sa_flags;
688 #endif
689 #endif
690 #endif
691 #if SANITIZER_LINUX
692 void (*sa_restorer)();
693 #endif
694 #if defined(__mips__) && (SANITIZER_WORDSIZE == 32)
695 int sa_resv[1];
696 #endif
697 #if defined(__s390x__)
698 __sanitizer_sigset_t sa_mask;
699 #endif
701 #endif // !SANITIZER_ANDROID
703 #if defined(__mips__)
704 #define __SANITIZER_KERNEL_NSIG 128
705 #else
706 #define __SANITIZER_KERNEL_NSIG 64
707 #endif
709 struct __sanitizer_kernel_sigset_t {
710 uptr sig[__SANITIZER_KERNEL_NSIG / (sizeof(uptr) * 8)];
713 // Linux system headers define the 'sa_handler' and 'sa_sigaction' macros.
714 #if SANITIZER_MIPS
715 struct __sanitizer_kernel_sigaction_t {
716 unsigned int sa_flags;
717 union {
718 void (*handler)(int signo);
719 void (*sigaction)(int signo, __sanitizer_siginfo *info, void *ctx);
721 __sanitizer_kernel_sigset_t sa_mask;
722 void (*sa_restorer)(void);
724 #else
725 struct __sanitizer_kernel_sigaction_t {
726 union {
727 void (*handler)(int signo);
728 void (*sigaction)(int signo, __sanitizer_siginfo *info, void *ctx);
730 unsigned long sa_flags;
731 void (*sa_restorer)(void);
732 __sanitizer_kernel_sigset_t sa_mask;
734 #endif
736 extern const uptr sig_ign;
737 extern const uptr sig_dfl;
738 extern const uptr sig_err;
739 extern const uptr sa_siginfo;
741 #if SANITIZER_LINUX
742 extern int e_tabsz;
743 #endif
745 extern int af_inet;
746 extern int af_inet6;
747 uptr __sanitizer_in_addr_sz(int af);
749 #if SANITIZER_LINUX
750 struct __sanitizer_dl_phdr_info {
751 uptr dlpi_addr;
752 const char *dlpi_name;
753 const void *dlpi_phdr;
754 short dlpi_phnum;
757 extern unsigned struct_ElfW_Phdr_sz;
758 #endif
760 struct __sanitizer_protoent {
761 char *p_name;
762 char **p_aliases;
763 int p_proto;
766 struct __sanitizer_netent {
767 char *n_name;
768 char **n_aliases;
769 int n_addrtype;
770 u32 n_net;
773 struct __sanitizer_addrinfo {
774 int ai_flags;
775 int ai_family;
776 int ai_socktype;
777 int ai_protocol;
778 #if SANITIZER_ANDROID || SANITIZER_APPLE
779 unsigned ai_addrlen;
780 char *ai_canonname;
781 void *ai_addr;
782 #else // LINUX
783 unsigned ai_addrlen;
784 void *ai_addr;
785 char *ai_canonname;
786 #endif
787 struct __sanitizer_addrinfo *ai_next;
790 struct __sanitizer_hostent {
791 char *h_name;
792 char **h_aliases;
793 int h_addrtype;
794 int h_length;
795 char **h_addr_list;
798 struct __sanitizer_pollfd {
799 int fd;
800 short events;
801 short revents;
804 #if SANITIZER_ANDROID || SANITIZER_APPLE
805 typedef unsigned __sanitizer_nfds_t;
806 #else
807 typedef unsigned long __sanitizer_nfds_t;
808 #endif
810 #if !SANITIZER_ANDROID
811 # if SANITIZER_LINUX
812 struct __sanitizer_glob_t {
813 uptr gl_pathc;
814 char **gl_pathv;
815 uptr gl_offs;
816 int gl_flags;
818 void (*gl_closedir)(void *dirp);
819 void *(*gl_readdir)(void *dirp);
820 void *(*gl_opendir)(const char *);
821 int (*gl_lstat)(const char *, void *);
822 int (*gl_stat)(const char *, void *);
824 # endif // SANITIZER_LINUX
826 # if SANITIZER_LINUX
827 extern int glob_nomatch;
828 extern int glob_altdirfunc;
829 # endif
830 #endif // !SANITIZER_ANDROID
832 extern unsigned path_max;
834 # if !SANITIZER_ANDROID
835 extern const int wordexp_wrde_dooffs;
836 # endif // !SANITIZER_ANDROID
838 struct __sanitizer_wordexp_t {
839 uptr we_wordc;
840 char **we_wordv;
841 uptr we_offs;
844 #if SANITIZER_LINUX && !SANITIZER_ANDROID
845 struct __sanitizer_FILE {
846 int _flags;
847 char *_IO_read_ptr;
848 char *_IO_read_end;
849 char *_IO_read_base;
850 char *_IO_write_base;
851 char *_IO_write_ptr;
852 char *_IO_write_end;
853 char *_IO_buf_base;
854 char *_IO_buf_end;
855 char *_IO_save_base;
856 char *_IO_backup_base;
857 char *_IO_save_end;
858 void *_markers;
859 __sanitizer_FILE *_chain;
860 int _fileno;
862 # define SANITIZER_HAS_STRUCT_FILE 1
863 #else
864 typedef void __sanitizer_FILE;
865 # define SANITIZER_HAS_STRUCT_FILE 0
866 #endif
868 # if SANITIZER_LINUX && !SANITIZER_ANDROID && \
869 (defined(__i386) || defined(__x86_64) || defined(__mips64) || \
870 defined(__powerpc64__) || defined(__aarch64__) || defined(__arm__) || \
871 defined(__s390__) || defined(__loongarch__) || SANITIZER_RISCV64 || \
872 defined(__sparc__))
873 extern unsigned struct_user_regs_struct_sz;
874 extern unsigned struct_user_fpregs_struct_sz;
875 extern unsigned struct_user_fpxregs_struct_sz;
876 extern unsigned struct_user_vfpregs_struct_sz;
878 extern int ptrace_peektext;
879 extern int ptrace_peekdata;
880 extern int ptrace_peekuser;
881 extern int ptrace_getregs;
882 extern int ptrace_setregs;
883 extern int ptrace_getfpregs;
884 extern int ptrace_setfpregs;
885 extern int ptrace_getfpxregs;
886 extern int ptrace_setfpxregs;
887 extern int ptrace_getvfpregs;
888 extern int ptrace_setvfpregs;
889 extern int ptrace_getsiginfo;
890 extern int ptrace_setsiginfo;
891 extern int ptrace_getregset;
892 extern int ptrace_setregset;
893 extern int ptrace_geteventmsg;
895 // Helper for the ptrace interceptor.
896 template <class T>
897 inline T ptrace_data_arg(int request, T addr, T data) {
898 # if SANITIZER_LINUX && SANITIZER_SPARC
899 // As described in ptrace(2), the meanings of addr and data are reversed
900 // for the PTRACE_GETREGS, PTRACE_GETFPREGS, PTRACE_GETREGS, and
901 // PTRACE_GETFPREGS requests on Linux/sparc64.
902 if (request == ptrace_getregs || request == ptrace_getfpregs ||
903 request == ptrace_setregs || request == ptrace_setfpregs)
904 return addr;
905 else
906 # endif
907 return data;
909 # endif
911 # if SANITIZER_LINUX && !SANITIZER_ANDROID
912 extern unsigned struct_shminfo_sz;
913 extern unsigned struct_shm_info_sz;
914 extern int shmctl_ipc_stat;
915 extern int shmctl_ipc_info;
916 extern int shmctl_shm_info;
917 extern int shmctl_shm_stat;
918 #endif
920 #if !SANITIZER_APPLE && !SANITIZER_FREEBSD
921 extern unsigned struct_utmp_sz;
922 #endif
923 #if !SANITIZER_ANDROID
924 extern unsigned struct_utmpx_sz;
925 #endif
927 extern int map_fixed;
929 // ioctl arguments
930 struct __sanitizer_ifconf {
931 int ifc_len;
932 union {
933 void *ifcu_req;
934 } ifc_ifcu;
935 #if SANITIZER_APPLE
936 } __attribute__((packed));
937 #else
939 #endif
941 #if SANITIZER_LINUX && !SANITIZER_ANDROID
942 struct __sanitizer__obstack_chunk {
943 char *limit;
944 struct __sanitizer__obstack_chunk *prev;
947 struct __sanitizer_obstack {
948 long chunk_size;
949 struct __sanitizer__obstack_chunk *chunk;
950 char *object_base;
951 char *next_free;
952 uptr more_fields[7];
955 typedef uptr (*__sanitizer_cookie_io_read)(void *cookie, char *buf, uptr size);
956 typedef uptr (*__sanitizer_cookie_io_write)(void *cookie, const char *buf,
957 uptr size);
958 typedef int (*__sanitizer_cookie_io_seek)(void *cookie, u64 *offset,
959 int whence);
960 typedef int (*__sanitizer_cookie_io_close)(void *cookie);
962 struct __sanitizer_cookie_io_functions_t {
963 __sanitizer_cookie_io_read read;
964 __sanitizer_cookie_io_write write;
965 __sanitizer_cookie_io_seek seek;
966 __sanitizer_cookie_io_close close;
968 #endif
970 #define IOC_NRBITS 8
971 #define IOC_TYPEBITS 8
972 #if defined(__powerpc__) || defined(__powerpc64__) || defined(__mips__) || \
973 defined(__sparc__)
974 #define IOC_SIZEBITS 13
975 #define IOC_DIRBITS 3
976 #define IOC_NONE 1U
977 #define IOC_WRITE 4U
978 #define IOC_READ 2U
979 #else
980 #define IOC_SIZEBITS 14
981 #define IOC_DIRBITS 2
982 #define IOC_NONE 0U
983 #define IOC_WRITE 1U
984 #define IOC_READ 2U
985 #endif
986 #define IOC_NRMASK ((1 << IOC_NRBITS) - 1)
987 #define IOC_TYPEMASK ((1 << IOC_TYPEBITS) - 1)
988 #define IOC_SIZEMASK ((1 << IOC_SIZEBITS) - 1)
989 #if defined(IOC_DIRMASK)
990 #undef IOC_DIRMASK
991 #endif
992 #define IOC_DIRMASK ((1 << IOC_DIRBITS) - 1)
993 #define IOC_NRSHIFT 0
994 #define IOC_TYPESHIFT (IOC_NRSHIFT + IOC_NRBITS)
995 #define IOC_SIZESHIFT (IOC_TYPESHIFT + IOC_TYPEBITS)
996 #define IOC_DIRSHIFT (IOC_SIZESHIFT + IOC_SIZEBITS)
997 #define EVIOC_EV_MAX 0x1f
998 #define EVIOC_ABS_MAX 0x3f
1000 #define IOC_DIR(nr) (((nr) >> IOC_DIRSHIFT) & IOC_DIRMASK)
1001 #define IOC_TYPE(nr) (((nr) >> IOC_TYPESHIFT) & IOC_TYPEMASK)
1002 #define IOC_NR(nr) (((nr) >> IOC_NRSHIFT) & IOC_NRMASK)
1004 #if defined(__sparc__)
1005 // In sparc the 14 bits SIZE field overlaps with the
1006 // least significant bit of DIR, so either IOC_READ or
1007 // IOC_WRITE shall be 1 in order to get a non-zero SIZE.
1008 #define IOC_SIZE(nr) \
1009 ((((((nr) >> 29) & 0x7) & (4U | 2U)) == 0) ? 0 : (((nr) >> 16) & 0x3fff))
1010 #else
1011 #define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK)
1012 #endif
1014 extern unsigned struct_ifreq_sz;
1015 extern unsigned struct_termios_sz;
1016 extern unsigned struct_winsize_sz;
1018 #if SANITIZER_LINUX
1019 extern unsigned struct_arpreq_sz;
1020 extern unsigned struct_cdrom_msf_sz;
1021 extern unsigned struct_cdrom_multisession_sz;
1022 extern unsigned struct_cdrom_read_audio_sz;
1023 extern unsigned struct_cdrom_subchnl_sz;
1024 extern unsigned struct_cdrom_ti_sz;
1025 extern unsigned struct_cdrom_tocentry_sz;
1026 extern unsigned struct_cdrom_tochdr_sz;
1027 extern unsigned struct_cdrom_volctrl_sz;
1028 extern unsigned struct_ff_effect_sz;
1029 extern unsigned struct_floppy_drive_params_sz;
1030 extern unsigned struct_floppy_drive_struct_sz;
1031 extern unsigned struct_floppy_fdc_state_sz;
1032 extern unsigned struct_floppy_max_errors_sz;
1033 extern unsigned struct_floppy_raw_cmd_sz;
1034 extern unsigned struct_floppy_struct_sz;
1035 extern unsigned struct_floppy_write_errors_sz;
1036 extern unsigned struct_format_descr_sz;
1037 extern unsigned struct_hd_driveid_sz;
1038 extern unsigned struct_hd_geometry_sz;
1039 extern unsigned struct_input_absinfo_sz;
1040 extern unsigned struct_input_id_sz;
1041 extern unsigned struct_mtpos_sz;
1042 extern unsigned struct_termio_sz;
1043 extern unsigned struct_vt_consize_sz;
1044 extern unsigned struct_vt_sizes_sz;
1045 extern unsigned struct_vt_stat_sz;
1046 #endif // SANITIZER_LINUX
1048 #if SANITIZER_LINUX
1049 extern unsigned struct_copr_buffer_sz;
1050 extern unsigned struct_copr_debug_buf_sz;
1051 extern unsigned struct_copr_msg_sz;
1052 extern unsigned struct_midi_info_sz;
1053 extern unsigned struct_mtget_sz;
1054 extern unsigned struct_mtop_sz;
1055 extern unsigned struct_rtentry_sz;
1056 extern unsigned struct_sbi_instrument_sz;
1057 extern unsigned struct_seq_event_rec_sz;
1058 extern unsigned struct_synth_info_sz;
1059 extern unsigned struct_vt_mode_sz;
1060 #endif // SANITIZER_LINUX
1062 #if SANITIZER_LINUX && !SANITIZER_ANDROID
1063 extern unsigned struct_ax25_parms_struct_sz;
1064 extern unsigned struct_input_keymap_entry_sz;
1065 extern unsigned struct_ipx_config_data_sz;
1066 extern unsigned struct_kbdiacrs_sz;
1067 extern unsigned struct_kbentry_sz;
1068 extern unsigned struct_kbkeycode_sz;
1069 extern unsigned struct_kbsentry_sz;
1070 extern unsigned struct_mtconfiginfo_sz;
1071 extern unsigned struct_nr_parms_struct_sz;
1072 extern unsigned struct_scc_modem_sz;
1073 extern unsigned struct_scc_stat_sz;
1074 extern unsigned struct_serial_multiport_struct_sz;
1075 extern unsigned struct_serial_struct_sz;
1076 extern unsigned struct_sockaddr_ax25_sz;
1077 extern unsigned struct_unimapdesc_sz;
1078 extern unsigned struct_unimapinit_sz;
1079 extern unsigned struct_sock_fprog_sz;
1080 # endif // SANITIZER_LINUX && !SANITIZER_ANDROID
1082 extern const unsigned long __sanitizer_bufsiz;
1084 #if SANITIZER_LINUX && !SANITIZER_ANDROID
1085 extern unsigned struct_audio_buf_info_sz;
1086 extern unsigned struct_ppp_stats_sz;
1087 #endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
1089 #if !SANITIZER_ANDROID && !SANITIZER_APPLE
1090 extern unsigned struct_sioc_sg_req_sz;
1091 extern unsigned struct_sioc_vif_req_sz;
1092 #endif
1094 // ioctl request identifiers
1096 // A special value to mark ioctls that are not present on the target platform,
1097 // when it can not be determined without including any system headers.
1098 extern const unsigned IOCTL_NOT_PRESENT;
1100 extern unsigned IOCTL_FIOASYNC;
1101 extern unsigned IOCTL_FIOCLEX;
1102 extern unsigned IOCTL_FIOGETOWN;
1103 extern unsigned IOCTL_FIONBIO;
1104 extern unsigned IOCTL_FIONCLEX;
1105 extern unsigned IOCTL_FIOSETOWN;
1106 extern unsigned IOCTL_SIOCADDMULTI;
1107 extern unsigned IOCTL_SIOCATMARK;
1108 extern unsigned IOCTL_SIOCDELMULTI;
1109 extern unsigned IOCTL_SIOCGIFADDR;
1110 extern unsigned IOCTL_SIOCGIFBRDADDR;
1111 extern unsigned IOCTL_SIOCGIFCONF;
1112 extern unsigned IOCTL_SIOCGIFDSTADDR;
1113 extern unsigned IOCTL_SIOCGIFFLAGS;
1114 extern unsigned IOCTL_SIOCGIFMETRIC;
1115 extern unsigned IOCTL_SIOCGIFMTU;
1116 extern unsigned IOCTL_SIOCGIFNETMASK;
1117 extern unsigned IOCTL_SIOCGPGRP;
1118 extern unsigned IOCTL_SIOCSIFADDR;
1119 extern unsigned IOCTL_SIOCSIFBRDADDR;
1120 extern unsigned IOCTL_SIOCSIFDSTADDR;
1121 extern unsigned IOCTL_SIOCSIFFLAGS;
1122 extern unsigned IOCTL_SIOCSIFMETRIC;
1123 extern unsigned IOCTL_SIOCSIFMTU;
1124 extern unsigned IOCTL_SIOCSIFNETMASK;
1125 extern unsigned IOCTL_SIOCSPGRP;
1126 extern unsigned IOCTL_TIOCCONS;
1127 extern unsigned IOCTL_TIOCEXCL;
1128 extern unsigned IOCTL_TIOCGETD;
1129 extern unsigned IOCTL_TIOCGPGRP;
1130 extern unsigned IOCTL_TIOCGWINSZ;
1131 extern unsigned IOCTL_TIOCMBIC;
1132 extern unsigned IOCTL_TIOCMBIS;
1133 extern unsigned IOCTL_TIOCMGET;
1134 extern unsigned IOCTL_TIOCMSET;
1135 extern unsigned IOCTL_TIOCNOTTY;
1136 extern unsigned IOCTL_TIOCNXCL;
1137 extern unsigned IOCTL_TIOCOUTQ;
1138 extern unsigned IOCTL_TIOCPKT;
1139 extern unsigned IOCTL_TIOCSCTTY;
1140 extern unsigned IOCTL_TIOCSETD;
1141 extern unsigned IOCTL_TIOCSPGRP;
1142 extern unsigned IOCTL_TIOCSTI;
1143 extern unsigned IOCTL_TIOCSWINSZ;
1144 #if SANITIZER_LINUX && !SANITIZER_ANDROID
1145 extern unsigned IOCTL_SIOCGETSGCNT;
1146 extern unsigned IOCTL_SIOCGETVIFCNT;
1147 #endif
1148 #if SANITIZER_LINUX
1149 extern unsigned IOCTL_EVIOCGABS;
1150 extern unsigned IOCTL_EVIOCGBIT;
1151 extern unsigned IOCTL_EVIOCGEFFECTS;
1152 extern unsigned IOCTL_EVIOCGID;
1153 extern unsigned IOCTL_EVIOCGKEY;
1154 extern unsigned IOCTL_EVIOCGKEYCODE;
1155 extern unsigned IOCTL_EVIOCGLED;
1156 extern unsigned IOCTL_EVIOCGNAME;
1157 extern unsigned IOCTL_EVIOCGPHYS;
1158 extern unsigned IOCTL_EVIOCGRAB;
1159 extern unsigned IOCTL_EVIOCGREP;
1160 extern unsigned IOCTL_EVIOCGSND;
1161 extern unsigned IOCTL_EVIOCGSW;
1162 extern unsigned IOCTL_EVIOCGUNIQ;
1163 extern unsigned IOCTL_EVIOCGVERSION;
1164 extern unsigned IOCTL_EVIOCRMFF;
1165 extern unsigned IOCTL_EVIOCSABS;
1166 extern unsigned IOCTL_EVIOCSFF;
1167 extern unsigned IOCTL_EVIOCSKEYCODE;
1168 extern unsigned IOCTL_EVIOCSREP;
1169 extern unsigned IOCTL_BLKFLSBUF;
1170 extern unsigned IOCTL_BLKGETSIZE;
1171 extern unsigned IOCTL_BLKRAGET;
1172 extern unsigned IOCTL_BLKRASET;
1173 extern unsigned IOCTL_BLKROGET;
1174 extern unsigned IOCTL_BLKROSET;
1175 extern unsigned IOCTL_BLKRRPART;
1176 extern unsigned IOCTL_BLKFRASET;
1177 extern unsigned IOCTL_BLKFRAGET;
1178 extern unsigned IOCTL_BLKSECTSET;
1179 extern unsigned IOCTL_BLKSECTGET;
1180 extern unsigned IOCTL_BLKSSZGET;
1181 extern unsigned IOCTL_BLKBSZGET;
1182 extern unsigned IOCTL_BLKBSZSET;
1183 extern unsigned IOCTL_BLKGETSIZE64;
1184 extern unsigned IOCTL_CDROMAUDIOBUFSIZ;
1185 extern unsigned IOCTL_CDROMEJECT;
1186 extern unsigned IOCTL_CDROMEJECT_SW;
1187 extern unsigned IOCTL_CDROMMULTISESSION;
1188 extern unsigned IOCTL_CDROMPAUSE;
1189 extern unsigned IOCTL_CDROMPLAYMSF;
1190 extern unsigned IOCTL_CDROMPLAYTRKIND;
1191 extern unsigned IOCTL_CDROMREADAUDIO;
1192 extern unsigned IOCTL_CDROMREADCOOKED;
1193 extern unsigned IOCTL_CDROMREADMODE1;
1194 extern unsigned IOCTL_CDROMREADMODE2;
1195 extern unsigned IOCTL_CDROMREADRAW;
1196 extern unsigned IOCTL_CDROMREADTOCENTRY;
1197 extern unsigned IOCTL_CDROMREADTOCHDR;
1198 extern unsigned IOCTL_CDROMRESET;
1199 extern unsigned IOCTL_CDROMRESUME;
1200 extern unsigned IOCTL_CDROMSEEK;
1201 extern unsigned IOCTL_CDROMSTART;
1202 extern unsigned IOCTL_CDROMSTOP;
1203 extern unsigned IOCTL_CDROMSUBCHNL;
1204 extern unsigned IOCTL_CDROMVOLCTRL;
1205 extern unsigned IOCTL_CDROMVOLREAD;
1206 extern unsigned IOCTL_CDROM_GET_UPC;
1207 extern unsigned IOCTL_FDCLRPRM;
1208 extern unsigned IOCTL_FDDEFPRM;
1209 extern unsigned IOCTL_FDFLUSH;
1210 extern unsigned IOCTL_FDFMTBEG;
1211 extern unsigned IOCTL_FDFMTEND;
1212 extern unsigned IOCTL_FDFMTTRK;
1213 extern unsigned IOCTL_FDGETDRVPRM;
1214 extern unsigned IOCTL_FDGETDRVSTAT;
1215 extern unsigned IOCTL_FDGETDRVTYP;
1216 extern unsigned IOCTL_FDGETFDCSTAT;
1217 extern unsigned IOCTL_FDGETMAXERRS;
1218 extern unsigned IOCTL_FDGETPRM;
1219 extern unsigned IOCTL_FDMSGOFF;
1220 extern unsigned IOCTL_FDMSGON;
1221 extern unsigned IOCTL_FDPOLLDRVSTAT;
1222 extern unsigned IOCTL_FDRAWCMD;
1223 extern unsigned IOCTL_FDRESET;
1224 extern unsigned IOCTL_FDSETDRVPRM;
1225 extern unsigned IOCTL_FDSETEMSGTRESH;
1226 extern unsigned IOCTL_FDSETMAXERRS;
1227 extern unsigned IOCTL_FDSETPRM;
1228 extern unsigned IOCTL_FDTWADDLE;
1229 extern unsigned IOCTL_FDWERRORCLR;
1230 extern unsigned IOCTL_FDWERRORGET;
1231 extern unsigned IOCTL_HDIO_DRIVE_CMD;
1232 extern unsigned IOCTL_HDIO_GETGEO;
1233 extern unsigned IOCTL_HDIO_GET_32BIT;
1234 extern unsigned IOCTL_HDIO_GET_DMA;
1235 extern unsigned IOCTL_HDIO_GET_IDENTITY;
1236 extern unsigned IOCTL_HDIO_GET_KEEPSETTINGS;
1237 extern unsigned IOCTL_HDIO_GET_MULTCOUNT;
1238 extern unsigned IOCTL_HDIO_GET_NOWERR;
1239 extern unsigned IOCTL_HDIO_GET_UNMASKINTR;
1240 extern unsigned IOCTL_HDIO_SET_32BIT;
1241 extern unsigned IOCTL_HDIO_SET_DMA;
1242 extern unsigned IOCTL_HDIO_SET_KEEPSETTINGS;
1243 extern unsigned IOCTL_HDIO_SET_MULTCOUNT;
1244 extern unsigned IOCTL_HDIO_SET_NOWERR;
1245 extern unsigned IOCTL_HDIO_SET_UNMASKINTR;
1246 extern unsigned IOCTL_MTIOCPOS;
1247 extern unsigned IOCTL_PPPIOCGASYNCMAP;
1248 extern unsigned IOCTL_PPPIOCGDEBUG;
1249 extern unsigned IOCTL_PPPIOCGFLAGS;
1250 extern unsigned IOCTL_PPPIOCGUNIT;
1251 extern unsigned IOCTL_PPPIOCGXASYNCMAP;
1252 extern unsigned IOCTL_PPPIOCSASYNCMAP;
1253 extern unsigned IOCTL_PPPIOCSDEBUG;
1254 extern unsigned IOCTL_PPPIOCSFLAGS;
1255 extern unsigned IOCTL_PPPIOCSMAXCID;
1256 extern unsigned IOCTL_PPPIOCSMRU;
1257 extern unsigned IOCTL_PPPIOCSXASYNCMAP;
1258 extern unsigned IOCTL_SIOCDARP;
1259 extern unsigned IOCTL_SIOCDRARP;
1260 extern unsigned IOCTL_SIOCGARP;
1261 extern unsigned IOCTL_SIOCGIFENCAP;
1262 extern unsigned IOCTL_SIOCGIFHWADDR;
1263 extern unsigned IOCTL_SIOCGIFMAP;
1264 extern unsigned IOCTL_SIOCGIFMEM;
1265 extern unsigned IOCTL_SIOCGIFNAME;
1266 extern unsigned IOCTL_SIOCGIFSLAVE;
1267 extern unsigned IOCTL_SIOCGRARP;
1268 extern unsigned IOCTL_SIOCGSTAMP;
1269 extern unsigned IOCTL_SIOCSARP;
1270 extern unsigned IOCTL_SIOCSIFENCAP;
1271 extern unsigned IOCTL_SIOCSIFHWADDR;
1272 extern unsigned IOCTL_SIOCSIFLINK;
1273 extern unsigned IOCTL_SIOCSIFMAP;
1274 extern unsigned IOCTL_SIOCSIFMEM;
1275 extern unsigned IOCTL_SIOCSIFSLAVE;
1276 extern unsigned IOCTL_SIOCSRARP;
1277 extern unsigned IOCTL_SNDCTL_COPR_HALT;
1278 extern unsigned IOCTL_SNDCTL_COPR_LOAD;
1279 extern unsigned IOCTL_SNDCTL_COPR_RCODE;
1280 extern unsigned IOCTL_SNDCTL_COPR_RCVMSG;
1281 extern unsigned IOCTL_SNDCTL_COPR_RDATA;
1282 extern unsigned IOCTL_SNDCTL_COPR_RESET;
1283 extern unsigned IOCTL_SNDCTL_COPR_RUN;
1284 extern unsigned IOCTL_SNDCTL_COPR_SENDMSG;
1285 extern unsigned IOCTL_SNDCTL_COPR_WCODE;
1286 extern unsigned IOCTL_SNDCTL_COPR_WDATA;
1287 extern unsigned IOCTL_TCFLSH;
1288 extern unsigned IOCTL_TCGETA;
1289 extern unsigned IOCTL_TCGETS;
1290 extern unsigned IOCTL_TCSBRK;
1291 extern unsigned IOCTL_TCSBRKP;
1292 extern unsigned IOCTL_TCSETA;
1293 extern unsigned IOCTL_TCSETAF;
1294 extern unsigned IOCTL_TCSETAW;
1295 extern unsigned IOCTL_TCSETS;
1296 extern unsigned IOCTL_TCSETSF;
1297 extern unsigned IOCTL_TCSETSW;
1298 extern unsigned IOCTL_TCXONC;
1299 extern unsigned IOCTL_TIOCGLCKTRMIOS;
1300 extern unsigned IOCTL_TIOCGSOFTCAR;
1301 extern unsigned IOCTL_TIOCINQ;
1302 extern unsigned IOCTL_TIOCLINUX;
1303 extern unsigned IOCTL_TIOCSERCONFIG;
1304 extern unsigned IOCTL_TIOCSERGETLSR;
1305 extern unsigned IOCTL_TIOCSERGWILD;
1306 extern unsigned IOCTL_TIOCSERSWILD;
1307 extern unsigned IOCTL_TIOCSLCKTRMIOS;
1308 extern unsigned IOCTL_TIOCSSOFTCAR;
1309 extern unsigned IOCTL_VT_DISALLOCATE;
1310 extern unsigned IOCTL_VT_GETSTATE;
1311 extern unsigned IOCTL_VT_RESIZE;
1312 extern unsigned IOCTL_VT_RESIZEX;
1313 extern unsigned IOCTL_VT_SENDSIG;
1314 extern unsigned IOCTL_MTIOCGET;
1315 extern unsigned IOCTL_MTIOCTOP;
1316 extern unsigned IOCTL_SIOCADDRT;
1317 extern unsigned IOCTL_SIOCDELRT;
1318 extern unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE;
1319 extern unsigned IOCTL_SNDCTL_DSP_GETFMTS;
1320 extern unsigned IOCTL_SNDCTL_DSP_NONBLOCK;
1321 extern unsigned IOCTL_SNDCTL_DSP_POST;
1322 extern unsigned IOCTL_SNDCTL_DSP_RESET;
1323 extern unsigned IOCTL_SNDCTL_DSP_SETFMT;
1324 extern unsigned IOCTL_SNDCTL_DSP_SETFRAGMENT;
1325 extern unsigned IOCTL_SNDCTL_DSP_SPEED;
1326 extern unsigned IOCTL_SNDCTL_DSP_STEREO;
1327 extern unsigned IOCTL_SNDCTL_DSP_SUBDIVIDE;
1328 extern unsigned IOCTL_SNDCTL_DSP_SYNC;
1329 extern unsigned IOCTL_SNDCTL_FM_4OP_ENABLE;
1330 extern unsigned IOCTL_SNDCTL_FM_LOAD_INSTR;
1331 extern unsigned IOCTL_SNDCTL_MIDI_INFO;
1332 extern unsigned IOCTL_SNDCTL_MIDI_PRETIME;
1333 extern unsigned IOCTL_SNDCTL_SEQ_CTRLRATE;
1334 extern unsigned IOCTL_SNDCTL_SEQ_GETINCOUNT;
1335 extern unsigned IOCTL_SNDCTL_SEQ_GETOUTCOUNT;
1336 extern unsigned IOCTL_SNDCTL_SEQ_NRMIDIS;
1337 extern unsigned IOCTL_SNDCTL_SEQ_NRSYNTHS;
1338 extern unsigned IOCTL_SNDCTL_SEQ_OUTOFBAND;
1339 extern unsigned IOCTL_SNDCTL_SEQ_PANIC;
1340 extern unsigned IOCTL_SNDCTL_SEQ_PERCMODE;
1341 extern unsigned IOCTL_SNDCTL_SEQ_RESET;
1342 extern unsigned IOCTL_SNDCTL_SEQ_RESETSAMPLES;
1343 extern unsigned IOCTL_SNDCTL_SEQ_SYNC;
1344 extern unsigned IOCTL_SNDCTL_SEQ_TESTMIDI;
1345 extern unsigned IOCTL_SNDCTL_SEQ_THRESHOLD;
1346 extern unsigned IOCTL_SNDCTL_SYNTH_INFO;
1347 extern unsigned IOCTL_SNDCTL_SYNTH_MEMAVL;
1348 extern unsigned IOCTL_SNDCTL_TMR_CONTINUE;
1349 extern unsigned IOCTL_SNDCTL_TMR_METRONOME;
1350 extern unsigned IOCTL_SNDCTL_TMR_SELECT;
1351 extern unsigned IOCTL_SNDCTL_TMR_SOURCE;
1352 extern unsigned IOCTL_SNDCTL_TMR_START;
1353 extern unsigned IOCTL_SNDCTL_TMR_STOP;
1354 extern unsigned IOCTL_SNDCTL_TMR_TEMPO;
1355 extern unsigned IOCTL_SNDCTL_TMR_TIMEBASE;
1356 extern unsigned IOCTL_SOUND_MIXER_READ_ALTPCM;
1357 extern unsigned IOCTL_SOUND_MIXER_READ_BASS;
1358 extern unsigned IOCTL_SOUND_MIXER_READ_CAPS;
1359 extern unsigned IOCTL_SOUND_MIXER_READ_CD;
1360 extern unsigned IOCTL_SOUND_MIXER_READ_DEVMASK;
1361 extern unsigned IOCTL_SOUND_MIXER_READ_ENHANCE;
1362 extern unsigned IOCTL_SOUND_MIXER_READ_IGAIN;
1363 extern unsigned IOCTL_SOUND_MIXER_READ_IMIX;
1364 extern unsigned IOCTL_SOUND_MIXER_READ_LINE1;
1365 extern unsigned IOCTL_SOUND_MIXER_READ_LINE2;
1366 extern unsigned IOCTL_SOUND_MIXER_READ_LINE3;
1367 extern unsigned IOCTL_SOUND_MIXER_READ_LINE;
1368 extern unsigned IOCTL_SOUND_MIXER_READ_LOUD;
1369 extern unsigned IOCTL_SOUND_MIXER_READ_MIC;
1370 extern unsigned IOCTL_SOUND_MIXER_READ_MUTE;
1371 extern unsigned IOCTL_SOUND_MIXER_READ_OGAIN;
1372 extern unsigned IOCTL_SOUND_MIXER_READ_PCM;
1373 extern unsigned IOCTL_SOUND_MIXER_READ_RECLEV;
1374 extern unsigned IOCTL_SOUND_MIXER_READ_RECMASK;
1375 extern unsigned IOCTL_SOUND_MIXER_READ_RECSRC;
1376 extern unsigned IOCTL_SOUND_MIXER_READ_SPEAKER;
1377 extern unsigned IOCTL_SOUND_MIXER_READ_STEREODEVS;
1378 extern unsigned IOCTL_SOUND_MIXER_READ_SYNTH;
1379 extern unsigned IOCTL_SOUND_MIXER_READ_TREBLE;
1380 extern unsigned IOCTL_SOUND_MIXER_READ_VOLUME;
1381 extern unsigned IOCTL_SOUND_MIXER_WRITE_ALTPCM;
1382 extern unsigned IOCTL_SOUND_MIXER_WRITE_BASS;
1383 extern unsigned IOCTL_SOUND_MIXER_WRITE_CD;
1384 extern unsigned IOCTL_SOUND_MIXER_WRITE_ENHANCE;
1385 extern unsigned IOCTL_SOUND_MIXER_WRITE_IGAIN;
1386 extern unsigned IOCTL_SOUND_MIXER_WRITE_IMIX;
1387 extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE1;
1388 extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE2;
1389 extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE3;
1390 extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE;
1391 extern unsigned IOCTL_SOUND_MIXER_WRITE_LOUD;
1392 extern unsigned IOCTL_SOUND_MIXER_WRITE_MIC;
1393 extern unsigned IOCTL_SOUND_MIXER_WRITE_MUTE;
1394 extern unsigned IOCTL_SOUND_MIXER_WRITE_OGAIN;
1395 extern unsigned IOCTL_SOUND_MIXER_WRITE_PCM;
1396 extern unsigned IOCTL_SOUND_MIXER_WRITE_RECLEV;
1397 extern unsigned IOCTL_SOUND_MIXER_WRITE_RECSRC;
1398 extern unsigned IOCTL_SOUND_MIXER_WRITE_SPEAKER;
1399 extern unsigned IOCTL_SOUND_MIXER_WRITE_SYNTH;
1400 extern unsigned IOCTL_SOUND_MIXER_WRITE_TREBLE;
1401 extern unsigned IOCTL_SOUND_MIXER_WRITE_VOLUME;
1402 extern unsigned IOCTL_SOUND_PCM_READ_BITS;
1403 extern unsigned IOCTL_SOUND_PCM_READ_CHANNELS;
1404 extern unsigned IOCTL_SOUND_PCM_READ_FILTER;
1405 extern unsigned IOCTL_SOUND_PCM_READ_RATE;
1406 extern unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS;
1407 extern unsigned IOCTL_SOUND_PCM_WRITE_FILTER;
1408 extern unsigned IOCTL_VT_ACTIVATE;
1409 extern unsigned IOCTL_VT_GETMODE;
1410 extern unsigned IOCTL_VT_OPENQRY;
1411 extern unsigned IOCTL_VT_RELDISP;
1412 extern unsigned IOCTL_VT_SETMODE;
1413 extern unsigned IOCTL_VT_WAITACTIVE;
1414 #endif // SANITIZER_LINUX
1416 #if SANITIZER_LINUX && !SANITIZER_ANDROID
1417 extern unsigned IOCTL_EQL_EMANCIPATE;
1418 extern unsigned IOCTL_EQL_ENSLAVE;
1419 extern unsigned IOCTL_EQL_GETMASTRCFG;
1420 extern unsigned IOCTL_EQL_GETSLAVECFG;
1421 extern unsigned IOCTL_EQL_SETMASTRCFG;
1422 extern unsigned IOCTL_EQL_SETSLAVECFG;
1423 extern unsigned IOCTL_EVIOCGKEYCODE_V2;
1424 extern unsigned IOCTL_EVIOCGPROP;
1425 extern unsigned IOCTL_EVIOCSKEYCODE_V2;
1426 extern unsigned IOCTL_FS_IOC_GETFLAGS;
1427 extern unsigned IOCTL_FS_IOC_GETVERSION;
1428 extern unsigned IOCTL_FS_IOC_SETFLAGS;
1429 extern unsigned IOCTL_FS_IOC_SETVERSION;
1430 extern unsigned IOCTL_GIO_CMAP;
1431 extern unsigned IOCTL_GIO_FONT;
1432 extern unsigned IOCTL_GIO_UNIMAP;
1433 extern unsigned IOCTL_GIO_UNISCRNMAP;
1434 extern unsigned IOCTL_KDADDIO;
1435 extern unsigned IOCTL_KDDELIO;
1436 extern unsigned IOCTL_KDGETKEYCODE;
1437 extern unsigned IOCTL_KDGKBDIACR;
1438 extern unsigned IOCTL_KDGKBENT;
1439 extern unsigned IOCTL_KDGKBLED;
1440 extern unsigned IOCTL_KDGKBMETA;
1441 extern unsigned IOCTL_KDGKBSENT;
1442 extern unsigned IOCTL_KDMAPDISP;
1443 extern unsigned IOCTL_KDSETKEYCODE;
1444 extern unsigned IOCTL_KDSIGACCEPT;
1445 extern unsigned IOCTL_KDSKBDIACR;
1446 extern unsigned IOCTL_KDSKBENT;
1447 extern unsigned IOCTL_KDSKBLED;
1448 extern unsigned IOCTL_KDSKBMETA;
1449 extern unsigned IOCTL_KDSKBSENT;
1450 extern unsigned IOCTL_KDUNMAPDISP;
1451 extern unsigned IOCTL_LPABORT;
1452 extern unsigned IOCTL_LPABORTOPEN;
1453 extern unsigned IOCTL_LPCAREFUL;
1454 extern unsigned IOCTL_LPCHAR;
1455 extern unsigned IOCTL_LPGETIRQ;
1456 extern unsigned IOCTL_LPGETSTATUS;
1457 extern unsigned IOCTL_LPRESET;
1458 extern unsigned IOCTL_LPSETIRQ;
1459 extern unsigned IOCTL_LPTIME;
1460 extern unsigned IOCTL_LPWAIT;
1461 extern unsigned IOCTL_MTIOCGETCONFIG;
1462 extern unsigned IOCTL_MTIOCSETCONFIG;
1463 extern unsigned IOCTL_PIO_CMAP;
1464 extern unsigned IOCTL_PIO_FONT;
1465 extern unsigned IOCTL_PIO_UNIMAP;
1466 extern unsigned IOCTL_PIO_UNIMAPCLR;
1467 extern unsigned IOCTL_PIO_UNISCRNMAP;
1468 extern unsigned IOCTL_SCSI_IOCTL_GET_IDLUN;
1469 extern unsigned IOCTL_SCSI_IOCTL_PROBE_HOST;
1470 extern unsigned IOCTL_SCSI_IOCTL_TAGGED_DISABLE;
1471 extern unsigned IOCTL_SCSI_IOCTL_TAGGED_ENABLE;
1472 extern unsigned IOCTL_SIOCAIPXITFCRT;
1473 extern unsigned IOCTL_SIOCAIPXPRISLT;
1474 extern unsigned IOCTL_SIOCAX25ADDUID;
1475 extern unsigned IOCTL_SIOCAX25DELUID;
1476 extern unsigned IOCTL_SIOCAX25GETPARMS;
1477 extern unsigned IOCTL_SIOCAX25GETUID;
1478 extern unsigned IOCTL_SIOCAX25NOUID;
1479 extern unsigned IOCTL_SIOCAX25SETPARMS;
1480 extern unsigned IOCTL_SIOCDEVPLIP;
1481 extern unsigned IOCTL_SIOCIPXCFGDATA;
1482 extern unsigned IOCTL_SIOCNRDECOBS;
1483 extern unsigned IOCTL_SIOCNRGETPARMS;
1484 extern unsigned IOCTL_SIOCNRRTCTL;
1485 extern unsigned IOCTL_SIOCNRSETPARMS;
1486 extern unsigned IOCTL_SNDCTL_DSP_GETISPACE;
1487 extern unsigned IOCTL_SNDCTL_DSP_GETOSPACE;
1488 extern unsigned IOCTL_TIOCGSERIAL;
1489 extern unsigned IOCTL_TIOCSERGETMULTI;
1490 extern unsigned IOCTL_TIOCSERSETMULTI;
1491 extern unsigned IOCTL_TIOCSSERIAL;
1492 extern unsigned IOCTL_GIO_SCRNMAP;
1493 extern unsigned IOCTL_KDDISABIO;
1494 extern unsigned IOCTL_KDENABIO;
1495 extern unsigned IOCTL_KDGETLED;
1496 extern unsigned IOCTL_KDGETMODE;
1497 extern unsigned IOCTL_KDGKBMODE;
1498 extern unsigned IOCTL_KDGKBTYPE;
1499 extern unsigned IOCTL_KDMKTONE;
1500 extern unsigned IOCTL_KDSETLED;
1501 extern unsigned IOCTL_KDSETMODE;
1502 extern unsigned IOCTL_KDSKBMODE;
1503 extern unsigned IOCTL_KIOCSOUND;
1504 extern unsigned IOCTL_PIO_SCRNMAP;
1505 #endif
1507 extern const int si_SEGV_MAPERR;
1508 extern const int si_SEGV_ACCERR;
1509 } // namespace __sanitizer
1511 #define CHECK_TYPE_SIZE(TYPE) \
1512 COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
1514 #define CHECK_SIZE_AND_OFFSET(CLASS, MEMBER) \
1515 COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *)NULL)->MEMBER) == \
1516 sizeof(((CLASS *)NULL)->MEMBER)); \
1517 COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) == \
1518 offsetof(CLASS, MEMBER))
1520 // For sigaction, which is a function and struct at the same time,
1521 // and thus requires explicit "struct" in sizeof() expression.
1522 #define CHECK_STRUCT_SIZE_AND_OFFSET(CLASS, MEMBER) \
1523 COMPILER_CHECK(sizeof(((struct __sanitizer_##CLASS *)NULL)->MEMBER) == \
1524 sizeof(((struct CLASS *)NULL)->MEMBER)); \
1525 COMPILER_CHECK(offsetof(struct __sanitizer_##CLASS, MEMBER) == \
1526 offsetof(struct CLASS, MEMBER))
1528 #define SIGACTION_SYMNAME sigaction
1530 # if SANITIZER_LINUX
1531 typedef void *__sanitizer_timer_t;
1532 # endif
1534 #endif // SANITIZER_LINUX || SANITIZER_APPLE
1536 #endif