Home | History | Annotate | Download | only in sanitizer_common
      1 //===-- sanitizer_platform_limits_posix.cc --------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file is a part of Sanitizer common code.
     11 //
     12 // Sizes and layouts of platform-specific POSIX data structures.
     13 //===----------------------------------------------------------------------===//
     14 
     15 
     16 #include "sanitizer_platform.h"
     17 #if SANITIZER_LINUX || SANITIZER_MAC
     18 
     19 #include "sanitizer_internal_defs.h"
     20 #include "sanitizer_platform_limits_posix.h"
     21 
     22 #include <arpa/inet.h>
     23 #include <dirent.h>
     24 #include <grp.h>
     25 #include <limits.h>
     26 #include <net/if.h>
     27 #include <net/if_arp.h>
     28 #include <net/route.h>
     29 #include <netdb.h>
     30 #include <pthread.h>
     31 #include <pwd.h>
     32 #include <signal.h>
     33 #include <stddef.h>
     34 #include <sys/resource.h>
     35 #include <sys/socket.h>
     36 #include <sys/stat.h>
     37 #include <sys/time.h>
     38 #include <sys/types.h>
     39 #include <sys/utsname.h>
     40 #include <termios.h>
     41 #include <time.h>
     42 #include <wchar.h>
     43 
     44 #if SANITIZER_LINUX
     45 #include <sys/mount.h>
     46 #include <sys/ptrace.h>
     47 #include <sys/sysinfo.h>
     48 #include <sys/vt.h>
     49 #include <linux/cdrom.h>
     50 #include <linux/fd.h>
     51 #include <linux/fs.h>
     52 #include <linux/hdreg.h>
     53 #include <linux/input.h>
     54 #include <linux/ioctl.h>
     55 #include <linux/soundcard.h>
     56 #endif
     57 
     58 #if !SANITIZER_ANDROID
     59 #include <sys/ucontext.h>
     60 #endif
     61 
     62 #if SANITIZER_LINUX && !SANITIZER_ANDROID
     63 #include <glob.h>
     64 #include <net/if_ppp.h>
     65 #include <netax25/ax25.h>
     66 #include <netipx/ipx.h>
     67 #include <netrom/netrom.h>
     68 #include <scsi/scsi.h>
     69 #include <sys/mtio.h>
     70 #include <sys/kd.h>
     71 #include <sys/user.h>
     72 #include <linux/cyclades.h>
     73 #include <linux/if_eql.h>
     74 #include <linux/if_plip.h>
     75 #include <linux/lp.h>
     76 #include <linux/mroute.h>
     77 #include <linux/mroute6.h>
     78 #include <linux/scc.h>
     79 #include <linux/serial.h>
     80 #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
     81 
     82 #if SANITIZER_ANDROID
     83 #include <linux/kd.h>
     84 #include <linux/mtio.h>
     85 #include <linux/ppp_defs.h>
     86 #include <linux/if_ppp.h>
     87 #endif
     88 
     89 #if SANITIZER_LINUX
     90 #include <link.h>
     91 #include <sys/vfs.h>
     92 #include <sys/epoll.h>
     93 #endif // SANITIZER_LINUX
     94 
     95 #if SANITIZER_MAC
     96 #include <netinet/ip_mroute.h>
     97 #include <sys/filio.h>
     98 #include <sys/sockio.h>
     99 #endif
    100 
    101 namespace __sanitizer {
    102   unsigned struct_utsname_sz = sizeof(struct utsname);
    103   unsigned struct_stat_sz = sizeof(struct stat);
    104   unsigned struct_stat64_sz = sizeof(struct stat64);
    105   unsigned struct_rusage_sz = sizeof(struct rusage);
    106   unsigned struct_tm_sz = sizeof(struct tm);
    107   unsigned struct_passwd_sz = sizeof(struct passwd);
    108   unsigned struct_group_sz = sizeof(struct group);
    109   unsigned siginfo_t_sz = sizeof(siginfo_t);
    110   unsigned struct_sigaction_sz = sizeof(struct sigaction);
    111   unsigned struct_itimerval_sz = sizeof(struct itimerval);
    112   unsigned pthread_t_sz = sizeof(pthread_t);
    113   unsigned pid_t_sz = sizeof(pid_t);
    114   unsigned timeval_sz = sizeof(timeval);
    115   unsigned uid_t_sz = sizeof(uid_t);
    116   unsigned mbstate_t_sz = sizeof(mbstate_t);
    117 
    118 #if !SANITIZER_ANDROID
    119   unsigned ucontext_t_sz = sizeof(ucontext_t);
    120 #endif // !SANITIZER_ANDROID
    121 
    122 #if SANITIZER_LINUX
    123   unsigned struct_rlimit_sz = sizeof(struct rlimit);
    124   unsigned struct_statfs_sz = sizeof(struct statfs);
    125   unsigned struct_epoll_event_sz = sizeof(struct epoll_event);
    126   unsigned struct_sysinfo_sz = sizeof(struct sysinfo);
    127   unsigned struct_timespec_sz = sizeof(struct timespec);
    128 #endif // SANITIZER_LINUX
    129 
    130 #if SANITIZER_LINUX && !SANITIZER_ANDROID
    131   unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
    132   unsigned struct_statfs64_sz = sizeof(struct statfs64);
    133 #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
    134 
    135   uptr sig_ign = (uptr)SIG_IGN;
    136   uptr sig_dfl = (uptr)SIG_DFL;
    137 
    138 #if SANITIZER_LINUX
    139   int e_tabsz = (int)E_TABSZ;
    140 #endif
    141 
    142   uptr __sanitizer_get_sigaction_sa_sigaction(void *act) {
    143     struct sigaction *a = (struct sigaction *)act;
    144     // Check that sa_sigaction and sa_handler are the same.
    145     CHECK((void *)&(a->sa_sigaction) == (void *)&(a->sa_handler));
    146     return (uptr) a->sa_sigaction;
    147   }
    148   void __sanitizer_set_sigaction_sa_sigaction(void *act, uptr cb) {
    149     struct sigaction *a = (struct sigaction *)act;
    150     a->sa_sigaction = (void (*)(int, siginfo_t *, void *))cb;
    151   }
    152   bool __sanitizer_get_sigaction_sa_siginfo(void *act) {
    153     struct sigaction *a = (struct sigaction *)act;
    154     return a->sa_flags & SA_SIGINFO;
    155   }
    156 
    157   int af_inet = (int)AF_INET;
    158   int af_inet6 = (int)AF_INET6;
    159 
    160   uptr __sanitizer_in_addr_sz(int af) {
    161     if (af == AF_INET)
    162       return sizeof(struct in_addr);
    163     else if (af == AF_INET6)
    164       return sizeof(struct in6_addr);
    165     else
    166       return 0;
    167   }
    168 
    169 #if SANITIZER_LINUX && !SANITIZER_ANDROID
    170   int glob_nomatch = GLOB_NOMATCH;
    171   int glob_altdirfunc = GLOB_ALTDIRFUNC;
    172 #endif
    173 
    174 #if SANITIZER_LINUX && !SANITIZER_ANDROID && \
    175       (defined(__i386) || defined (__x86_64))  // NOLINT
    176   unsigned struct_user_regs_struct_sz = sizeof(struct user_regs_struct);
    177   unsigned struct_user_fpregs_struct_sz = sizeof(struct user_fpregs_struct);
    178 #if __WORDSIZE == 64
    179   unsigned struct_user_fpxregs_struct_sz = 0;
    180 #else
    181   unsigned struct_user_fpxregs_struct_sz = sizeof(struct user_fpxregs_struct);
    182 #endif
    183 
    184   int ptrace_getregs = PTRACE_GETREGS;
    185   int ptrace_setregs = PTRACE_SETREGS;
    186   int ptrace_getfpregs = PTRACE_GETFPREGS;
    187   int ptrace_setfpregs = PTRACE_SETFPREGS;
    188   int ptrace_getfpxregs = PTRACE_GETFPXREGS;
    189   int ptrace_setfpxregs = PTRACE_SETFPXREGS;
    190   int ptrace_getsiginfo = PTRACE_GETSIGINFO;
    191   int ptrace_setsiginfo = PTRACE_SETSIGINFO;
    192 #if defined(PTRACE_GETREGSET) && defined(PTRACE_SETREGSET)
    193   int ptrace_getregset = PTRACE_GETREGSET;
    194   int ptrace_setregset = PTRACE_SETREGSET;
    195 #else
    196   int ptrace_getregset = -1;
    197   int ptrace_setregset = -1;
    198 #endif
    199 #endif
    200 
    201   unsigned path_max = PATH_MAX;
    202 
    203   // ioctl arguments
    204   unsigned struct_arpreq_sz = sizeof(struct arpreq);
    205   unsigned struct_ifreq_sz = sizeof(struct ifreq);
    206   unsigned struct_termios_sz = sizeof(struct termios);
    207   unsigned struct_winsize_sz = sizeof(struct winsize);
    208 
    209 #if SANITIZER_LINUX
    210   unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf);
    211   unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession);
    212   unsigned struct_cdrom_read_audio_sz = sizeof(struct cdrom_read_audio);
    213   unsigned struct_cdrom_subchnl_sz = sizeof(struct cdrom_subchnl);
    214   unsigned struct_cdrom_ti_sz = sizeof(struct cdrom_ti);
    215   unsigned struct_cdrom_tocentry_sz = sizeof(struct cdrom_tocentry);
    216   unsigned struct_cdrom_tochdr_sz = sizeof(struct cdrom_tochdr);
    217   unsigned struct_cdrom_volctrl_sz = sizeof(struct cdrom_volctrl);
    218 #if SOUND_VERSION >= 0x040000
    219   unsigned struct_copr_buffer_sz = 0;
    220   unsigned struct_copr_debug_buf_sz = 0;
    221   unsigned struct_copr_msg_sz = 0;
    222 #else
    223   unsigned struct_copr_buffer_sz = sizeof(struct copr_buffer);
    224   unsigned struct_copr_debug_buf_sz = sizeof(struct copr_debug_buf);
    225   unsigned struct_copr_msg_sz = sizeof(struct copr_msg);
    226 #endif
    227   unsigned struct_ff_effect_sz = sizeof(struct ff_effect);
    228   unsigned struct_floppy_drive_params_sz = sizeof(struct floppy_drive_params);
    229   unsigned struct_floppy_drive_struct_sz = sizeof(struct floppy_drive_struct);
    230   unsigned struct_floppy_fdc_state_sz = sizeof(struct floppy_fdc_state);
    231   unsigned struct_floppy_max_errors_sz = sizeof(struct floppy_max_errors);
    232   unsigned struct_floppy_raw_cmd_sz = sizeof(struct floppy_raw_cmd);
    233   unsigned struct_floppy_struct_sz = sizeof(struct floppy_struct);
    234   unsigned struct_floppy_write_errors_sz = sizeof(struct floppy_write_errors);
    235   unsigned struct_format_descr_sz = sizeof(struct format_descr);
    236   unsigned struct_hd_driveid_sz = sizeof(struct hd_driveid);
    237   unsigned struct_hd_geometry_sz = sizeof(struct hd_geometry);
    238   unsigned struct_input_absinfo_sz = sizeof(struct input_absinfo);
    239   unsigned struct_input_id_sz = sizeof(struct input_id);
    240   unsigned struct_midi_info_sz = sizeof(struct midi_info);
    241   unsigned struct_mtget_sz = sizeof(struct mtget);
    242   unsigned struct_mtop_sz = sizeof(struct mtop);
    243   unsigned struct_mtpos_sz = sizeof(struct mtpos);
    244   unsigned struct_rtentry_sz = sizeof(struct rtentry);
    245   unsigned struct_sbi_instrument_sz = sizeof(struct sbi_instrument);
    246   unsigned struct_seq_event_rec_sz = sizeof(struct seq_event_rec);
    247   unsigned struct_synth_info_sz = sizeof(struct synth_info);
    248   unsigned struct_termio_sz = sizeof(struct termio);
    249   unsigned struct_vt_consize_sz = sizeof(struct vt_consize);
    250   unsigned struct_vt_mode_sz = sizeof(struct vt_mode);
    251   unsigned struct_vt_sizes_sz = sizeof(struct vt_sizes);
    252   unsigned struct_vt_stat_sz = sizeof(struct vt_stat);
    253 #endif
    254 
    255 #if SANITIZER_LINUX && !SANITIZER_ANDROID
    256   unsigned struct_audio_buf_info_sz = sizeof(struct audio_buf_info);
    257   unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
    258   unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
    259 #if EV_VERSION > (0x010000)
    260   unsigned struct_input_keymap_entry_sz = sizeof(struct input_keymap_entry);
    261 #else
    262   unsigned struct_input_keymap_entry_sz = 0;
    263 #endif
    264   unsigned struct_ipx_config_data_sz = sizeof(struct ipx_config_data);
    265   unsigned struct_kbdiacrs_sz = sizeof(struct kbdiacrs);
    266   unsigned struct_kbentry_sz = sizeof(struct kbentry);
    267   unsigned struct_kbkeycode_sz = sizeof(struct kbkeycode);
    268   unsigned struct_kbsentry_sz = sizeof(struct kbsentry);
    269   unsigned struct_mtconfiginfo_sz = sizeof(struct mtconfiginfo);
    270   unsigned struct_nr_parms_struct_sz = sizeof(struct nr_parms_struct);
    271   unsigned struct_ppp_stats_sz = sizeof(struct ppp_stats);
    272   unsigned struct_scc_modem_sz = sizeof(struct scc_modem);
    273   unsigned struct_scc_stat_sz = sizeof(struct scc_stat);
    274   unsigned struct_serial_multiport_struct_sz
    275       = sizeof(struct serial_multiport_struct);
    276   unsigned struct_serial_struct_sz = sizeof(struct serial_struct);
    277   unsigned struct_sockaddr_ax25_sz = sizeof(struct sockaddr_ax25);
    278   unsigned struct_unimapdesc_sz = sizeof(struct unimapdesc);
    279   unsigned struct_unimapinit_sz = sizeof(struct unimapinit);
    280 #endif
    281 
    282 #if !SANITIZER_ANDROID
    283   unsigned struct_sioc_sg_req_sz = sizeof(struct sioc_sg_req);
    284   unsigned struct_sioc_vif_req_sz = sizeof(struct sioc_vif_req);
    285 #endif
    286 
    287   unsigned IOCTL_NOT_PRESENT = 0;
    288 
    289   unsigned IOCTL_FIOASYNC = FIOASYNC;
    290   unsigned IOCTL_FIOCLEX = FIOCLEX;
    291   unsigned IOCTL_FIOGETOWN = FIOGETOWN;
    292   unsigned IOCTL_FIONBIO = FIONBIO;
    293   unsigned IOCTL_FIONCLEX = FIONCLEX;
    294   unsigned IOCTL_FIOSETOWN = FIOSETOWN;
    295   unsigned IOCTL_SIOCADDMULTI = SIOCADDMULTI;
    296   unsigned IOCTL_SIOCATMARK = SIOCATMARK;
    297   unsigned IOCTL_SIOCDELMULTI = SIOCDELMULTI;
    298   unsigned IOCTL_SIOCGIFADDR = SIOCGIFADDR;
    299   unsigned IOCTL_SIOCGIFBRDADDR = SIOCGIFBRDADDR;
    300   unsigned IOCTL_SIOCGIFCONF = SIOCGIFCONF;
    301   unsigned IOCTL_SIOCGIFDSTADDR = SIOCGIFDSTADDR;
    302   unsigned IOCTL_SIOCGIFFLAGS = SIOCGIFFLAGS;
    303   unsigned IOCTL_SIOCGIFMETRIC = SIOCGIFMETRIC;
    304   unsigned IOCTL_SIOCGIFMTU = SIOCGIFMTU;
    305   unsigned IOCTL_SIOCGIFNETMASK = SIOCGIFNETMASK;
    306   unsigned IOCTL_SIOCGPGRP = SIOCGPGRP;
    307   unsigned IOCTL_SIOCSIFADDR = SIOCSIFADDR;
    308   unsigned IOCTL_SIOCSIFBRDADDR = SIOCSIFBRDADDR;
    309   unsigned IOCTL_SIOCSIFDSTADDR = SIOCSIFDSTADDR;
    310   unsigned IOCTL_SIOCSIFFLAGS = SIOCSIFFLAGS;
    311   unsigned IOCTL_SIOCSIFMETRIC = SIOCSIFMETRIC;
    312   unsigned IOCTL_SIOCSIFMTU = SIOCSIFMTU;
    313   unsigned IOCTL_SIOCSIFNETMASK = SIOCSIFNETMASK;
    314   unsigned IOCTL_SIOCSPGRP = SIOCSPGRP;
    315   unsigned IOCTL_TIOCCONS = TIOCCONS;
    316   unsigned IOCTL_TIOCEXCL = TIOCEXCL;
    317   unsigned IOCTL_TIOCGETD = TIOCGETD;
    318   unsigned IOCTL_TIOCGPGRP = TIOCGPGRP;
    319   unsigned IOCTL_TIOCGWINSZ = TIOCGWINSZ;
    320   unsigned IOCTL_TIOCMBIC = TIOCMBIC;
    321   unsigned IOCTL_TIOCMBIS = TIOCMBIS;
    322   unsigned IOCTL_TIOCMGET = TIOCMGET;
    323   unsigned IOCTL_TIOCMSET = TIOCMSET;
    324   unsigned IOCTL_TIOCNOTTY = TIOCNOTTY;
    325   unsigned IOCTL_TIOCNXCL = TIOCNXCL;
    326   unsigned IOCTL_TIOCOUTQ = TIOCOUTQ;
    327   unsigned IOCTL_TIOCPKT = TIOCPKT;
    328   unsigned IOCTL_TIOCSCTTY = TIOCSCTTY;
    329   unsigned IOCTL_TIOCSETD = TIOCSETD;
    330   unsigned IOCTL_TIOCSPGRP = TIOCSPGRP;
    331   unsigned IOCTL_TIOCSTI = TIOCSTI;
    332   unsigned IOCTL_TIOCSWINSZ = TIOCSWINSZ;
    333 #if (SANITIZER_LINUX && !SANITIZER_ANDROID) || SANITIZER_MAC
    334   unsigned IOCTL_SIOCGETSGCNT = SIOCGETSGCNT;
    335   unsigned IOCTL_SIOCGETVIFCNT = SIOCGETVIFCNT;
    336 #endif
    337 #if SANITIZER_LINUX
    338   unsigned IOCTL_EVIOCGABS = EVIOCGABS(0);
    339   unsigned IOCTL_EVIOCGBIT = EVIOCGBIT(0, 0);
    340   unsigned IOCTL_EVIOCGEFFECTS = EVIOCGEFFECTS;
    341   unsigned IOCTL_EVIOCGID = EVIOCGID;
    342   unsigned IOCTL_EVIOCGKEY = EVIOCGKEY(0);
    343   unsigned IOCTL_EVIOCGKEYCODE = EVIOCGKEYCODE;
    344   unsigned IOCTL_EVIOCGLED = EVIOCGLED(0);
    345   unsigned IOCTL_EVIOCGNAME = EVIOCGNAME(0);
    346   unsigned IOCTL_EVIOCGPHYS = EVIOCGPHYS(0);
    347   unsigned IOCTL_EVIOCGRAB = EVIOCGRAB;
    348   unsigned IOCTL_EVIOCGREP = EVIOCGREP;
    349   unsigned IOCTL_EVIOCGSND = EVIOCGSND(0);
    350   unsigned IOCTL_EVIOCGSW = EVIOCGSW(0);
    351   unsigned IOCTL_EVIOCGUNIQ = EVIOCGUNIQ(0);
    352   unsigned IOCTL_EVIOCGVERSION = EVIOCGVERSION;
    353   unsigned IOCTL_EVIOCRMFF = EVIOCRMFF;
    354   unsigned IOCTL_EVIOCSABS = EVIOCSABS(0);
    355   unsigned IOCTL_EVIOCSFF = EVIOCSFF;
    356   unsigned IOCTL_EVIOCSKEYCODE = EVIOCSKEYCODE;
    357   unsigned IOCTL_EVIOCSREP = EVIOCSREP;
    358   unsigned IOCTL_BLKFLSBUF = BLKFLSBUF;
    359   unsigned IOCTL_BLKGETSIZE = BLKGETSIZE;
    360   unsigned IOCTL_BLKRAGET = BLKRAGET;
    361   unsigned IOCTL_BLKRASET = BLKRASET;
    362   unsigned IOCTL_BLKROGET = BLKROGET;
    363   unsigned IOCTL_BLKROSET = BLKROSET;
    364   unsigned IOCTL_BLKRRPART = BLKRRPART;
    365   unsigned IOCTL_CDROMAUDIOBUFSIZ = CDROMAUDIOBUFSIZ;
    366   unsigned IOCTL_CDROMEJECT = CDROMEJECT;
    367   unsigned IOCTL_CDROMEJECT_SW = CDROMEJECT_SW;
    368   unsigned IOCTL_CDROMMULTISESSION = CDROMMULTISESSION;
    369   unsigned IOCTL_CDROMPAUSE = CDROMPAUSE;
    370   unsigned IOCTL_CDROMPLAYMSF = CDROMPLAYMSF;
    371   unsigned IOCTL_CDROMPLAYTRKIND = CDROMPLAYTRKIND;
    372   unsigned IOCTL_CDROMREADAUDIO = CDROMREADAUDIO;
    373   unsigned IOCTL_CDROMREADCOOKED = CDROMREADCOOKED;
    374   unsigned IOCTL_CDROMREADMODE1 = CDROMREADMODE1;
    375   unsigned IOCTL_CDROMREADMODE2 = CDROMREADMODE2;
    376   unsigned IOCTL_CDROMREADRAW = CDROMREADRAW;
    377   unsigned IOCTL_CDROMREADTOCENTRY = CDROMREADTOCENTRY;
    378   unsigned IOCTL_CDROMREADTOCHDR = CDROMREADTOCHDR;
    379   unsigned IOCTL_CDROMRESET = CDROMRESET;
    380   unsigned IOCTL_CDROMRESUME = CDROMRESUME;
    381   unsigned IOCTL_CDROMSEEK = CDROMSEEK;
    382   unsigned IOCTL_CDROMSTART = CDROMSTART;
    383   unsigned IOCTL_CDROMSTOP = CDROMSTOP;
    384   unsigned IOCTL_CDROMSUBCHNL = CDROMSUBCHNL;
    385   unsigned IOCTL_CDROMVOLCTRL = CDROMVOLCTRL;
    386   unsigned IOCTL_CDROMVOLREAD = CDROMVOLREAD;
    387   unsigned IOCTL_CDROM_GET_UPC = CDROM_GET_UPC;
    388   unsigned IOCTL_FDCLRPRM = FDCLRPRM;
    389   unsigned IOCTL_FDDEFPRM = FDDEFPRM;
    390   unsigned IOCTL_FDFLUSH = FDFLUSH;
    391   unsigned IOCTL_FDFMTBEG = FDFMTBEG;
    392   unsigned IOCTL_FDFMTEND = FDFMTEND;
    393   unsigned IOCTL_FDFMTTRK = FDFMTTRK;
    394   unsigned IOCTL_FDGETDRVPRM = FDGETDRVPRM;
    395   unsigned IOCTL_FDGETDRVSTAT = FDGETDRVSTAT;
    396   unsigned IOCTL_FDGETDRVTYP = FDGETDRVTYP;
    397   unsigned IOCTL_FDGETFDCSTAT = FDGETFDCSTAT;
    398   unsigned IOCTL_FDGETMAXERRS = FDGETMAXERRS;
    399   unsigned IOCTL_FDGETPRM = FDGETPRM;
    400   unsigned IOCTL_FDMSGOFF = FDMSGOFF;
    401   unsigned IOCTL_FDMSGON = FDMSGON;
    402   unsigned IOCTL_FDPOLLDRVSTAT = FDPOLLDRVSTAT;
    403   unsigned IOCTL_FDRAWCMD = FDRAWCMD;
    404   unsigned IOCTL_FDRESET = FDRESET;
    405   unsigned IOCTL_FDSETDRVPRM = FDSETDRVPRM;
    406   unsigned IOCTL_FDSETEMSGTRESH = FDSETEMSGTRESH;
    407   unsigned IOCTL_FDSETMAXERRS = FDSETMAXERRS;
    408   unsigned IOCTL_FDSETPRM = FDSETPRM;
    409   unsigned IOCTL_FDTWADDLE = FDTWADDLE;
    410   unsigned IOCTL_FDWERRORCLR = FDWERRORCLR;
    411   unsigned IOCTL_FDWERRORGET = FDWERRORGET;
    412   unsigned IOCTL_HDIO_DRIVE_CMD = HDIO_DRIVE_CMD;
    413   unsigned IOCTL_HDIO_GETGEO = HDIO_GETGEO;
    414   unsigned IOCTL_HDIO_GET_32BIT = HDIO_GET_32BIT;
    415   unsigned IOCTL_HDIO_GET_DMA = HDIO_GET_DMA;
    416   unsigned IOCTL_HDIO_GET_IDENTITY = HDIO_GET_IDENTITY;
    417   unsigned IOCTL_HDIO_GET_KEEPSETTINGS = HDIO_GET_KEEPSETTINGS;
    418   unsigned IOCTL_HDIO_GET_MULTCOUNT = HDIO_GET_MULTCOUNT;
    419   unsigned IOCTL_HDIO_GET_NOWERR = HDIO_GET_NOWERR;
    420   unsigned IOCTL_HDIO_GET_UNMASKINTR = HDIO_GET_UNMASKINTR;
    421   unsigned IOCTL_HDIO_SET_32BIT = HDIO_SET_32BIT;
    422   unsigned IOCTL_HDIO_SET_DMA = HDIO_SET_DMA;
    423   unsigned IOCTL_HDIO_SET_KEEPSETTINGS = HDIO_SET_KEEPSETTINGS;
    424   unsigned IOCTL_HDIO_SET_MULTCOUNT = HDIO_SET_MULTCOUNT;
    425   unsigned IOCTL_HDIO_SET_NOWERR = HDIO_SET_NOWERR;
    426   unsigned IOCTL_HDIO_SET_UNMASKINTR = HDIO_SET_UNMASKINTR;
    427   unsigned IOCTL_MTIOCGET = MTIOCGET;
    428   unsigned IOCTL_MTIOCPOS = MTIOCPOS;
    429   unsigned IOCTL_MTIOCTOP = MTIOCTOP;
    430   unsigned IOCTL_PPPIOCGASYNCMAP = PPPIOCGASYNCMAP;
    431   unsigned IOCTL_PPPIOCGDEBUG = PPPIOCGDEBUG;
    432   unsigned IOCTL_PPPIOCGFLAGS = PPPIOCGFLAGS;
    433   unsigned IOCTL_PPPIOCGUNIT = PPPIOCGUNIT;
    434   unsigned IOCTL_PPPIOCGXASYNCMAP = PPPIOCGXASYNCMAP;
    435   unsigned IOCTL_PPPIOCSASYNCMAP = PPPIOCSASYNCMAP;
    436   unsigned IOCTL_PPPIOCSDEBUG = PPPIOCSDEBUG;
    437   unsigned IOCTL_PPPIOCSFLAGS = PPPIOCSFLAGS;
    438   unsigned IOCTL_PPPIOCSMAXCID = PPPIOCSMAXCID;
    439   unsigned IOCTL_PPPIOCSMRU = PPPIOCSMRU;
    440   unsigned IOCTL_PPPIOCSXASYNCMAP = PPPIOCSXASYNCMAP;
    441   unsigned IOCTL_SIOCADDRT = SIOCADDRT;
    442   unsigned IOCTL_SIOCDARP = SIOCDARP;
    443   unsigned IOCTL_SIOCDELRT = SIOCDELRT;
    444   unsigned IOCTL_SIOCDRARP = SIOCDRARP;
    445   unsigned IOCTL_SIOCGARP = SIOCGARP;
    446   unsigned IOCTL_SIOCGIFENCAP = SIOCGIFENCAP;
    447   unsigned IOCTL_SIOCGIFHWADDR = SIOCGIFHWADDR;
    448   unsigned IOCTL_SIOCGIFMAP = SIOCGIFMAP;
    449   unsigned IOCTL_SIOCGIFMEM = SIOCGIFMEM;
    450   unsigned IOCTL_SIOCGIFNAME = SIOCGIFNAME;
    451   unsigned IOCTL_SIOCGIFSLAVE = SIOCGIFSLAVE;
    452   unsigned IOCTL_SIOCGRARP = SIOCGRARP;
    453   unsigned IOCTL_SIOCGSTAMP = SIOCGSTAMP;
    454   unsigned IOCTL_SIOCSARP = SIOCSARP;
    455   unsigned IOCTL_SIOCSIFENCAP = SIOCSIFENCAP;
    456   unsigned IOCTL_SIOCSIFHWADDR = SIOCSIFHWADDR;
    457   unsigned IOCTL_SIOCSIFLINK = SIOCSIFLINK;
    458   unsigned IOCTL_SIOCSIFMAP = SIOCSIFMAP;
    459   unsigned IOCTL_SIOCSIFMEM = SIOCSIFMEM;
    460   unsigned IOCTL_SIOCSIFSLAVE = SIOCSIFSLAVE;
    461   unsigned IOCTL_SIOCSRARP = SIOCSRARP;
    462 #if SOUND_VERSION >= 0x040000
    463   unsigned IOCTL_SNDCTL_COPR_HALT = IOCTL_NOT_PRESENT;
    464   unsigned IOCTL_SNDCTL_COPR_LOAD = IOCTL_NOT_PRESENT;
    465   unsigned IOCTL_SNDCTL_COPR_RCODE = IOCTL_NOT_PRESENT;
    466   unsigned IOCTL_SNDCTL_COPR_RCVMSG = IOCTL_NOT_PRESENT;
    467   unsigned IOCTL_SNDCTL_COPR_RDATA = IOCTL_NOT_PRESENT;
    468   unsigned IOCTL_SNDCTL_COPR_RESET = IOCTL_NOT_PRESENT;
    469   unsigned IOCTL_SNDCTL_COPR_RUN = IOCTL_NOT_PRESENT;
    470   unsigned IOCTL_SNDCTL_COPR_SENDMSG = IOCTL_NOT_PRESENT;
    471   unsigned IOCTL_SNDCTL_COPR_WCODE = IOCTL_NOT_PRESENT;
    472   unsigned IOCTL_SNDCTL_COPR_WDATA = IOCTL_NOT_PRESENT;
    473   unsigned IOCTL_SOUND_PCM_READ_BITS = IOCTL_NOT_PRESENT;
    474   unsigned IOCTL_SOUND_PCM_READ_CHANNELS = IOCTL_NOT_PRESENT;
    475   unsigned IOCTL_SOUND_PCM_READ_FILTER = IOCTL_NOT_PRESENT;
    476   unsigned IOCTL_SOUND_PCM_READ_RATE = IOCTL_NOT_PRESENT;
    477   unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS = IOCTL_NOT_PRESENT;
    478   unsigned IOCTL_SOUND_PCM_WRITE_FILTER = IOCTL_NOT_PRESENT;
    479 #else
    480   unsigned IOCTL_SNDCTL_COPR_HALT = SNDCTL_COPR_HALT;
    481   unsigned IOCTL_SNDCTL_COPR_LOAD = SNDCTL_COPR_LOAD;
    482   unsigned IOCTL_SNDCTL_COPR_RCODE = SNDCTL_COPR_RCODE;
    483   unsigned IOCTL_SNDCTL_COPR_RCVMSG = SNDCTL_COPR_RCVMSG;
    484   unsigned IOCTL_SNDCTL_COPR_RDATA = SNDCTL_COPR_RDATA;
    485   unsigned IOCTL_SNDCTL_COPR_RESET = SNDCTL_COPR_RESET;
    486   unsigned IOCTL_SNDCTL_COPR_RUN = SNDCTL_COPR_RUN;
    487   unsigned IOCTL_SNDCTL_COPR_SENDMSG = SNDCTL_COPR_SENDMSG;
    488   unsigned IOCTL_SNDCTL_COPR_WCODE = SNDCTL_COPR_WCODE;
    489   unsigned IOCTL_SNDCTL_COPR_WDATA = SNDCTL_COPR_WDATA;
    490   unsigned IOCTL_SOUND_PCM_READ_BITS = SOUND_PCM_READ_BITS;
    491   unsigned IOCTL_SOUND_PCM_READ_CHANNELS = SOUND_PCM_READ_CHANNELS;
    492   unsigned IOCTL_SOUND_PCM_READ_FILTER = SOUND_PCM_READ_FILTER;
    493   unsigned IOCTL_SOUND_PCM_READ_RATE = SOUND_PCM_READ_RATE;
    494   unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS = SOUND_PCM_WRITE_CHANNELS;
    495   unsigned IOCTL_SOUND_PCM_WRITE_FILTER = SOUND_PCM_WRITE_FILTER;
    496 #endif
    497   unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE = SNDCTL_DSP_GETBLKSIZE;
    498   unsigned IOCTL_SNDCTL_DSP_GETFMTS = SNDCTL_DSP_GETFMTS;
    499   unsigned IOCTL_SNDCTL_DSP_NONBLOCK = SNDCTL_DSP_NONBLOCK;
    500   unsigned IOCTL_SNDCTL_DSP_POST = SNDCTL_DSP_POST;
    501   unsigned IOCTL_SNDCTL_DSP_RESET = SNDCTL_DSP_RESET;
    502   unsigned IOCTL_SNDCTL_DSP_SETFMT = SNDCTL_DSP_SETFMT;
    503   unsigned IOCTL_SNDCTL_DSP_SETFRAGMENT = SNDCTL_DSP_SETFRAGMENT;
    504   unsigned IOCTL_SNDCTL_DSP_SPEED = SNDCTL_DSP_SPEED;
    505   unsigned IOCTL_SNDCTL_DSP_STEREO = SNDCTL_DSP_STEREO;
    506   unsigned IOCTL_SNDCTL_DSP_SUBDIVIDE = SNDCTL_DSP_SUBDIVIDE;
    507   unsigned IOCTL_SNDCTL_DSP_SYNC = SNDCTL_DSP_SYNC;
    508   unsigned IOCTL_SNDCTL_FM_4OP_ENABLE = SNDCTL_FM_4OP_ENABLE;
    509   unsigned IOCTL_SNDCTL_FM_LOAD_INSTR = SNDCTL_FM_LOAD_INSTR;
    510   unsigned IOCTL_SNDCTL_MIDI_INFO = SNDCTL_MIDI_INFO;
    511   unsigned IOCTL_SNDCTL_MIDI_PRETIME = SNDCTL_MIDI_PRETIME;
    512   unsigned IOCTL_SNDCTL_SEQ_CTRLRATE = SNDCTL_SEQ_CTRLRATE;
    513   unsigned IOCTL_SNDCTL_SEQ_GETINCOUNT = SNDCTL_SEQ_GETINCOUNT;
    514   unsigned IOCTL_SNDCTL_SEQ_GETOUTCOUNT = SNDCTL_SEQ_GETOUTCOUNT;
    515   unsigned IOCTL_SNDCTL_SEQ_NRMIDIS = SNDCTL_SEQ_NRMIDIS;
    516   unsigned IOCTL_SNDCTL_SEQ_NRSYNTHS = SNDCTL_SEQ_NRSYNTHS;
    517   unsigned IOCTL_SNDCTL_SEQ_OUTOFBAND = SNDCTL_SEQ_OUTOFBAND;
    518   unsigned IOCTL_SNDCTL_SEQ_PANIC = SNDCTL_SEQ_PANIC;
    519   unsigned IOCTL_SNDCTL_SEQ_PERCMODE = SNDCTL_SEQ_PERCMODE;
    520   unsigned IOCTL_SNDCTL_SEQ_RESET = SNDCTL_SEQ_RESET;
    521   unsigned IOCTL_SNDCTL_SEQ_RESETSAMPLES = SNDCTL_SEQ_RESETSAMPLES;
    522   unsigned IOCTL_SNDCTL_SEQ_SYNC = SNDCTL_SEQ_SYNC;
    523   unsigned IOCTL_SNDCTL_SEQ_TESTMIDI = SNDCTL_SEQ_TESTMIDI;
    524   unsigned IOCTL_SNDCTL_SEQ_THRESHOLD = SNDCTL_SEQ_THRESHOLD;
    525   unsigned IOCTL_SNDCTL_SYNTH_INFO = SNDCTL_SYNTH_INFO;
    526   unsigned IOCTL_SNDCTL_SYNTH_MEMAVL = SNDCTL_SYNTH_MEMAVL;
    527   unsigned IOCTL_SNDCTL_TMR_CONTINUE = SNDCTL_TMR_CONTINUE;
    528   unsigned IOCTL_SNDCTL_TMR_METRONOME = SNDCTL_TMR_METRONOME;
    529   unsigned IOCTL_SNDCTL_TMR_SELECT = SNDCTL_TMR_SELECT;
    530   unsigned IOCTL_SNDCTL_TMR_SOURCE = SNDCTL_TMR_SOURCE;
    531   unsigned IOCTL_SNDCTL_TMR_START = SNDCTL_TMR_START;
    532   unsigned IOCTL_SNDCTL_TMR_STOP = SNDCTL_TMR_STOP;
    533   unsigned IOCTL_SNDCTL_TMR_TEMPO = SNDCTL_TMR_TEMPO;
    534   unsigned IOCTL_SNDCTL_TMR_TIMEBASE = SNDCTL_TMR_TIMEBASE;
    535   unsigned IOCTL_SOUND_MIXER_READ_ALTPCM = SOUND_MIXER_READ_ALTPCM;
    536   unsigned IOCTL_SOUND_MIXER_READ_BASS = SOUND_MIXER_READ_BASS;
    537   unsigned IOCTL_SOUND_MIXER_READ_CAPS = SOUND_MIXER_READ_CAPS;
    538   unsigned IOCTL_SOUND_MIXER_READ_CD = SOUND_MIXER_READ_CD;
    539   unsigned IOCTL_SOUND_MIXER_READ_DEVMASK = SOUND_MIXER_READ_DEVMASK;
    540   unsigned IOCTL_SOUND_MIXER_READ_ENHANCE = SOUND_MIXER_READ_ENHANCE;
    541   unsigned IOCTL_SOUND_MIXER_READ_IGAIN = SOUND_MIXER_READ_IGAIN;
    542   unsigned IOCTL_SOUND_MIXER_READ_IMIX = SOUND_MIXER_READ_IMIX;
    543   unsigned IOCTL_SOUND_MIXER_READ_LINE = SOUND_MIXER_READ_LINE;
    544   unsigned IOCTL_SOUND_MIXER_READ_LINE1 = SOUND_MIXER_READ_LINE1;
    545   unsigned IOCTL_SOUND_MIXER_READ_LINE2 = SOUND_MIXER_READ_LINE2;
    546   unsigned IOCTL_SOUND_MIXER_READ_LINE3 = SOUND_MIXER_READ_LINE3;
    547   unsigned IOCTL_SOUND_MIXER_READ_LOUD = SOUND_MIXER_READ_LOUD;
    548   unsigned IOCTL_SOUND_MIXER_READ_MIC = SOUND_MIXER_READ_MIC;
    549   unsigned IOCTL_SOUND_MIXER_READ_MUTE = SOUND_MIXER_READ_MUTE;
    550   unsigned IOCTL_SOUND_MIXER_READ_OGAIN = SOUND_MIXER_READ_OGAIN;
    551   unsigned IOCTL_SOUND_MIXER_READ_PCM = SOUND_MIXER_READ_PCM;
    552   unsigned IOCTL_SOUND_MIXER_READ_RECLEV = SOUND_MIXER_READ_RECLEV;
    553   unsigned IOCTL_SOUND_MIXER_READ_RECMASK = SOUND_MIXER_READ_RECMASK;
    554   unsigned IOCTL_SOUND_MIXER_READ_RECSRC = SOUND_MIXER_READ_RECSRC;
    555   unsigned IOCTL_SOUND_MIXER_READ_SPEAKER = SOUND_MIXER_READ_SPEAKER;
    556   unsigned IOCTL_SOUND_MIXER_READ_STEREODEVS = SOUND_MIXER_READ_STEREODEVS;
    557   unsigned IOCTL_SOUND_MIXER_READ_SYNTH = SOUND_MIXER_READ_SYNTH;
    558   unsigned IOCTL_SOUND_MIXER_READ_TREBLE = SOUND_MIXER_READ_TREBLE;
    559   unsigned IOCTL_SOUND_MIXER_READ_VOLUME = SOUND_MIXER_READ_VOLUME;
    560   unsigned IOCTL_SOUND_MIXER_WRITE_ALTPCM = SOUND_MIXER_WRITE_ALTPCM;
    561   unsigned IOCTL_SOUND_MIXER_WRITE_BASS = SOUND_MIXER_WRITE_BASS;
    562   unsigned IOCTL_SOUND_MIXER_WRITE_CD = SOUND_MIXER_WRITE_CD;
    563   unsigned IOCTL_SOUND_MIXER_WRITE_ENHANCE = SOUND_MIXER_WRITE_ENHANCE;
    564   unsigned IOCTL_SOUND_MIXER_WRITE_IGAIN = SOUND_MIXER_WRITE_IGAIN;
    565   unsigned IOCTL_SOUND_MIXER_WRITE_IMIX = SOUND_MIXER_WRITE_IMIX;
    566   unsigned IOCTL_SOUND_MIXER_WRITE_LINE = SOUND_MIXER_WRITE_LINE;
    567   unsigned IOCTL_SOUND_MIXER_WRITE_LINE1 = SOUND_MIXER_WRITE_LINE1;
    568   unsigned IOCTL_SOUND_MIXER_WRITE_LINE2 = SOUND_MIXER_WRITE_LINE2;
    569   unsigned IOCTL_SOUND_MIXER_WRITE_LINE3 = SOUND_MIXER_WRITE_LINE3;
    570   unsigned IOCTL_SOUND_MIXER_WRITE_LOUD = SOUND_MIXER_WRITE_LOUD;
    571   unsigned IOCTL_SOUND_MIXER_WRITE_MIC = SOUND_MIXER_WRITE_MIC;
    572   unsigned IOCTL_SOUND_MIXER_WRITE_MUTE = SOUND_MIXER_WRITE_MUTE;
    573   unsigned IOCTL_SOUND_MIXER_WRITE_OGAIN = SOUND_MIXER_WRITE_OGAIN;
    574   unsigned IOCTL_SOUND_MIXER_WRITE_PCM = SOUND_MIXER_WRITE_PCM;
    575   unsigned IOCTL_SOUND_MIXER_WRITE_RECLEV = SOUND_MIXER_WRITE_RECLEV;
    576   unsigned IOCTL_SOUND_MIXER_WRITE_RECSRC = SOUND_MIXER_WRITE_RECSRC;
    577   unsigned IOCTL_SOUND_MIXER_WRITE_SPEAKER = SOUND_MIXER_WRITE_SPEAKER;
    578   unsigned IOCTL_SOUND_MIXER_WRITE_SYNTH = SOUND_MIXER_WRITE_SYNTH;
    579   unsigned IOCTL_SOUND_MIXER_WRITE_TREBLE = SOUND_MIXER_WRITE_TREBLE;
    580   unsigned IOCTL_SOUND_MIXER_WRITE_VOLUME = SOUND_MIXER_WRITE_VOLUME;
    581   unsigned IOCTL_TCFLSH = TCFLSH;
    582   unsigned IOCTL_TCGETA = TCGETA;
    583   unsigned IOCTL_TCGETS = TCGETS;
    584   unsigned IOCTL_TCSBRK = TCSBRK;
    585   unsigned IOCTL_TCSBRKP = TCSBRKP;
    586   unsigned IOCTL_TCSETA = TCSETA;
    587   unsigned IOCTL_TCSETAF = TCSETAF;
    588   unsigned IOCTL_TCSETAW = TCSETAW;
    589   unsigned IOCTL_TCSETS = TCSETS;
    590   unsigned IOCTL_TCSETSF = TCSETSF;
    591   unsigned IOCTL_TCSETSW = TCSETSW;
    592   unsigned IOCTL_TCXONC = TCXONC;
    593   unsigned IOCTL_TIOCGLCKTRMIOS = TIOCGLCKTRMIOS;
    594   unsigned IOCTL_TIOCGSOFTCAR = TIOCGSOFTCAR;
    595   unsigned IOCTL_TIOCINQ = TIOCINQ;
    596   unsigned IOCTL_TIOCLINUX = TIOCLINUX;
    597   unsigned IOCTL_TIOCSERCONFIG = TIOCSERCONFIG;
    598   unsigned IOCTL_TIOCSERGETLSR = TIOCSERGETLSR;
    599   unsigned IOCTL_TIOCSERGWILD = TIOCSERGWILD;
    600   unsigned IOCTL_TIOCSERSWILD = TIOCSERSWILD;
    601   unsigned IOCTL_TIOCSLCKTRMIOS = TIOCSLCKTRMIOS;
    602   unsigned IOCTL_TIOCSSOFTCAR = TIOCSSOFTCAR;
    603   unsigned IOCTL_VT_ACTIVATE = VT_ACTIVATE;
    604   unsigned IOCTL_VT_DISALLOCATE = VT_DISALLOCATE;
    605   unsigned IOCTL_VT_GETMODE = VT_GETMODE;
    606   unsigned IOCTL_VT_GETSTATE = VT_GETSTATE;
    607   unsigned IOCTL_VT_OPENQRY = VT_OPENQRY;
    608   unsigned IOCTL_VT_RELDISP = VT_RELDISP;
    609   unsigned IOCTL_VT_RESIZE = VT_RESIZE;
    610   unsigned IOCTL_VT_RESIZEX = VT_RESIZEX;
    611   unsigned IOCTL_VT_SENDSIG = VT_SENDSIG;
    612   unsigned IOCTL_VT_SETMODE = VT_SETMODE;
    613   unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE;
    614 #endif
    615 #if SANITIZER_LINUX && !SANITIZER_ANDROID
    616   unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
    617   unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
    618   unsigned IOCTL_CYGETMON = CYGETMON;
    619   unsigned IOCTL_CYGETTHRESH = CYGETTHRESH;
    620   unsigned IOCTL_CYGETTIMEOUT = CYGETTIMEOUT;
    621   unsigned IOCTL_CYSETDEFTHRESH = CYSETDEFTHRESH;
    622   unsigned IOCTL_CYSETDEFTIMEOUT = CYSETDEFTIMEOUT;
    623   unsigned IOCTL_CYSETTHRESH = CYSETTHRESH;
    624   unsigned IOCTL_CYSETTIMEOUT = CYSETTIMEOUT;
    625   unsigned IOCTL_EQL_EMANCIPATE = EQL_EMANCIPATE;
    626   unsigned IOCTL_EQL_ENSLAVE = EQL_ENSLAVE;
    627   unsigned IOCTL_EQL_GETMASTRCFG = EQL_GETMASTRCFG;
    628   unsigned IOCTL_EQL_GETSLAVECFG = EQL_GETSLAVECFG;
    629   unsigned IOCTL_EQL_SETMASTRCFG = EQL_SETMASTRCFG;
    630   unsigned IOCTL_EQL_SETSLAVECFG = EQL_SETSLAVECFG;
    631 #if EV_VERSION > (0x010000)
    632   unsigned IOCTL_EVIOCGKEYCODE_V2 = EVIOCGKEYCODE_V2;
    633   unsigned IOCTL_EVIOCGPROP = EVIOCGPROP(0);
    634   unsigned IOCTL_EVIOCSKEYCODE_V2 = EVIOCSKEYCODE_V2;
    635 #else
    636   unsigned IOCTL_EVIOCGKEYCODE_V2 = IOCTL_NOT_PRESENT;
    637   unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT;
    638   unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT;
    639 #endif
    640   unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS;
    641   unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION;
    642   unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS;
    643   unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION;
    644   unsigned IOCTL_GIO_CMAP = GIO_CMAP;
    645   unsigned IOCTL_GIO_FONT = GIO_FONT;
    646   unsigned IOCTL_GIO_SCRNMAP = GIO_SCRNMAP;
    647   unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP;
    648   unsigned IOCTL_GIO_UNISCRNMAP = GIO_UNISCRNMAP;
    649   unsigned IOCTL_KDADDIO = KDADDIO;
    650   unsigned IOCTL_KDDELIO = KDDELIO;
    651   unsigned IOCTL_KDDISABIO = KDDISABIO;
    652   unsigned IOCTL_KDENABIO = KDENABIO;
    653   unsigned IOCTL_KDGETKEYCODE = KDGETKEYCODE;
    654   unsigned IOCTL_KDGETLED = KDGETLED;
    655   unsigned IOCTL_KDGETMODE = KDGETMODE;
    656   unsigned IOCTL_KDGKBDIACR = KDGKBDIACR;
    657   unsigned IOCTL_KDGKBENT = KDGKBENT;
    658   unsigned IOCTL_KDGKBLED = KDGKBLED;
    659   unsigned IOCTL_KDGKBMETA = KDGKBMETA;
    660   unsigned IOCTL_KDGKBMODE = KDGKBMODE;
    661   unsigned IOCTL_KDGKBSENT = KDGKBSENT;
    662   unsigned IOCTL_KDGKBTYPE = KDGKBTYPE;
    663   unsigned IOCTL_KDMAPDISP = KDMAPDISP;
    664   unsigned IOCTL_KDMKTONE = KDMKTONE;
    665   unsigned IOCTL_KDSETKEYCODE = KDSETKEYCODE;
    666   unsigned IOCTL_KDSETLED = KDSETLED;
    667   unsigned IOCTL_KDSETMODE = KDSETMODE;
    668   unsigned IOCTL_KDSIGACCEPT = KDSIGACCEPT;
    669   unsigned IOCTL_KDSKBDIACR = KDSKBDIACR;
    670   unsigned IOCTL_KDSKBENT = KDSKBENT;
    671   unsigned IOCTL_KDSKBLED = KDSKBLED;
    672   unsigned IOCTL_KDSKBMETA = KDSKBMETA;
    673   unsigned IOCTL_KDSKBMODE = KDSKBMODE;
    674   unsigned IOCTL_KDSKBSENT = KDSKBSENT;
    675   unsigned IOCTL_KDUNMAPDISP = KDUNMAPDISP;
    676   unsigned IOCTL_KIOCSOUND = KIOCSOUND;
    677   unsigned IOCTL_LPABORT = LPABORT;
    678   unsigned IOCTL_LPABORTOPEN = LPABORTOPEN;
    679   unsigned IOCTL_LPCAREFUL = LPCAREFUL;
    680   unsigned IOCTL_LPCHAR = LPCHAR;
    681   unsigned IOCTL_LPGETIRQ = LPGETIRQ;
    682   unsigned IOCTL_LPGETSTATUS = LPGETSTATUS;
    683   unsigned IOCTL_LPRESET = LPRESET;
    684   unsigned IOCTL_LPSETIRQ = LPSETIRQ;
    685   unsigned IOCTL_LPTIME = LPTIME;
    686   unsigned IOCTL_LPWAIT = LPWAIT;
    687   unsigned IOCTL_MTIOCGETCONFIG = MTIOCGETCONFIG;
    688   unsigned IOCTL_MTIOCSETCONFIG = MTIOCSETCONFIG;
    689   unsigned IOCTL_PIO_CMAP = PIO_CMAP;
    690   unsigned IOCTL_PIO_FONT = PIO_FONT;
    691   unsigned IOCTL_PIO_SCRNMAP = PIO_SCRNMAP;
    692   unsigned IOCTL_PIO_UNIMAP = PIO_UNIMAP;
    693   unsigned IOCTL_PIO_UNIMAPCLR = PIO_UNIMAPCLR;
    694   unsigned IOCTL_PIO_UNISCRNMAP = PIO_UNISCRNMAP;
    695   unsigned IOCTL_SCSI_IOCTL_GET_IDLUN = SCSI_IOCTL_GET_IDLUN;
    696   unsigned IOCTL_SCSI_IOCTL_PROBE_HOST = SCSI_IOCTL_PROBE_HOST;
    697   unsigned IOCTL_SCSI_IOCTL_TAGGED_DISABLE = SCSI_IOCTL_TAGGED_DISABLE;
    698   unsigned IOCTL_SCSI_IOCTL_TAGGED_ENABLE = SCSI_IOCTL_TAGGED_ENABLE;
    699   unsigned IOCTL_SIOCAIPXITFCRT = SIOCAIPXITFCRT;
    700   unsigned IOCTL_SIOCAIPXPRISLT = SIOCAIPXPRISLT;
    701   unsigned IOCTL_SIOCAX25ADDUID = SIOCAX25ADDUID;
    702   unsigned IOCTL_SIOCAX25DELUID = SIOCAX25DELUID;
    703   unsigned IOCTL_SIOCAX25GETPARMS = SIOCAX25GETPARMS;
    704   unsigned IOCTL_SIOCAX25GETUID = SIOCAX25GETUID;
    705   unsigned IOCTL_SIOCAX25NOUID = SIOCAX25NOUID;
    706   unsigned IOCTL_SIOCAX25SETPARMS = SIOCAX25SETPARMS;
    707   unsigned IOCTL_SIOCDEVPLIP = SIOCDEVPLIP;
    708   unsigned IOCTL_SIOCIPXCFGDATA = SIOCIPXCFGDATA;
    709   unsigned IOCTL_SIOCNRDECOBS = SIOCNRDECOBS;
    710   unsigned IOCTL_SIOCNRGETPARMS = SIOCNRGETPARMS;
    711   unsigned IOCTL_SIOCNRRTCTL = SIOCNRRTCTL;
    712   unsigned IOCTL_SIOCNRSETPARMS = SIOCNRSETPARMS;
    713   unsigned IOCTL_SNDCTL_DSP_GETISPACE = SNDCTL_DSP_GETISPACE;
    714   unsigned IOCTL_SNDCTL_DSP_GETOSPACE = SNDCTL_DSP_GETOSPACE;
    715   unsigned IOCTL_TIOCGSERIAL = TIOCGSERIAL;
    716   unsigned IOCTL_TIOCSERGETMULTI = TIOCSERGETMULTI;
    717   unsigned IOCTL_TIOCSERSETMULTI = TIOCSERSETMULTI;
    718   unsigned IOCTL_TIOCSSERIAL = TIOCSSERIAL;
    719 #endif
    720 }  // namespace __sanitizer
    721 
    722 #define CHECK_TYPE_SIZE(TYPE) \
    723   COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
    724 
    725 #define CHECK_SIZE_AND_OFFSET(CLASS, MEMBER)                       \
    726   COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *) NULL)->MEMBER) == \
    727                  sizeof(((CLASS *) NULL)->MEMBER));                \
    728   COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==          \
    729                  offsetof(CLASS, MEMBER))
    730 
    731 COMPILER_CHECK(sizeof(__sanitizer_pthread_attr_t) >= sizeof(pthread_attr_t));
    732 COMPILER_CHECK(sizeof(__sanitizer::struct_sigaction_max_sz) >=
    733                    sizeof(__sanitizer::struct_sigaction_sz));
    734 
    735 COMPILER_CHECK(sizeof(socklen_t) == sizeof(unsigned));
    736 CHECK_TYPE_SIZE(pthread_key_t);
    737 
    738 #if SANITIZER_LINUX
    739 // There are more undocumented fields in dl_phdr_info that we are not interested
    740 // in.
    741 COMPILER_CHECK(sizeof(__sanitizer_dl_phdr_info) <= sizeof(dl_phdr_info));
    742 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_addr);
    743 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_name);
    744 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
    745 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
    746 
    747 COMPILER_CHECK(IOC_SIZE(0x12345678) == _IOC_SIZE(0x12345678));
    748 #endif
    749 
    750 #if SANITIZER_LINUX && !SANITIZER_ANDROID
    751 CHECK_TYPE_SIZE(glob_t);
    752 CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
    753 CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
    754 CHECK_SIZE_AND_OFFSET(glob_t, gl_offs);
    755 CHECK_SIZE_AND_OFFSET(glob_t, gl_flags);
    756 CHECK_SIZE_AND_OFFSET(glob_t, gl_closedir);
    757 CHECK_SIZE_AND_OFFSET(glob_t, gl_readdir);
    758 CHECK_SIZE_AND_OFFSET(glob_t, gl_opendir);
    759 CHECK_SIZE_AND_OFFSET(glob_t, gl_lstat);
    760 CHECK_SIZE_AND_OFFSET(glob_t, gl_stat);
    761 #endif
    762 
    763 CHECK_TYPE_SIZE(addrinfo);
    764 CHECK_SIZE_AND_OFFSET(addrinfo, ai_flags);
    765 CHECK_SIZE_AND_OFFSET(addrinfo, ai_family);
    766 CHECK_SIZE_AND_OFFSET(addrinfo, ai_socktype);
    767 CHECK_SIZE_AND_OFFSET(addrinfo, ai_protocol);
    768 CHECK_SIZE_AND_OFFSET(addrinfo, ai_protocol);
    769 CHECK_SIZE_AND_OFFSET(addrinfo, ai_addrlen);
    770 CHECK_SIZE_AND_OFFSET(addrinfo, ai_canonname);
    771 CHECK_SIZE_AND_OFFSET(addrinfo, ai_addr);
    772 
    773 CHECK_TYPE_SIZE(hostent);
    774 CHECK_SIZE_AND_OFFSET(hostent, h_name);
    775 CHECK_SIZE_AND_OFFSET(hostent, h_aliases);
    776 CHECK_SIZE_AND_OFFSET(hostent, h_addrtype);
    777 CHECK_SIZE_AND_OFFSET(hostent, h_length);
    778 CHECK_SIZE_AND_OFFSET(hostent, h_addr_list);
    779 
    780 CHECK_TYPE_SIZE(iovec);
    781 CHECK_SIZE_AND_OFFSET(iovec, iov_base);
    782 CHECK_SIZE_AND_OFFSET(iovec, iov_len);
    783 
    784 CHECK_TYPE_SIZE(msghdr);
    785 CHECK_SIZE_AND_OFFSET(msghdr, msg_name);
    786 CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen);
    787 CHECK_SIZE_AND_OFFSET(msghdr, msg_iov);
    788 CHECK_SIZE_AND_OFFSET(msghdr, msg_iovlen);
    789 CHECK_SIZE_AND_OFFSET(msghdr, msg_control);
    790 CHECK_SIZE_AND_OFFSET(msghdr, msg_controllen);
    791 CHECK_SIZE_AND_OFFSET(msghdr, msg_flags);
    792 
    793 CHECK_TYPE_SIZE(cmsghdr);
    794 CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
    795 CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
    796 CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
    797 
    798 COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
    799 CHECK_SIZE_AND_OFFSET(dirent, d_ino);
    800 #if SANITIZER_MAC
    801 CHECK_SIZE_AND_OFFSET(dirent, d_seekoff);
    802 #else
    803 CHECK_SIZE_AND_OFFSET(dirent, d_off);
    804 #endif
    805 CHECK_SIZE_AND_OFFSET(dirent, d_reclen);
    806 
    807 #if SANITIZER_LINUX && !SANITIZER_ANDROID
    808 COMPILER_CHECK(sizeof(__sanitizer_dirent64) <= sizeof(dirent64));
    809 CHECK_SIZE_AND_OFFSET(dirent64, d_ino);
    810 CHECK_SIZE_AND_OFFSET(dirent64, d_off);
    811 CHECK_SIZE_AND_OFFSET(dirent64, d_reclen);
    812 #endif
    813 
    814 CHECK_TYPE_SIZE(ifconf);
    815 CHECK_SIZE_AND_OFFSET(ifconf, ifc_len);
    816 CHECK_SIZE_AND_OFFSET(ifconf, ifc_ifcu);
    817 
    818 #endif  // SANITIZER_LINUX || SANITIZER_MAC
    819 
    820