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