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

source code of compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h