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