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 defined(__riscv) && __riscv_xlen == 64
103const unsigned struct_kernel_stat_sz = 128;
104const unsigned struct_kernel_stat64_sz = 104;
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(__riscv) || 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
446struct __sanitizer_msghdr {
447  void *msg_name;
448  unsigned msg_namelen;
449  struct __sanitizer_iovec *msg_iov;
450  uptr msg_iovlen;
451  void *msg_control;
452  uptr msg_controllen;
453  int msg_flags;
454};
455struct __sanitizer_cmsghdr {
456  uptr cmsg_len;
457  int cmsg_level;
458  int cmsg_type;
459};
460#endif
461
462#if SANITIZER_LINUX
463struct __sanitizer_mmsghdr {
464  __sanitizer_msghdr msg_hdr;
465  unsigned int msg_len;
466};
467#endif
468
469#if SANITIZER_MAC
470struct __sanitizer_dirent {
471  unsigned long long d_ino;
472  unsigned long long d_seekoff;
473  unsigned short d_reclen;
474  // more fields that we don't care about
475};
476#elif SANITIZER_ANDROID || defined(__x86_64__)
477struct __sanitizer_dirent {
478  unsigned long long d_ino;
479  unsigned long long d_off;
480  unsigned short d_reclen;
481  // more fields that we don't care about
482};
483#else
484struct __sanitizer_dirent {
485  uptr d_ino;
486  uptr d_off;
487  unsigned short d_reclen;
488  // more fields that we don't care about
489};
490#endif
491
492#if SANITIZER_LINUX && !SANITIZER_ANDROID
493struct __sanitizer_dirent64 {
494  unsigned long long d_ino;
495  unsigned long long d_off;
496  unsigned short d_reclen;
497  // more fields that we don't care about
498};
499#endif
500
501#if defined(__x86_64__) && !defined(_LP64)
502typedef long long __sanitizer_clock_t;
503#else
504typedef long __sanitizer_clock_t;
505#endif
506
507#if SANITIZER_LINUX
508typedef int __sanitizer_clockid_t;
509#endif
510
511#if SANITIZER_LINUX
512#if defined(_LP64) || defined(__x86_64__) || defined(__powerpc__) || \
513    defined(__mips__)
514typedef unsigned __sanitizer___kernel_uid_t;
515typedef unsigned __sanitizer___kernel_gid_t;
516#else
517typedef unsigned short __sanitizer___kernel_uid_t;
518typedef unsigned short __sanitizer___kernel_gid_t;
519#endif
520#if defined(__x86_64__) && !defined(_LP64)
521typedef long long __sanitizer___kernel_off_t;
522#else
523typedef long __sanitizer___kernel_off_t;
524#endif
525
526#if defined(__powerpc__) || defined(__mips__) || defined(__riscv)
527typedef unsigned int __sanitizer___kernel_old_uid_t;
528typedef unsigned int __sanitizer___kernel_old_gid_t;
529#else
530typedef unsigned short __sanitizer___kernel_old_uid_t;
531typedef unsigned short __sanitizer___kernel_old_gid_t;
532#endif
533
534typedef long long __sanitizer___kernel_loff_t;
535typedef struct {
536  unsigned long fds_bits[1024 / (8 * sizeof(long))];
537} __sanitizer___kernel_fd_set;
538#endif
539
540// This thing depends on the platform. We are only interested in the upper
541// limit. Verified with a compiler assert in .cpp.
542union __sanitizer_pthread_attr_t {
543  char size[128];
544  void *align;
545};
546
547#if SANITIZER_ANDROID
548# if SANITIZER_MIPS
549typedef unsigned long __sanitizer_sigset_t[16 / sizeof(unsigned long)];
550# else
551typedef unsigned long __sanitizer_sigset_t;
552# endif
553#elif SANITIZER_MAC
554typedef unsigned __sanitizer_sigset_t;
555#elif SANITIZER_LINUX
556struct __sanitizer_sigset_t {
557  // The size is determined by looking at sizeof of real sigset_t on linux.
558  uptr val[128 / sizeof(uptr)];
559};
560#endif
561
562struct __sanitizer_siginfo {
563  // The size is determined by looking at sizeof of real siginfo_t on linux.
564  u64 opaque[128 / sizeof(u64)];
565};
566
567using __sanitizer_sighandler_ptr = void (*)(int sig);
568using __sanitizer_sigactionhandler_ptr = void (*)(int sig,
569                                                  __sanitizer_siginfo *siginfo,
570                                                  void *uctx);
571
572// Linux system headers define the 'sa_handler' and 'sa_sigaction' macros.
573#if SANITIZER_ANDROID && (SANITIZER_WORDSIZE == 64)
574struct __sanitizer_sigaction {
575  unsigned sa_flags;
576  union {
577    __sanitizer_sigactionhandler_ptr sigaction;
578    __sanitizer_sighandler_ptr handler;
579  };
580  __sanitizer_sigset_t sa_mask;
581  void (*sa_restorer)();
582};
583#elif SANITIZER_ANDROID && SANITIZER_MIPS32  // check this before WORDSIZE == 32
584struct __sanitizer_sigaction {
585  unsigned sa_flags;
586  union {
587    __sanitizer_sigactionhandler_ptr sigaction;
588    __sanitizer_sighandler_ptr handler;
589  };
590  __sanitizer_sigset_t sa_mask;
591};
592#elif SANITIZER_ANDROID && (SANITIZER_WORDSIZE == 32)
593struct __sanitizer_sigaction {
594  union {
595    __sanitizer_sigactionhandler_ptr sigaction;
596    __sanitizer_sighandler_ptr handler;
597  };
598  __sanitizer_sigset_t sa_mask;
599  uptr sa_flags;
600  void (*sa_restorer)();
601};
602#else // !SANITIZER_ANDROID
603struct __sanitizer_sigaction {
604#if defined(__mips__) && !SANITIZER_FREEBSD
605  unsigned int sa_flags;
606#endif
607  union {
608    __sanitizer_sigactionhandler_ptr sigaction;
609    __sanitizer_sighandler_ptr handler;
610  };
611#if SANITIZER_FREEBSD
612  int sa_flags;
613  __sanitizer_sigset_t sa_mask;
614#else
615#if defined(__s390x__)
616  int sa_resv;
617#else
618  __sanitizer_sigset_t sa_mask;
619#endif
620#ifndef __mips__
621#if defined(__sparc__)
622#if __GLIBC_PREREQ (2, 20)
623  // On sparc glibc 2.19 and earlier sa_flags was unsigned long.
624#if defined(__arch64__)
625  // To maintain ABI compatibility on sparc64 when switching to an int,
626  // __glibc_reserved0 was added.
627  int __glibc_reserved0;
628#endif
629  int sa_flags;
630#else
631  unsigned long sa_flags;
632#endif
633#else
634  int sa_flags;
635#endif
636#endif
637#endif
638#if SANITIZER_LINUX
639  void (*sa_restorer)();
640#endif
641#if defined(__mips__) && (SANITIZER_WORDSIZE == 32)
642  int sa_resv[1];
643#endif
644#if defined(__s390x__)
645  __sanitizer_sigset_t sa_mask;
646#endif
647};
648#endif // !SANITIZER_ANDROID
649
650#if defined(__mips__)
651struct __sanitizer_kernel_sigset_t {
652  uptr sig[2];
653};
654#else
655struct __sanitizer_kernel_sigset_t {
656  u8 sig[8];
657};
658#endif
659
660// Linux system headers define the 'sa_handler' and 'sa_sigaction' macros.
661#if SANITIZER_MIPS
662struct __sanitizer_kernel_sigaction_t {
663  unsigned int sa_flags;
664  union {
665    void (*handler)(int signo);
666    void (*sigaction)(int signo, __sanitizer_siginfo *info, void *ctx);
667  };
668  __sanitizer_kernel_sigset_t sa_mask;
669  void (*sa_restorer)(void);
670};
671#else
672struct __sanitizer_kernel_sigaction_t {
673  union {
674    void (*handler)(int signo);
675    void (*sigaction)(int signo, __sanitizer_siginfo *info, void *ctx);
676  };
677  unsigned long sa_flags;
678  void (*sa_restorer)(void);
679  __sanitizer_kernel_sigset_t sa_mask;
680};
681#endif
682
683extern const uptr sig_ign;
684extern const uptr sig_dfl;
685extern const uptr sig_err;
686extern const uptr sa_siginfo;
687
688#if SANITIZER_LINUX
689extern int e_tabsz;
690#endif
691
692extern int af_inet;
693extern int af_inet6;
694uptr __sanitizer_in_addr_sz(int af);
695
696#if SANITIZER_LINUX
697struct __sanitizer_dl_phdr_info {
698  uptr dlpi_addr;
699  const char *dlpi_name;
700  const void *dlpi_phdr;
701  short dlpi_phnum;
702};
703
704extern unsigned struct_ElfW_Phdr_sz;
705#endif
706
707struct __sanitizer_protoent {
708  char *p_name;
709  char **p_aliases;
710  int p_proto;
711};
712
713struct __sanitizer_addrinfo {
714  int ai_flags;
715  int ai_family;
716  int ai_socktype;
717  int ai_protocol;
718#if SANITIZER_ANDROID || SANITIZER_MAC
719  unsigned ai_addrlen;
720  char *ai_canonname;
721  void *ai_addr;
722#else // LINUX
723  unsigned ai_addrlen;
724  void *ai_addr;
725  char *ai_canonname;
726#endif
727  struct __sanitizer_addrinfo *ai_next;
728};
729
730struct __sanitizer_hostent {
731  char *h_name;
732  char **h_aliases;
733  int h_addrtype;
734  int h_length;
735  char **h_addr_list;
736};
737
738struct __sanitizer_pollfd {
739  int fd;
740  short events;
741  short revents;
742};
743
744#if SANITIZER_ANDROID || SANITIZER_MAC
745typedef unsigned __sanitizer_nfds_t;
746#else
747typedef unsigned long __sanitizer_nfds_t;
748#endif
749
750#if !SANITIZER_ANDROID
751# if SANITIZER_LINUX
752struct __sanitizer_glob_t {
753  uptr gl_pathc;
754  char **gl_pathv;
755  uptr gl_offs;
756  int gl_flags;
757
758  void (*gl_closedir)(void *dirp);
759  void *(*gl_readdir)(void *dirp);
760  void *(*gl_opendir)(const char *);
761  int (*gl_lstat)(const char *, void *);
762  int (*gl_stat)(const char *, void *);
763};
764# endif  // SANITIZER_LINUX
765
766# if SANITIZER_LINUX
767extern int glob_nomatch;
768extern int glob_altdirfunc;
769# endif
770#endif  // !SANITIZER_ANDROID
771
772extern unsigned path_max;
773
774struct __sanitizer_wordexp_t {
775  uptr we_wordc;
776  char **we_wordv;
777  uptr we_offs;
778};
779
780#if SANITIZER_LINUX && !SANITIZER_ANDROID
781struct __sanitizer_FILE {
782  int _flags;
783  char *_IO_read_ptr;
784  char *_IO_read_end;
785  char *_IO_read_base;
786  char *_IO_write_base;
787  char *_IO_write_ptr;
788  char *_IO_write_end;
789  char *_IO_buf_base;
790  char *_IO_buf_end;
791  char *_IO_save_base;
792  char *_IO_backup_base;
793  char *_IO_save_end;
794  void *_markers;
795  __sanitizer_FILE *_chain;
796  int _fileno;
797};
798# define SANITIZER_HAS_STRUCT_FILE 1
799#else
800typedef void __sanitizer_FILE;
801# define SANITIZER_HAS_STRUCT_FILE 0
802#endif
803
804#if SANITIZER_LINUX && !SANITIZER_ANDROID &&                               \
805    (defined(__i386) || defined(__x86_64) || defined(__mips64) ||          \
806     defined(__powerpc64__) || defined(__aarch64__) || defined(__arm__) || \
807     defined(__s390__))
808extern unsigned struct_user_regs_struct_sz;
809extern unsigned struct_user_fpregs_struct_sz;
810extern unsigned struct_user_fpxregs_struct_sz;
811extern unsigned struct_user_vfpregs_struct_sz;
812
813extern int ptrace_peektext;
814extern int ptrace_peekdata;
815extern int ptrace_peekuser;
816extern int ptrace_getregs;
817extern int ptrace_setregs;
818extern int ptrace_getfpregs;
819extern int ptrace_setfpregs;
820extern int ptrace_getfpxregs;
821extern int ptrace_setfpxregs;
822extern int ptrace_getvfpregs;
823extern int ptrace_setvfpregs;
824extern int ptrace_getsiginfo;
825extern int ptrace_setsiginfo;
826extern int ptrace_getregset;
827extern int ptrace_setregset;
828extern int ptrace_geteventmsg;
829#endif
830
831#if SANITIZER_LINUX  && !SANITIZER_ANDROID
832extern unsigned struct_shminfo_sz;
833extern unsigned struct_shm_info_sz;
834extern int shmctl_ipc_stat;
835extern int shmctl_ipc_info;
836extern int shmctl_shm_info;
837extern int shmctl_shm_stat;
838#endif
839
840#if !SANITIZER_MAC && !SANITIZER_FREEBSD
841extern unsigned struct_utmp_sz;
842#endif
843#if !SANITIZER_ANDROID
844extern unsigned struct_utmpx_sz;
845#endif
846
847extern int map_fixed;
848
849// ioctl arguments
850struct __sanitizer_ifconf {
851  int ifc_len;
852  union {
853    void *ifcu_req;
854  } ifc_ifcu;
855#if SANITIZER_MAC
856} __attribute__((packed));
857#else
858};
859#endif
860
861#if SANITIZER_LINUX && !SANITIZER_ANDROID
862struct __sanitizer__obstack_chunk {
863  char *limit;
864  struct __sanitizer__obstack_chunk *prev;
865};
866
867struct __sanitizer_obstack {
868  long chunk_size;
869  struct __sanitizer__obstack_chunk *chunk;
870  char *object_base;
871  char *next_free;
872  uptr more_fields[7];
873};
874
875typedef uptr (*__sanitizer_cookie_io_read)(void *cookie, char *buf, uptr size);
876typedef uptr (*__sanitizer_cookie_io_write)(void *cookie, const char *buf,
877                                            uptr size);
878typedef int (*__sanitizer_cookie_io_seek)(void *cookie, u64 *offset,
879                                          int whence);
880typedef int (*__sanitizer_cookie_io_close)(void *cookie);
881
882struct __sanitizer_cookie_io_functions_t {
883  __sanitizer_cookie_io_read read;
884  __sanitizer_cookie_io_write write;
885  __sanitizer_cookie_io_seek seek;
886  __sanitizer_cookie_io_close close;
887};
888#endif
889
890#define IOC_NRBITS 8
891#define IOC_TYPEBITS 8
892#if defined(__powerpc__) || defined(__powerpc64__) || defined(__mips__) || \
893    defined(__sparc__)
894#define IOC_SIZEBITS 13
895#define IOC_DIRBITS 3
896#define IOC_NONE 1U
897#define IOC_WRITE 4U
898#define IOC_READ 2U
899#else
900#define IOC_SIZEBITS 14
901#define IOC_DIRBITS 2
902#define IOC_NONE 0U
903#define IOC_WRITE 1U
904#define IOC_READ 2U
905#endif
906#define IOC_NRMASK ((1 << IOC_NRBITS) - 1)
907#define IOC_TYPEMASK ((1 << IOC_TYPEBITS) - 1)
908#define IOC_SIZEMASK ((1 << IOC_SIZEBITS) - 1)
909#if defined(IOC_DIRMASK)
910#undef IOC_DIRMASK
911#endif
912#define IOC_DIRMASK ((1 << IOC_DIRBITS) - 1)
913#define IOC_NRSHIFT 0
914#define IOC_TYPESHIFT (IOC_NRSHIFT + IOC_NRBITS)
915#define IOC_SIZESHIFT (IOC_TYPESHIFT + IOC_TYPEBITS)
916#define IOC_DIRSHIFT (IOC_SIZESHIFT + IOC_SIZEBITS)
917#define EVIOC_EV_MAX 0x1f
918#define EVIOC_ABS_MAX 0x3f
919
920#define IOC_DIR(nr) (((nr) >> IOC_DIRSHIFT) & IOC_DIRMASK)
921#define IOC_TYPE(nr) (((nr) >> IOC_TYPESHIFT) & IOC_TYPEMASK)
922#define IOC_NR(nr) (((nr) >> IOC_NRSHIFT) & IOC_NRMASK)
923
924#if defined(__sparc__)
925// In sparc the 14 bits SIZE field overlaps with the
926// least significant bit of DIR, so either IOC_READ or
927// IOC_WRITE shall be 1 in order to get a non-zero SIZE.
928#define IOC_SIZE(nr) \
929  ((((((nr) >> 29) & 0x7) & (4U | 2U)) == 0) ? 0 : (((nr) >> 16) & 0x3fff))
930#else
931#define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK)
932#endif
933
934extern unsigned struct_ifreq_sz;
935extern unsigned struct_termios_sz;
936extern unsigned struct_winsize_sz;
937
938#if SANITIZER_LINUX
939extern unsigned struct_arpreq_sz;
940extern unsigned struct_cdrom_msf_sz;
941extern unsigned struct_cdrom_multisession_sz;
942extern unsigned struct_cdrom_read_audio_sz;
943extern unsigned struct_cdrom_subchnl_sz;
944extern unsigned struct_cdrom_ti_sz;
945extern unsigned struct_cdrom_tocentry_sz;
946extern unsigned struct_cdrom_tochdr_sz;
947extern unsigned struct_cdrom_volctrl_sz;
948extern unsigned struct_ff_effect_sz;
949extern unsigned struct_floppy_drive_params_sz;
950extern unsigned struct_floppy_drive_struct_sz;
951extern unsigned struct_floppy_fdc_state_sz;
952extern unsigned struct_floppy_max_errors_sz;
953extern unsigned struct_floppy_raw_cmd_sz;
954extern unsigned struct_floppy_struct_sz;
955extern unsigned struct_floppy_write_errors_sz;
956extern unsigned struct_format_descr_sz;
957extern unsigned struct_hd_driveid_sz;
958extern unsigned struct_hd_geometry_sz;
959extern unsigned struct_input_absinfo_sz;
960extern unsigned struct_input_id_sz;
961extern unsigned struct_mtpos_sz;
962extern unsigned struct_termio_sz;
963extern unsigned struct_vt_consize_sz;
964extern unsigned struct_vt_sizes_sz;
965extern unsigned struct_vt_stat_sz;
966#endif  // SANITIZER_LINUX
967
968#if SANITIZER_LINUX
969extern unsigned struct_copr_buffer_sz;
970extern unsigned struct_copr_debug_buf_sz;
971extern unsigned struct_copr_msg_sz;
972extern unsigned struct_midi_info_sz;
973extern unsigned struct_mtget_sz;
974extern unsigned struct_mtop_sz;
975extern unsigned struct_rtentry_sz;
976extern unsigned struct_sbi_instrument_sz;
977extern unsigned struct_seq_event_rec_sz;
978extern unsigned struct_synth_info_sz;
979extern unsigned struct_vt_mode_sz;
980#endif // SANITIZER_LINUX
981
982#if SANITIZER_LINUX && !SANITIZER_ANDROID
983extern unsigned struct_ax25_parms_struct_sz;
984extern unsigned struct_cyclades_monitor_sz;
985extern unsigned struct_input_keymap_entry_sz;
986extern unsigned struct_ipx_config_data_sz;
987extern unsigned struct_kbdiacrs_sz;
988extern unsigned struct_kbentry_sz;
989extern unsigned struct_kbkeycode_sz;
990extern unsigned struct_kbsentry_sz;
991extern unsigned struct_mtconfiginfo_sz;
992extern unsigned struct_nr_parms_struct_sz;
993extern unsigned struct_scc_modem_sz;
994extern unsigned struct_scc_stat_sz;
995extern unsigned struct_serial_multiport_struct_sz;
996extern unsigned struct_serial_struct_sz;
997extern unsigned struct_sockaddr_ax25_sz;
998extern unsigned struct_unimapdesc_sz;
999extern unsigned struct_unimapinit_sz;
1000#endif  // SANITIZER_LINUX && !SANITIZER_ANDROID
1001
1002extern const unsigned long __sanitizer_bufsiz;
1003
1004#if SANITIZER_LINUX && !SANITIZER_ANDROID
1005extern unsigned struct_audio_buf_info_sz;
1006extern unsigned struct_ppp_stats_sz;
1007#endif  // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
1008
1009#if !SANITIZER_ANDROID && !SANITIZER_MAC
1010extern unsigned struct_sioc_sg_req_sz;
1011extern unsigned struct_sioc_vif_req_sz;
1012#endif
1013
1014// ioctl request identifiers
1015
1016// A special value to mark ioctls that are not present on the target platform,
1017// when it can not be determined without including any system headers.
1018extern const unsigned IOCTL_NOT_PRESENT;
1019
1020extern unsigned IOCTL_FIOASYNC;
1021extern unsigned IOCTL_FIOCLEX;
1022extern unsigned IOCTL_FIOGETOWN;
1023extern unsigned IOCTL_FIONBIO;
1024extern unsigned IOCTL_FIONCLEX;
1025extern unsigned IOCTL_FIOSETOWN;
1026extern unsigned IOCTL_SIOCADDMULTI;
1027extern unsigned IOCTL_SIOCATMARK;
1028extern unsigned IOCTL_SIOCDELMULTI;
1029extern unsigned IOCTL_SIOCGIFADDR;
1030extern unsigned IOCTL_SIOCGIFBRDADDR;
1031extern unsigned IOCTL_SIOCGIFCONF;
1032extern unsigned IOCTL_SIOCGIFDSTADDR;
1033extern unsigned IOCTL_SIOCGIFFLAGS;
1034extern unsigned IOCTL_SIOCGIFMETRIC;
1035extern unsigned IOCTL_SIOCGIFMTU;
1036extern unsigned IOCTL_SIOCGIFNETMASK;
1037extern unsigned IOCTL_SIOCGPGRP;
1038extern unsigned IOCTL_SIOCSIFADDR;
1039extern unsigned IOCTL_SIOCSIFBRDADDR;
1040extern unsigned IOCTL_SIOCSIFDSTADDR;
1041extern unsigned IOCTL_SIOCSIFFLAGS;
1042extern unsigned IOCTL_SIOCSIFMETRIC;
1043extern unsigned IOCTL_SIOCSIFMTU;
1044extern unsigned IOCTL_SIOCSIFNETMASK;
1045extern unsigned IOCTL_SIOCSPGRP;
1046extern unsigned IOCTL_TIOCCONS;
1047extern unsigned IOCTL_TIOCEXCL;
1048extern unsigned IOCTL_TIOCGETD;
1049extern unsigned IOCTL_TIOCGPGRP;
1050extern unsigned IOCTL_TIOCGWINSZ;
1051extern unsigned IOCTL_TIOCMBIC;
1052extern unsigned IOCTL_TIOCMBIS;
1053extern unsigned IOCTL_TIOCMGET;
1054extern unsigned IOCTL_TIOCMSET;
1055extern unsigned IOCTL_TIOCNOTTY;
1056extern unsigned IOCTL_TIOCNXCL;
1057extern unsigned IOCTL_TIOCOUTQ;
1058extern unsigned IOCTL_TIOCPKT;
1059extern unsigned IOCTL_TIOCSCTTY;
1060extern unsigned IOCTL_TIOCSETD;
1061extern unsigned IOCTL_TIOCSPGRP;
1062extern unsigned IOCTL_TIOCSTI;
1063extern unsigned IOCTL_TIOCSWINSZ;
1064#if SANITIZER_LINUX && !SANITIZER_ANDROID
1065extern unsigned IOCTL_SIOCGETSGCNT;
1066extern unsigned IOCTL_SIOCGETVIFCNT;
1067#endif
1068#if SANITIZER_LINUX
1069extern unsigned IOCTL_EVIOCGABS;
1070extern unsigned IOCTL_EVIOCGBIT;
1071extern unsigned IOCTL_EVIOCGEFFECTS;
1072extern unsigned IOCTL_EVIOCGID;
1073extern unsigned IOCTL_EVIOCGKEY;
1074extern unsigned IOCTL_EVIOCGKEYCODE;
1075extern unsigned IOCTL_EVIOCGLED;
1076extern unsigned IOCTL_EVIOCGNAME;
1077extern unsigned IOCTL_EVIOCGPHYS;
1078extern unsigned IOCTL_EVIOCGRAB;
1079extern unsigned IOCTL_EVIOCGREP;
1080extern unsigned IOCTL_EVIOCGSND;
1081extern unsigned IOCTL_EVIOCGSW;
1082extern unsigned IOCTL_EVIOCGUNIQ;
1083extern unsigned IOCTL_EVIOCGVERSION;
1084extern unsigned IOCTL_EVIOCRMFF;
1085extern unsigned IOCTL_EVIOCSABS;
1086extern unsigned IOCTL_EVIOCSFF;
1087extern unsigned IOCTL_EVIOCSKEYCODE;
1088extern unsigned IOCTL_EVIOCSREP;
1089extern unsigned IOCTL_BLKFLSBUF;
1090extern unsigned IOCTL_BLKGETSIZE;
1091extern unsigned IOCTL_BLKRAGET;
1092extern unsigned IOCTL_BLKRASET;
1093extern unsigned IOCTL_BLKROGET;
1094extern unsigned IOCTL_BLKROSET;
1095extern unsigned IOCTL_BLKRRPART;
1096extern unsigned IOCTL_CDROMAUDIOBUFSIZ;
1097extern unsigned IOCTL_CDROMEJECT;
1098extern unsigned IOCTL_CDROMEJECT_SW;
1099extern unsigned IOCTL_CDROMMULTISESSION;
1100extern unsigned IOCTL_CDROMPAUSE;
1101extern unsigned IOCTL_CDROMPLAYMSF;
1102extern unsigned IOCTL_CDROMPLAYTRKIND;
1103extern unsigned IOCTL_CDROMREADAUDIO;
1104extern unsigned IOCTL_CDROMREADCOOKED;
1105extern unsigned IOCTL_CDROMREADMODE1;
1106extern unsigned IOCTL_CDROMREADMODE2;
1107extern unsigned IOCTL_CDROMREADRAW;
1108extern unsigned IOCTL_CDROMREADTOCENTRY;
1109extern unsigned IOCTL_CDROMREADTOCHDR;
1110extern unsigned IOCTL_CDROMRESET;
1111extern unsigned IOCTL_CDROMRESUME;
1112extern unsigned IOCTL_CDROMSEEK;
1113extern unsigned IOCTL_CDROMSTART;
1114extern unsigned IOCTL_CDROMSTOP;
1115extern unsigned IOCTL_CDROMSUBCHNL;
1116extern unsigned IOCTL_CDROMVOLCTRL;
1117extern unsigned IOCTL_CDROMVOLREAD;
1118extern unsigned IOCTL_CDROM_GET_UPC;
1119extern unsigned IOCTL_FDCLRPRM;
1120extern unsigned IOCTL_FDDEFPRM;
1121extern unsigned IOCTL_FDFLUSH;
1122extern unsigned IOCTL_FDFMTBEG;
1123extern unsigned IOCTL_FDFMTEND;
1124extern unsigned IOCTL_FDFMTTRK;
1125extern unsigned IOCTL_FDGETDRVPRM;
1126extern unsigned IOCTL_FDGETDRVSTAT;
1127extern unsigned IOCTL_FDGETDRVTYP;
1128extern unsigned IOCTL_FDGETFDCSTAT;
1129extern unsigned IOCTL_FDGETMAXERRS;
1130extern unsigned IOCTL_FDGETPRM;
1131extern unsigned IOCTL_FDMSGOFF;
1132extern unsigned IOCTL_FDMSGON;
1133extern unsigned IOCTL_FDPOLLDRVSTAT;
1134extern unsigned IOCTL_FDRAWCMD;
1135extern unsigned IOCTL_FDRESET;
1136extern unsigned IOCTL_FDSETDRVPRM;
1137extern unsigned IOCTL_FDSETEMSGTRESH;
1138extern unsigned IOCTL_FDSETMAXERRS;
1139extern unsigned IOCTL_FDSETPRM;
1140extern unsigned IOCTL_FDTWADDLE;
1141extern unsigned IOCTL_FDWERRORCLR;
1142extern unsigned IOCTL_FDWERRORGET;
1143extern unsigned IOCTL_HDIO_DRIVE_CMD;
1144extern unsigned IOCTL_HDIO_GETGEO;
1145extern unsigned IOCTL_HDIO_GET_32BIT;
1146extern unsigned IOCTL_HDIO_GET_DMA;
1147extern unsigned IOCTL_HDIO_GET_IDENTITY;
1148extern unsigned IOCTL_HDIO_GET_KEEPSETTINGS;
1149extern unsigned IOCTL_HDIO_GET_MULTCOUNT;
1150extern unsigned IOCTL_HDIO_GET_NOWERR;
1151extern unsigned IOCTL_HDIO_GET_UNMASKINTR;
1152extern unsigned IOCTL_HDIO_SET_32BIT;
1153extern unsigned IOCTL_HDIO_SET_DMA;
1154extern unsigned IOCTL_HDIO_SET_KEEPSETTINGS;
1155extern unsigned IOCTL_HDIO_SET_MULTCOUNT;
1156extern unsigned IOCTL_HDIO_SET_NOWERR;
1157extern unsigned IOCTL_HDIO_SET_UNMASKINTR;
1158extern unsigned IOCTL_MTIOCPOS;
1159extern unsigned IOCTL_PPPIOCGASYNCMAP;
1160extern unsigned IOCTL_PPPIOCGDEBUG;
1161extern unsigned IOCTL_PPPIOCGFLAGS;
1162extern unsigned IOCTL_PPPIOCGUNIT;
1163extern unsigned IOCTL_PPPIOCGXASYNCMAP;
1164extern unsigned IOCTL_PPPIOCSASYNCMAP;
1165extern unsigned IOCTL_PPPIOCSDEBUG;
1166extern unsigned IOCTL_PPPIOCSFLAGS;
1167extern unsigned IOCTL_PPPIOCSMAXCID;
1168extern unsigned IOCTL_PPPIOCSMRU;
1169extern unsigned IOCTL_PPPIOCSXASYNCMAP;
1170extern unsigned IOCTL_SIOCDARP;
1171extern unsigned IOCTL_SIOCDRARP;
1172extern unsigned IOCTL_SIOCGARP;
1173extern unsigned IOCTL_SIOCGIFENCAP;
1174extern unsigned IOCTL_SIOCGIFHWADDR;
1175extern unsigned IOCTL_SIOCGIFMAP;
1176extern unsigned IOCTL_SIOCGIFMEM;
1177extern unsigned IOCTL_SIOCGIFNAME;
1178extern unsigned IOCTL_SIOCGIFSLAVE;
1179extern unsigned IOCTL_SIOCGRARP;
1180extern unsigned IOCTL_SIOCGSTAMP;
1181extern unsigned IOCTL_SIOCSARP;
1182extern unsigned IOCTL_SIOCSIFENCAP;
1183extern unsigned IOCTL_SIOCSIFHWADDR;
1184extern unsigned IOCTL_SIOCSIFLINK;
1185extern unsigned IOCTL_SIOCSIFMAP;
1186extern unsigned IOCTL_SIOCSIFMEM;
1187extern unsigned IOCTL_SIOCSIFSLAVE;
1188extern unsigned IOCTL_SIOCSRARP;
1189extern unsigned IOCTL_SNDCTL_COPR_HALT;
1190extern unsigned IOCTL_SNDCTL_COPR_LOAD;
1191extern unsigned IOCTL_SNDCTL_COPR_RCODE;
1192extern unsigned IOCTL_SNDCTL_COPR_RCVMSG;
1193extern unsigned IOCTL_SNDCTL_COPR_RDATA;
1194extern unsigned IOCTL_SNDCTL_COPR_RESET;
1195extern unsigned IOCTL_SNDCTL_COPR_RUN;
1196extern unsigned IOCTL_SNDCTL_COPR_SENDMSG;
1197extern unsigned IOCTL_SNDCTL_COPR_WCODE;
1198extern unsigned IOCTL_SNDCTL_COPR_WDATA;
1199extern unsigned IOCTL_TCFLSH;
1200extern unsigned IOCTL_TCGETA;
1201extern unsigned IOCTL_TCGETS;
1202extern unsigned IOCTL_TCSBRK;
1203extern unsigned IOCTL_TCSBRKP;
1204extern unsigned IOCTL_TCSETA;
1205extern unsigned IOCTL_TCSETAF;
1206extern unsigned IOCTL_TCSETAW;
1207extern unsigned IOCTL_TCSETS;
1208extern unsigned IOCTL_TCSETSF;
1209extern unsigned IOCTL_TCSETSW;
1210extern unsigned IOCTL_TCXONC;
1211extern unsigned IOCTL_TIOCGLCKTRMIOS;
1212extern unsigned IOCTL_TIOCGSOFTCAR;
1213extern unsigned IOCTL_TIOCINQ;
1214extern unsigned IOCTL_TIOCLINUX;
1215extern unsigned IOCTL_TIOCSERCONFIG;
1216extern unsigned IOCTL_TIOCSERGETLSR;
1217extern unsigned IOCTL_TIOCSERGWILD;
1218extern unsigned IOCTL_TIOCSERSWILD;
1219extern unsigned IOCTL_TIOCSLCKTRMIOS;
1220extern unsigned IOCTL_TIOCSSOFTCAR;
1221extern unsigned IOCTL_VT_DISALLOCATE;
1222extern unsigned IOCTL_VT_GETSTATE;
1223extern unsigned IOCTL_VT_RESIZE;
1224extern unsigned IOCTL_VT_RESIZEX;
1225extern unsigned IOCTL_VT_SENDSIG;
1226extern unsigned IOCTL_MTIOCGET;
1227extern unsigned IOCTL_MTIOCTOP;
1228extern unsigned IOCTL_SIOCADDRT;
1229extern unsigned IOCTL_SIOCDELRT;
1230extern unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE;
1231extern unsigned IOCTL_SNDCTL_DSP_GETFMTS;
1232extern unsigned IOCTL_SNDCTL_DSP_NONBLOCK;
1233extern unsigned IOCTL_SNDCTL_DSP_POST;
1234extern unsigned IOCTL_SNDCTL_DSP_RESET;
1235extern unsigned IOCTL_SNDCTL_DSP_SETFMT;
1236extern unsigned IOCTL_SNDCTL_DSP_SETFRAGMENT;
1237extern unsigned IOCTL_SNDCTL_DSP_SPEED;
1238extern unsigned IOCTL_SNDCTL_DSP_STEREO;
1239extern unsigned IOCTL_SNDCTL_DSP_SUBDIVIDE;
1240extern unsigned IOCTL_SNDCTL_DSP_SYNC;
1241extern unsigned IOCTL_SNDCTL_FM_4OP_ENABLE;
1242extern unsigned IOCTL_SNDCTL_FM_LOAD_INSTR;
1243extern unsigned IOCTL_SNDCTL_MIDI_INFO;
1244extern unsigned IOCTL_SNDCTL_MIDI_PRETIME;
1245extern unsigned IOCTL_SNDCTL_SEQ_CTRLRATE;
1246extern unsigned IOCTL_SNDCTL_SEQ_GETINCOUNT;
1247extern unsigned IOCTL_SNDCTL_SEQ_GETOUTCOUNT;
1248extern unsigned IOCTL_SNDCTL_SEQ_NRMIDIS;
1249extern unsigned IOCTL_SNDCTL_SEQ_NRSYNTHS;
1250extern unsigned IOCTL_SNDCTL_SEQ_OUTOFBAND;
1251extern unsigned IOCTL_SNDCTL_SEQ_PANIC;
1252extern unsigned IOCTL_SNDCTL_SEQ_PERCMODE;
1253extern unsigned IOCTL_SNDCTL_SEQ_RESET;
1254extern unsigned IOCTL_SNDCTL_SEQ_RESETSAMPLES;
1255extern unsigned IOCTL_SNDCTL_SEQ_SYNC;
1256extern unsigned IOCTL_SNDCTL_SEQ_TESTMIDI;
1257extern unsigned IOCTL_SNDCTL_SEQ_THRESHOLD;
1258extern unsigned IOCTL_SNDCTL_SYNTH_INFO;
1259extern unsigned IOCTL_SNDCTL_SYNTH_MEMAVL;
1260extern unsigned IOCTL_SNDCTL_TMR_CONTINUE;
1261extern unsigned IOCTL_SNDCTL_TMR_METRONOME;
1262extern unsigned IOCTL_SNDCTL_TMR_SELECT;
1263extern unsigned IOCTL_SNDCTL_TMR_SOURCE;
1264extern unsigned IOCTL_SNDCTL_TMR_START;
1265extern unsigned IOCTL_SNDCTL_TMR_STOP;
1266extern unsigned IOCTL_SNDCTL_TMR_TEMPO;
1267extern unsigned IOCTL_SNDCTL_TMR_TIMEBASE;
1268extern unsigned IOCTL_SOUND_MIXER_READ_ALTPCM;
1269extern unsigned IOCTL_SOUND_MIXER_READ_BASS;
1270extern unsigned IOCTL_SOUND_MIXER_READ_CAPS;
1271extern unsigned IOCTL_SOUND_MIXER_READ_CD;
1272extern unsigned IOCTL_SOUND_MIXER_READ_DEVMASK;
1273extern unsigned IOCTL_SOUND_MIXER_READ_ENHANCE;
1274extern unsigned IOCTL_SOUND_MIXER_READ_IGAIN;
1275extern unsigned IOCTL_SOUND_MIXER_READ_IMIX;
1276extern unsigned IOCTL_SOUND_MIXER_READ_LINE1;
1277extern unsigned IOCTL_SOUND_MIXER_READ_LINE2;
1278extern unsigned IOCTL_SOUND_MIXER_READ_LINE3;
1279extern unsigned IOCTL_SOUND_MIXER_READ_LINE;
1280extern unsigned IOCTL_SOUND_MIXER_READ_LOUD;
1281extern unsigned IOCTL_SOUND_MIXER_READ_MIC;
1282extern unsigned IOCTL_SOUND_MIXER_READ_MUTE;
1283extern unsigned IOCTL_SOUND_MIXER_READ_OGAIN;
1284extern unsigned IOCTL_SOUND_MIXER_READ_PCM;
1285extern unsigned IOCTL_SOUND_MIXER_READ_RECLEV;
1286extern unsigned IOCTL_SOUND_MIXER_READ_RECMASK;
1287extern unsigned IOCTL_SOUND_MIXER_READ_RECSRC;
1288extern unsigned IOCTL_SOUND_MIXER_READ_SPEAKER;
1289extern unsigned IOCTL_SOUND_MIXER_READ_STEREODEVS;
1290extern unsigned IOCTL_SOUND_MIXER_READ_SYNTH;
1291extern unsigned IOCTL_SOUND_MIXER_READ_TREBLE;
1292extern unsigned IOCTL_SOUND_MIXER_READ_VOLUME;
1293extern unsigned IOCTL_SOUND_MIXER_WRITE_ALTPCM;
1294extern unsigned IOCTL_SOUND_MIXER_WRITE_BASS;
1295extern unsigned IOCTL_SOUND_MIXER_WRITE_CD;
1296extern unsigned IOCTL_SOUND_MIXER_WRITE_ENHANCE;
1297extern unsigned IOCTL_SOUND_MIXER_WRITE_IGAIN;
1298extern unsigned IOCTL_SOUND_MIXER_WRITE_IMIX;
1299extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE1;
1300extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE2;
1301extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE3;
1302extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE;
1303extern unsigned IOCTL_SOUND_MIXER_WRITE_LOUD;
1304extern unsigned IOCTL_SOUND_MIXER_WRITE_MIC;
1305extern unsigned IOCTL_SOUND_MIXER_WRITE_MUTE;
1306extern unsigned IOCTL_SOUND_MIXER_WRITE_OGAIN;
1307extern unsigned IOCTL_SOUND_MIXER_WRITE_PCM;
1308extern unsigned IOCTL_SOUND_MIXER_WRITE_RECLEV;
1309extern unsigned IOCTL_SOUND_MIXER_WRITE_RECSRC;
1310extern unsigned IOCTL_SOUND_MIXER_WRITE_SPEAKER;
1311extern unsigned IOCTL_SOUND_MIXER_WRITE_SYNTH;
1312extern unsigned IOCTL_SOUND_MIXER_WRITE_TREBLE;
1313extern unsigned IOCTL_SOUND_MIXER_WRITE_VOLUME;
1314extern unsigned IOCTL_SOUND_PCM_READ_BITS;
1315extern unsigned IOCTL_SOUND_PCM_READ_CHANNELS;
1316extern unsigned IOCTL_SOUND_PCM_READ_FILTER;
1317extern unsigned IOCTL_SOUND_PCM_READ_RATE;
1318extern unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS;
1319extern unsigned IOCTL_SOUND_PCM_WRITE_FILTER;
1320extern unsigned IOCTL_VT_ACTIVATE;
1321extern unsigned IOCTL_VT_GETMODE;
1322extern unsigned IOCTL_VT_OPENQRY;
1323extern unsigned IOCTL_VT_RELDISP;
1324extern unsigned IOCTL_VT_SETMODE;
1325extern unsigned IOCTL_VT_WAITACTIVE;
1326#endif  // SANITIZER_LINUX
1327
1328#if SANITIZER_LINUX && !SANITIZER_ANDROID
1329extern unsigned IOCTL_CYGETDEFTHRESH;
1330extern unsigned IOCTL_CYGETDEFTIMEOUT;
1331extern unsigned IOCTL_CYGETMON;
1332extern unsigned IOCTL_CYGETTHRESH;
1333extern unsigned IOCTL_CYGETTIMEOUT;
1334extern unsigned IOCTL_CYSETDEFTHRESH;
1335extern unsigned IOCTL_CYSETDEFTIMEOUT;
1336extern unsigned IOCTL_CYSETTHRESH;
1337extern unsigned IOCTL_CYSETTIMEOUT;
1338extern unsigned IOCTL_EQL_EMANCIPATE;
1339extern unsigned IOCTL_EQL_ENSLAVE;
1340extern unsigned IOCTL_EQL_GETMASTRCFG;
1341extern unsigned IOCTL_EQL_GETSLAVECFG;
1342extern unsigned IOCTL_EQL_SETMASTRCFG;
1343extern unsigned IOCTL_EQL_SETSLAVECFG;
1344extern unsigned IOCTL_EVIOCGKEYCODE_V2;
1345extern unsigned IOCTL_EVIOCGPROP;
1346extern unsigned IOCTL_EVIOCSKEYCODE_V2;
1347extern unsigned IOCTL_FS_IOC_GETFLAGS;
1348extern unsigned IOCTL_FS_IOC_GETVERSION;
1349extern unsigned IOCTL_FS_IOC_SETFLAGS;
1350extern unsigned IOCTL_FS_IOC_SETVERSION;
1351extern unsigned IOCTL_GIO_CMAP;
1352extern unsigned IOCTL_GIO_FONT;
1353extern unsigned IOCTL_GIO_UNIMAP;
1354extern unsigned IOCTL_GIO_UNISCRNMAP;
1355extern unsigned IOCTL_KDADDIO;
1356extern unsigned IOCTL_KDDELIO;
1357extern unsigned IOCTL_KDGETKEYCODE;
1358extern unsigned IOCTL_KDGKBDIACR;
1359extern unsigned IOCTL_KDGKBENT;
1360extern unsigned IOCTL_KDGKBLED;
1361extern unsigned IOCTL_KDGKBMETA;
1362extern unsigned IOCTL_KDGKBSENT;
1363extern unsigned IOCTL_KDMAPDISP;
1364extern unsigned IOCTL_KDSETKEYCODE;
1365extern unsigned IOCTL_KDSIGACCEPT;
1366extern unsigned IOCTL_KDSKBDIACR;
1367extern unsigned IOCTL_KDSKBENT;
1368extern unsigned IOCTL_KDSKBLED;
1369extern unsigned IOCTL_KDSKBMETA;
1370extern unsigned IOCTL_KDSKBSENT;
1371extern unsigned IOCTL_KDUNMAPDISP;
1372extern unsigned IOCTL_LPABORT;
1373extern unsigned IOCTL_LPABORTOPEN;
1374extern unsigned IOCTL_LPCAREFUL;
1375extern unsigned IOCTL_LPCHAR;
1376extern unsigned IOCTL_LPGETIRQ;
1377extern unsigned IOCTL_LPGETSTATUS;
1378extern unsigned IOCTL_LPRESET;
1379extern unsigned IOCTL_LPSETIRQ;
1380extern unsigned IOCTL_LPTIME;
1381extern unsigned IOCTL_LPWAIT;
1382extern unsigned IOCTL_MTIOCGETCONFIG;
1383extern unsigned IOCTL_MTIOCSETCONFIG;
1384extern unsigned IOCTL_PIO_CMAP;
1385extern unsigned IOCTL_PIO_FONT;
1386extern unsigned IOCTL_PIO_UNIMAP;
1387extern unsigned IOCTL_PIO_UNIMAPCLR;
1388extern unsigned IOCTL_PIO_UNISCRNMAP;
1389extern unsigned IOCTL_SCSI_IOCTL_GET_IDLUN;
1390extern unsigned IOCTL_SCSI_IOCTL_PROBE_HOST;
1391extern unsigned IOCTL_SCSI_IOCTL_TAGGED_DISABLE;
1392extern unsigned IOCTL_SCSI_IOCTL_TAGGED_ENABLE;
1393extern unsigned IOCTL_SIOCAIPXITFCRT;
1394extern unsigned IOCTL_SIOCAIPXPRISLT;
1395extern unsigned IOCTL_SIOCAX25ADDUID;
1396extern unsigned IOCTL_SIOCAX25DELUID;
1397extern unsigned IOCTL_SIOCAX25GETPARMS;
1398extern unsigned IOCTL_SIOCAX25GETUID;
1399extern unsigned IOCTL_SIOCAX25NOUID;
1400extern unsigned IOCTL_SIOCAX25SETPARMS;
1401extern unsigned IOCTL_SIOCDEVPLIP;
1402extern unsigned IOCTL_SIOCIPXCFGDATA;
1403extern unsigned IOCTL_SIOCNRDECOBS;
1404extern unsigned IOCTL_SIOCNRGETPARMS;
1405extern unsigned IOCTL_SIOCNRRTCTL;
1406extern unsigned IOCTL_SIOCNRSETPARMS;
1407extern unsigned IOCTL_SNDCTL_DSP_GETISPACE;
1408extern unsigned IOCTL_SNDCTL_DSP_GETOSPACE;
1409extern unsigned IOCTL_TIOCGSERIAL;
1410extern unsigned IOCTL_TIOCSERGETMULTI;
1411extern unsigned IOCTL_TIOCSERSETMULTI;
1412extern unsigned IOCTL_TIOCSSERIAL;
1413extern unsigned IOCTL_GIO_SCRNMAP;
1414extern unsigned IOCTL_KDDISABIO;
1415extern unsigned IOCTL_KDENABIO;
1416extern unsigned IOCTL_KDGETLED;
1417extern unsigned IOCTL_KDGETMODE;
1418extern unsigned IOCTL_KDGKBMODE;
1419extern unsigned IOCTL_KDGKBTYPE;
1420extern unsigned IOCTL_KDMKTONE;
1421extern unsigned IOCTL_KDSETLED;
1422extern unsigned IOCTL_KDSETMODE;
1423extern unsigned IOCTL_KDSKBMODE;
1424extern unsigned IOCTL_KIOCSOUND;
1425extern unsigned IOCTL_PIO_SCRNMAP;
1426#endif
1427
1428extern const int si_SEGV_MAPERR;
1429extern const int si_SEGV_ACCERR;
1430}  // namespace __sanitizer
1431
1432#define CHECK_TYPE_SIZE(TYPE) \
1433  COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
1434
1435#define CHECK_SIZE_AND_OFFSET(CLASS, MEMBER)                      \
1436  COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *)NULL)->MEMBER) == \
1437                 sizeof(((CLASS *)NULL)->MEMBER));                \
1438  COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==         \
1439                 offsetof(CLASS, MEMBER))
1440
1441// For sigaction, which is a function and struct at the same time,
1442// and thus requires explicit "struct" in sizeof() expression.
1443#define CHECK_STRUCT_SIZE_AND_OFFSET(CLASS, MEMBER)                      \
1444  COMPILER_CHECK(sizeof(((struct __sanitizer_##CLASS *)NULL)->MEMBER) == \
1445                 sizeof(((struct CLASS *)NULL)->MEMBER));                \
1446  COMPILER_CHECK(offsetof(struct __sanitizer_##CLASS, MEMBER) ==         \
1447                 offsetof(struct CLASS, MEMBER))
1448
1449#define SIGACTION_SYMNAME sigaction
1450
1451#endif  // SANITIZER_LINUX || SANITIZER_MAC
1452
1453#endif
1454