sanitizer_platform_limits_posix.cc 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198
  1. //===-- sanitizer_platform_limits_posix.cc --------------------------------===//
  2. //
  3. // This file is distributed under the University of Illinois Open Source
  4. // License. See LICENSE.TXT for details.
  5. //
  6. //===----------------------------------------------------------------------===//
  7. //
  8. // This file is a part of Sanitizer common code.
  9. //
  10. // Sizes and layouts of platform-specific POSIX data structures.
  11. //===----------------------------------------------------------------------===//
  12. #include "sanitizer_platform.h"
  13. #if SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC
  14. // Tests in this file assume that off_t-dependent data structures match the
  15. // libc ABI. For example, struct dirent here is what readdir() function (as
  16. // exported from libc) returns, and not the user-facing "dirent", which
  17. // depends on _FILE_OFFSET_BITS setting.
  18. // To get this "true" dirent definition, we undefine _FILE_OFFSET_BITS below.
  19. #ifdef _FILE_OFFSET_BITS
  20. #undef _FILE_OFFSET_BITS
  21. #endif
  22. #if SANITIZER_FREEBSD
  23. #define _WANT_RTENTRY
  24. #include <sys/param.h>
  25. #include <sys/socketvar.h>
  26. #endif
  27. #include <arpa/inet.h>
  28. #include <dirent.h>
  29. #include <errno.h>
  30. #include <grp.h>
  31. #include <limits.h>
  32. #include <net/if.h>
  33. #include <net/if_arp.h>
  34. #include <net/route.h>
  35. #include <netdb.h>
  36. #include <poll.h>
  37. #include <pthread.h>
  38. #include <pwd.h>
  39. #include <signal.h>
  40. #include <stddef.h>
  41. #include <sys/mman.h>
  42. #include <sys/resource.h>
  43. #include <sys/socket.h>
  44. #include <sys/stat.h>
  45. #include <sys/time.h>
  46. #include <sys/times.h>
  47. #include <sys/types.h>
  48. #include <sys/utsname.h>
  49. #include <termios.h>
  50. #include <time.h>
  51. #include <wchar.h>
  52. #if !SANITIZER_ANDROID
  53. #include <sys/mount.h>
  54. #include <sys/timeb.h>
  55. #endif
  56. #if SANITIZER_LINUX
  57. #include <malloc.h>
  58. #include <mntent.h>
  59. #include <netinet/ether.h>
  60. #include <sys/sysinfo.h>
  61. #include <sys/vt.h>
  62. #include <linux/cdrom.h>
  63. #include <linux/fd.h>
  64. #include <linux/fs.h>
  65. #include <linux/hdreg.h>
  66. #include <linux/input.h>
  67. #include <linux/ioctl.h>
  68. #include <linux/soundcard.h>
  69. #include <linux/sysctl.h>
  70. #include <linux/utsname.h>
  71. #include <linux/posix_types.h>
  72. #endif
  73. #if SANITIZER_FREEBSD
  74. # include <sys/mount.h>
  75. # include <sys/sockio.h>
  76. # include <sys/socket.h>
  77. # include <sys/filio.h>
  78. # include <sys/signal.h>
  79. # include <sys/timespec.h>
  80. # include <sys/timex.h>
  81. # include <sys/mqueue.h>
  82. # include <sys/msg.h>
  83. # include <sys/ipc.h>
  84. # include <sys/msg.h>
  85. # include <sys/statvfs.h>
  86. # include <sys/soundcard.h>
  87. # include <sys/mtio.h>
  88. # include <sys/consio.h>
  89. # include <sys/kbio.h>
  90. # include <sys/link_elf.h>
  91. # include <netinet/ip_mroute.h>
  92. # include <netinet/in.h>
  93. # include <netinet/ip_compat.h>
  94. # include <net/ethernet.h>
  95. # include <net/ppp_defs.h>
  96. # include <glob.h>
  97. # include <term.h>
  98. #define _KERNEL // to declare 'shminfo' structure
  99. # include <sys/shm.h>
  100. #undef _KERNEL
  101. #undef INLINE // to avoid clashes with sanitizers' definitions
  102. #endif
  103. #if SANITIZER_FREEBSD || SANITIZER_IOS
  104. #undef IOC_DIRMASK
  105. #endif
  106. #if SANITIZER_LINUX || SANITIZER_FREEBSD
  107. # include <utime.h>
  108. # include <sys/ptrace.h>
  109. #endif
  110. #if !SANITIZER_ANDROID
  111. #include <ifaddrs.h>
  112. #include <sys/ucontext.h>
  113. #include <wordexp.h>
  114. #endif
  115. #if SANITIZER_LINUX && !SANITIZER_ANDROID
  116. #include <glob.h>
  117. #include <obstack.h>
  118. #include <mqueue.h>
  119. #include <net/if_ppp.h>
  120. #include <netax25/ax25.h>
  121. #include <netipx/ipx.h>
  122. #include <netrom/netrom.h>
  123. #if HAVE_RPC_XDR_H
  124. # include <rpc/xdr.h>
  125. #elif HAVE_TIRPC_RPC_XDR_H
  126. # include <tirpc/rpc/xdr.h>
  127. #endif
  128. #include <scsi/scsi.h>
  129. #include <sys/mtio.h>
  130. #include <sys/kd.h>
  131. #include <sys/shm.h>
  132. #include <sys/statvfs.h>
  133. #include <sys/timex.h>
  134. #include <sys/user.h>
  135. #include <sys/ustat.h>
  136. #include <linux/cyclades.h>
  137. #include <linux/if_eql.h>
  138. #include <linux/if_plip.h>
  139. #include <linux/lp.h>
  140. #include <linux/mroute.h>
  141. #include <linux/mroute6.h>
  142. #include <linux/scc.h>
  143. #include <linux/serial.h>
  144. #include <sys/msg.h>
  145. #include <sys/ipc.h>
  146. #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
  147. #if SANITIZER_ANDROID
  148. #include <linux/kd.h>
  149. #include <linux/mtio.h>
  150. #include <linux/ppp_defs.h>
  151. #include <linux/if_ppp.h>
  152. #endif
  153. #if SANITIZER_LINUX
  154. #include <link.h>
  155. #include <sys/vfs.h>
  156. #include <sys/epoll.h>
  157. #include <linux/capability.h>
  158. #endif // SANITIZER_LINUX
  159. #if SANITIZER_MAC
  160. #include <net/ethernet.h>
  161. #include <sys/filio.h>
  162. #include <sys/sockio.h>
  163. #endif
  164. // Include these after system headers to avoid name clashes and ambiguities.
  165. #include "sanitizer_internal_defs.h"
  166. #include "sanitizer_platform_limits_posix.h"
  167. namespace __sanitizer {
  168. unsigned struct_utsname_sz = sizeof(struct utsname);
  169. unsigned struct_stat_sz = sizeof(struct stat);
  170. #if !SANITIZER_IOS && !SANITIZER_FREEBSD
  171. unsigned struct_stat64_sz = sizeof(struct stat64);
  172. #endif // !SANITIZER_IOS && !SANITIZER_FREEBSD
  173. unsigned struct_rusage_sz = sizeof(struct rusage);
  174. unsigned struct_tm_sz = sizeof(struct tm);
  175. unsigned struct_passwd_sz = sizeof(struct passwd);
  176. unsigned struct_group_sz = sizeof(struct group);
  177. unsigned siginfo_t_sz = sizeof(siginfo_t);
  178. unsigned struct_sigaction_sz = sizeof(struct sigaction);
  179. unsigned struct_itimerval_sz = sizeof(struct itimerval);
  180. unsigned pthread_t_sz = sizeof(pthread_t);
  181. unsigned pthread_cond_t_sz = sizeof(pthread_cond_t);
  182. unsigned pid_t_sz = sizeof(pid_t);
  183. unsigned timeval_sz = sizeof(timeval);
  184. unsigned uid_t_sz = sizeof(uid_t);
  185. unsigned gid_t_sz = sizeof(gid_t);
  186. unsigned mbstate_t_sz = sizeof(mbstate_t);
  187. unsigned sigset_t_sz = sizeof(sigset_t);
  188. unsigned struct_timezone_sz = sizeof(struct timezone);
  189. unsigned struct_tms_sz = sizeof(struct tms);
  190. unsigned struct_sigevent_sz = sizeof(struct sigevent);
  191. unsigned struct_sched_param_sz = sizeof(struct sched_param);
  192. #if SANITIZER_MAC && !SANITIZER_IOS
  193. unsigned struct_statfs64_sz = sizeof(struct statfs64);
  194. #endif // SANITIZER_MAC && !SANITIZER_IOS
  195. #if !SANITIZER_ANDROID
  196. unsigned struct_statfs_sz = sizeof(struct statfs);
  197. unsigned struct_sockaddr_sz = sizeof(struct sockaddr);
  198. unsigned ucontext_t_sz = sizeof(ucontext_t);
  199. #endif // !SANITIZER_ANDROID
  200. #if SANITIZER_LINUX
  201. unsigned struct_epoll_event_sz = sizeof(struct epoll_event);
  202. unsigned struct_sysinfo_sz = sizeof(struct sysinfo);
  203. unsigned __user_cap_header_struct_sz =
  204. sizeof(struct __user_cap_header_struct);
  205. unsigned __user_cap_data_struct_sz = sizeof(struct __user_cap_data_struct);
  206. unsigned struct_new_utsname_sz = sizeof(struct new_utsname);
  207. unsigned struct_old_utsname_sz = sizeof(struct old_utsname);
  208. unsigned struct_oldold_utsname_sz = sizeof(struct oldold_utsname);
  209. #endif // SANITIZER_LINUX
  210. #if SANITIZER_LINUX || SANITIZER_FREEBSD
  211. unsigned struct_rlimit_sz = sizeof(struct rlimit);
  212. unsigned struct_timespec_sz = sizeof(struct timespec);
  213. unsigned struct_utimbuf_sz = sizeof(struct utimbuf);
  214. unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
  215. #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
  216. #if SANITIZER_LINUX && !SANITIZER_ANDROID
  217. unsigned struct_ustat_sz = sizeof(struct ustat);
  218. unsigned struct_rlimit64_sz = sizeof(struct rlimit64);
  219. unsigned struct_statvfs64_sz = sizeof(struct statvfs64);
  220. #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
  221. #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
  222. unsigned struct_timex_sz = sizeof(struct timex);
  223. unsigned struct_msqid_ds_sz = sizeof(struct msqid_ds);
  224. unsigned struct_mq_attr_sz = sizeof(struct mq_attr);
  225. unsigned struct_statvfs_sz = sizeof(struct statvfs);
  226. #endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
  227. uptr sig_ign = (uptr)SIG_IGN;
  228. uptr sig_dfl = (uptr)SIG_DFL;
  229. uptr sa_siginfo = (uptr)SA_SIGINFO;
  230. #if SANITIZER_LINUX
  231. int e_tabsz = (int)E_TABSZ;
  232. #endif
  233. #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
  234. unsigned struct_shminfo_sz = sizeof(struct shminfo);
  235. unsigned struct_shm_info_sz = sizeof(struct shm_info);
  236. int shmctl_ipc_stat = (int)IPC_STAT;
  237. int shmctl_ipc_info = (int)IPC_INFO;
  238. int shmctl_shm_info = (int)SHM_INFO;
  239. int shmctl_shm_stat = (int)SHM_STAT;
  240. #endif
  241. int map_fixed = MAP_FIXED;
  242. int af_inet = (int)AF_INET;
  243. int af_inet6 = (int)AF_INET6;
  244. uptr __sanitizer_in_addr_sz(int af) {
  245. if (af == AF_INET)
  246. return sizeof(struct in_addr);
  247. else if (af == AF_INET6)
  248. return sizeof(struct in6_addr);
  249. else
  250. return 0;
  251. }
  252. #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
  253. int glob_nomatch = GLOB_NOMATCH;
  254. int glob_altdirfunc = GLOB_ALTDIRFUNC;
  255. #endif
  256. #if SANITIZER_LINUX && !SANITIZER_ANDROID && \
  257. (defined(__i386) || defined(__x86_64))
  258. unsigned struct_user_regs_struct_sz = sizeof(struct user_regs_struct);
  259. unsigned struct_user_fpregs_struct_sz = sizeof(struct user_fpregs_struct);
  260. #ifdef __x86_64
  261. unsigned struct_user_fpxregs_struct_sz = 0;
  262. #else
  263. unsigned struct_user_fpxregs_struct_sz = sizeof(struct user_fpxregs_struct);
  264. #endif
  265. int ptrace_peektext = PTRACE_PEEKTEXT;
  266. int ptrace_peekdata = PTRACE_PEEKDATA;
  267. int ptrace_peekuser = PTRACE_PEEKUSER;
  268. int ptrace_getregs = PTRACE_GETREGS;
  269. int ptrace_setregs = PTRACE_SETREGS;
  270. int ptrace_getfpregs = PTRACE_GETFPREGS;
  271. int ptrace_setfpregs = PTRACE_SETFPREGS;
  272. int ptrace_getfpxregs = PTRACE_GETFPXREGS;
  273. int ptrace_setfpxregs = PTRACE_SETFPXREGS;
  274. int ptrace_geteventmsg = PTRACE_GETEVENTMSG;
  275. #if (defined(PTRACE_GETSIGINFO) && defined(PTRACE_SETSIGINFO)) || \
  276. (defined(PT_GETSIGINFO) && defined(PT_SETSIGINFO))
  277. int ptrace_getsiginfo = PTRACE_GETSIGINFO;
  278. int ptrace_setsiginfo = PTRACE_SETSIGINFO;
  279. #else
  280. int ptrace_getsiginfo = -1;
  281. int ptrace_setsiginfo = -1;
  282. #endif // PTRACE_GETSIGINFO/PTRACE_SETSIGINFO
  283. #if defined(PTRACE_GETREGSET) && defined(PTRACE_SETREGSET)
  284. int ptrace_getregset = PTRACE_GETREGSET;
  285. int ptrace_setregset = PTRACE_SETREGSET;
  286. #else
  287. int ptrace_getregset = -1;
  288. int ptrace_setregset = -1;
  289. #endif // PTRACE_GETREGSET/PTRACE_SETREGSET
  290. #endif
  291. unsigned path_max = PATH_MAX;
  292. // ioctl arguments
  293. unsigned struct_arpreq_sz = sizeof(struct arpreq);
  294. unsigned struct_ifreq_sz = sizeof(struct ifreq);
  295. unsigned struct_termios_sz = sizeof(struct termios);
  296. unsigned struct_winsize_sz = sizeof(struct winsize);
  297. #if SANITIZER_LINUX
  298. unsigned struct_cdrom_msf_sz = sizeof(struct cdrom_msf);
  299. unsigned struct_cdrom_multisession_sz = sizeof(struct cdrom_multisession);
  300. unsigned struct_cdrom_read_audio_sz = sizeof(struct cdrom_read_audio);
  301. unsigned struct_cdrom_subchnl_sz = sizeof(struct cdrom_subchnl);
  302. unsigned struct_cdrom_ti_sz = sizeof(struct cdrom_ti);
  303. unsigned struct_cdrom_tocentry_sz = sizeof(struct cdrom_tocentry);
  304. unsigned struct_cdrom_tochdr_sz = sizeof(struct cdrom_tochdr);
  305. unsigned struct_cdrom_volctrl_sz = sizeof(struct cdrom_volctrl);
  306. unsigned struct_ff_effect_sz = sizeof(struct ff_effect);
  307. unsigned struct_floppy_drive_params_sz = sizeof(struct floppy_drive_params);
  308. unsigned struct_floppy_drive_struct_sz = sizeof(struct floppy_drive_struct);
  309. unsigned struct_floppy_fdc_state_sz = sizeof(struct floppy_fdc_state);
  310. unsigned struct_floppy_max_errors_sz = sizeof(struct floppy_max_errors);
  311. unsigned struct_floppy_raw_cmd_sz = sizeof(struct floppy_raw_cmd);
  312. unsigned struct_floppy_struct_sz = sizeof(struct floppy_struct);
  313. unsigned struct_floppy_write_errors_sz = sizeof(struct floppy_write_errors);
  314. unsigned struct_format_descr_sz = sizeof(struct format_descr);
  315. unsigned struct_hd_driveid_sz = sizeof(struct hd_driveid);
  316. unsigned struct_hd_geometry_sz = sizeof(struct hd_geometry);
  317. unsigned struct_input_absinfo_sz = sizeof(struct input_absinfo);
  318. unsigned struct_input_id_sz = sizeof(struct input_id);
  319. unsigned struct_mtpos_sz = sizeof(struct mtpos);
  320. unsigned struct_termio_sz = sizeof(struct termio);
  321. unsigned struct_vt_consize_sz = sizeof(struct vt_consize);
  322. unsigned struct_vt_sizes_sz = sizeof(struct vt_sizes);
  323. unsigned struct_vt_stat_sz = sizeof(struct vt_stat);
  324. #endif // SANITIZER_LINUX
  325. #if SANITIZER_LINUX || SANITIZER_FREEBSD
  326. #if SOUND_VERSION >= 0x040000
  327. unsigned struct_copr_buffer_sz = 0;
  328. unsigned struct_copr_debug_buf_sz = 0;
  329. unsigned struct_copr_msg_sz = 0;
  330. #else
  331. unsigned struct_copr_buffer_sz = sizeof(struct copr_buffer);
  332. unsigned struct_copr_debug_buf_sz = sizeof(struct copr_debug_buf);
  333. unsigned struct_copr_msg_sz = sizeof(struct copr_msg);
  334. #endif
  335. unsigned struct_midi_info_sz = sizeof(struct midi_info);
  336. unsigned struct_mtget_sz = sizeof(struct mtget);
  337. unsigned struct_mtop_sz = sizeof(struct mtop);
  338. unsigned struct_rtentry_sz = sizeof(struct rtentry);
  339. unsigned struct_sbi_instrument_sz = sizeof(struct sbi_instrument);
  340. unsigned struct_seq_event_rec_sz = sizeof(struct seq_event_rec);
  341. unsigned struct_synth_info_sz = sizeof(struct synth_info);
  342. unsigned struct_vt_mode_sz = sizeof(struct vt_mode);
  343. #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
  344. #if SANITIZER_LINUX && !SANITIZER_ANDROID
  345. unsigned struct_ax25_parms_struct_sz = sizeof(struct ax25_parms_struct);
  346. unsigned struct_cyclades_monitor_sz = sizeof(struct cyclades_monitor);
  347. #if EV_VERSION > (0x010000)
  348. unsigned struct_input_keymap_entry_sz = sizeof(struct input_keymap_entry);
  349. #else
  350. unsigned struct_input_keymap_entry_sz = 0;
  351. #endif
  352. unsigned struct_ipx_config_data_sz = sizeof(struct ipx_config_data);
  353. unsigned struct_kbdiacrs_sz = sizeof(struct kbdiacrs);
  354. unsigned struct_kbentry_sz = sizeof(struct kbentry);
  355. unsigned struct_kbkeycode_sz = sizeof(struct kbkeycode);
  356. unsigned struct_kbsentry_sz = sizeof(struct kbsentry);
  357. unsigned struct_mtconfiginfo_sz = sizeof(struct mtconfiginfo);
  358. unsigned struct_nr_parms_struct_sz = sizeof(struct nr_parms_struct);
  359. unsigned struct_scc_modem_sz = sizeof(struct scc_modem);
  360. unsigned struct_scc_stat_sz = sizeof(struct scc_stat);
  361. unsigned struct_serial_multiport_struct_sz
  362. = sizeof(struct serial_multiport_struct);
  363. unsigned struct_serial_struct_sz = sizeof(struct serial_struct);
  364. unsigned struct_sockaddr_ax25_sz = sizeof(struct sockaddr_ax25);
  365. unsigned struct_unimapdesc_sz = sizeof(struct unimapdesc);
  366. unsigned struct_unimapinit_sz = sizeof(struct unimapinit);
  367. #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
  368. #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
  369. unsigned struct_audio_buf_info_sz = sizeof(struct audio_buf_info);
  370. unsigned struct_ppp_stats_sz = sizeof(struct ppp_stats);
  371. #endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
  372. #if !SANITIZER_ANDROID && !SANITIZER_MAC
  373. unsigned struct_sioc_sg_req_sz = sizeof(struct sioc_sg_req);
  374. unsigned struct_sioc_vif_req_sz = sizeof(struct sioc_vif_req);
  375. #endif
  376. const unsigned IOCTL_NOT_PRESENT = 0;
  377. unsigned IOCTL_FIOASYNC = FIOASYNC;
  378. unsigned IOCTL_FIOCLEX = FIOCLEX;
  379. unsigned IOCTL_FIOGETOWN = FIOGETOWN;
  380. unsigned IOCTL_FIONBIO = FIONBIO;
  381. unsigned IOCTL_FIONCLEX = FIONCLEX;
  382. unsigned IOCTL_FIOSETOWN = FIOSETOWN;
  383. unsigned IOCTL_SIOCADDMULTI = SIOCADDMULTI;
  384. unsigned IOCTL_SIOCATMARK = SIOCATMARK;
  385. unsigned IOCTL_SIOCDELMULTI = SIOCDELMULTI;
  386. unsigned IOCTL_SIOCGIFADDR = SIOCGIFADDR;
  387. unsigned IOCTL_SIOCGIFBRDADDR = SIOCGIFBRDADDR;
  388. unsigned IOCTL_SIOCGIFCONF = SIOCGIFCONF;
  389. unsigned IOCTL_SIOCGIFDSTADDR = SIOCGIFDSTADDR;
  390. unsigned IOCTL_SIOCGIFFLAGS = SIOCGIFFLAGS;
  391. unsigned IOCTL_SIOCGIFMETRIC = SIOCGIFMETRIC;
  392. unsigned IOCTL_SIOCGIFMTU = SIOCGIFMTU;
  393. unsigned IOCTL_SIOCGIFNETMASK = SIOCGIFNETMASK;
  394. unsigned IOCTL_SIOCGPGRP = SIOCGPGRP;
  395. unsigned IOCTL_SIOCSIFADDR = SIOCSIFADDR;
  396. unsigned IOCTL_SIOCSIFBRDADDR = SIOCSIFBRDADDR;
  397. unsigned IOCTL_SIOCSIFDSTADDR = SIOCSIFDSTADDR;
  398. unsigned IOCTL_SIOCSIFFLAGS = SIOCSIFFLAGS;
  399. unsigned IOCTL_SIOCSIFMETRIC = SIOCSIFMETRIC;
  400. unsigned IOCTL_SIOCSIFMTU = SIOCSIFMTU;
  401. unsigned IOCTL_SIOCSIFNETMASK = SIOCSIFNETMASK;
  402. unsigned IOCTL_SIOCSPGRP = SIOCSPGRP;
  403. unsigned IOCTL_TIOCCONS = TIOCCONS;
  404. unsigned IOCTL_TIOCEXCL = TIOCEXCL;
  405. unsigned IOCTL_TIOCGETD = TIOCGETD;
  406. unsigned IOCTL_TIOCGPGRP = TIOCGPGRP;
  407. unsigned IOCTL_TIOCGWINSZ = TIOCGWINSZ;
  408. unsigned IOCTL_TIOCMBIC = TIOCMBIC;
  409. unsigned IOCTL_TIOCMBIS = TIOCMBIS;
  410. unsigned IOCTL_TIOCMGET = TIOCMGET;
  411. unsigned IOCTL_TIOCMSET = TIOCMSET;
  412. unsigned IOCTL_TIOCNOTTY = TIOCNOTTY;
  413. unsigned IOCTL_TIOCNXCL = TIOCNXCL;
  414. unsigned IOCTL_TIOCOUTQ = TIOCOUTQ;
  415. unsigned IOCTL_TIOCPKT = TIOCPKT;
  416. unsigned IOCTL_TIOCSCTTY = TIOCSCTTY;
  417. unsigned IOCTL_TIOCSETD = TIOCSETD;
  418. unsigned IOCTL_TIOCSPGRP = TIOCSPGRP;
  419. unsigned IOCTL_TIOCSTI = TIOCSTI;
  420. unsigned IOCTL_TIOCSWINSZ = TIOCSWINSZ;
  421. #if ((SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID)
  422. unsigned IOCTL_SIOCGETSGCNT = SIOCGETSGCNT;
  423. unsigned IOCTL_SIOCGETVIFCNT = SIOCGETVIFCNT;
  424. #endif
  425. #if SANITIZER_LINUX
  426. unsigned IOCTL_EVIOCGABS = EVIOCGABS(0);
  427. unsigned IOCTL_EVIOCGBIT = EVIOCGBIT(0, 0);
  428. unsigned IOCTL_EVIOCGEFFECTS = EVIOCGEFFECTS;
  429. unsigned IOCTL_EVIOCGID = EVIOCGID;
  430. unsigned IOCTL_EVIOCGKEY = EVIOCGKEY(0);
  431. unsigned IOCTL_EVIOCGKEYCODE = EVIOCGKEYCODE;
  432. unsigned IOCTL_EVIOCGLED = EVIOCGLED(0);
  433. unsigned IOCTL_EVIOCGNAME = EVIOCGNAME(0);
  434. unsigned IOCTL_EVIOCGPHYS = EVIOCGPHYS(0);
  435. unsigned IOCTL_EVIOCGRAB = EVIOCGRAB;
  436. unsigned IOCTL_EVIOCGREP = EVIOCGREP;
  437. unsigned IOCTL_EVIOCGSND = EVIOCGSND(0);
  438. unsigned IOCTL_EVIOCGSW = EVIOCGSW(0);
  439. unsigned IOCTL_EVIOCGUNIQ = EVIOCGUNIQ(0);
  440. unsigned IOCTL_EVIOCGVERSION = EVIOCGVERSION;
  441. unsigned IOCTL_EVIOCRMFF = EVIOCRMFF;
  442. unsigned IOCTL_EVIOCSABS = EVIOCSABS(0);
  443. unsigned IOCTL_EVIOCSFF = EVIOCSFF;
  444. unsigned IOCTL_EVIOCSKEYCODE = EVIOCSKEYCODE;
  445. unsigned IOCTL_EVIOCSREP = EVIOCSREP;
  446. unsigned IOCTL_BLKFLSBUF = BLKFLSBUF;
  447. unsigned IOCTL_BLKGETSIZE = BLKGETSIZE;
  448. unsigned IOCTL_BLKRAGET = BLKRAGET;
  449. unsigned IOCTL_BLKRASET = BLKRASET;
  450. unsigned IOCTL_BLKROGET = BLKROGET;
  451. unsigned IOCTL_BLKROSET = BLKROSET;
  452. unsigned IOCTL_BLKRRPART = BLKRRPART;
  453. unsigned IOCTL_CDROMAUDIOBUFSIZ = CDROMAUDIOBUFSIZ;
  454. unsigned IOCTL_CDROMEJECT = CDROMEJECT;
  455. unsigned IOCTL_CDROMEJECT_SW = CDROMEJECT_SW;
  456. unsigned IOCTL_CDROMMULTISESSION = CDROMMULTISESSION;
  457. unsigned IOCTL_CDROMPAUSE = CDROMPAUSE;
  458. unsigned IOCTL_CDROMPLAYMSF = CDROMPLAYMSF;
  459. unsigned IOCTL_CDROMPLAYTRKIND = CDROMPLAYTRKIND;
  460. unsigned IOCTL_CDROMREADAUDIO = CDROMREADAUDIO;
  461. unsigned IOCTL_CDROMREADCOOKED = CDROMREADCOOKED;
  462. unsigned IOCTL_CDROMREADMODE1 = CDROMREADMODE1;
  463. unsigned IOCTL_CDROMREADMODE2 = CDROMREADMODE2;
  464. unsigned IOCTL_CDROMREADRAW = CDROMREADRAW;
  465. unsigned IOCTL_CDROMREADTOCENTRY = CDROMREADTOCENTRY;
  466. unsigned IOCTL_CDROMREADTOCHDR = CDROMREADTOCHDR;
  467. unsigned IOCTL_CDROMRESET = CDROMRESET;
  468. unsigned IOCTL_CDROMRESUME = CDROMRESUME;
  469. unsigned IOCTL_CDROMSEEK = CDROMSEEK;
  470. unsigned IOCTL_CDROMSTART = CDROMSTART;
  471. unsigned IOCTL_CDROMSTOP = CDROMSTOP;
  472. unsigned IOCTL_CDROMSUBCHNL = CDROMSUBCHNL;
  473. unsigned IOCTL_CDROMVOLCTRL = CDROMVOLCTRL;
  474. unsigned IOCTL_CDROMVOLREAD = CDROMVOLREAD;
  475. unsigned IOCTL_CDROM_GET_UPC = CDROM_GET_UPC;
  476. unsigned IOCTL_FDCLRPRM = FDCLRPRM;
  477. unsigned IOCTL_FDDEFPRM = FDDEFPRM;
  478. unsigned IOCTL_FDFLUSH = FDFLUSH;
  479. unsigned IOCTL_FDFMTBEG = FDFMTBEG;
  480. unsigned IOCTL_FDFMTEND = FDFMTEND;
  481. unsigned IOCTL_FDFMTTRK = FDFMTTRK;
  482. unsigned IOCTL_FDGETDRVPRM = FDGETDRVPRM;
  483. unsigned IOCTL_FDGETDRVSTAT = FDGETDRVSTAT;
  484. unsigned IOCTL_FDGETDRVTYP = FDGETDRVTYP;
  485. unsigned IOCTL_FDGETFDCSTAT = FDGETFDCSTAT;
  486. unsigned IOCTL_FDGETMAXERRS = FDGETMAXERRS;
  487. unsigned IOCTL_FDGETPRM = FDGETPRM;
  488. unsigned IOCTL_FDMSGOFF = FDMSGOFF;
  489. unsigned IOCTL_FDMSGON = FDMSGON;
  490. unsigned IOCTL_FDPOLLDRVSTAT = FDPOLLDRVSTAT;
  491. unsigned IOCTL_FDRAWCMD = FDRAWCMD;
  492. unsigned IOCTL_FDRESET = FDRESET;
  493. unsigned IOCTL_FDSETDRVPRM = FDSETDRVPRM;
  494. unsigned IOCTL_FDSETEMSGTRESH = FDSETEMSGTRESH;
  495. unsigned IOCTL_FDSETMAXERRS = FDSETMAXERRS;
  496. unsigned IOCTL_FDSETPRM = FDSETPRM;
  497. unsigned IOCTL_FDTWADDLE = FDTWADDLE;
  498. unsigned IOCTL_FDWERRORCLR = FDWERRORCLR;
  499. unsigned IOCTL_FDWERRORGET = FDWERRORGET;
  500. unsigned IOCTL_HDIO_DRIVE_CMD = HDIO_DRIVE_CMD;
  501. unsigned IOCTL_HDIO_GETGEO = HDIO_GETGEO;
  502. unsigned IOCTL_HDIO_GET_32BIT = HDIO_GET_32BIT;
  503. unsigned IOCTL_HDIO_GET_DMA = HDIO_GET_DMA;
  504. unsigned IOCTL_HDIO_GET_IDENTITY = HDIO_GET_IDENTITY;
  505. unsigned IOCTL_HDIO_GET_KEEPSETTINGS = HDIO_GET_KEEPSETTINGS;
  506. unsigned IOCTL_HDIO_GET_MULTCOUNT = HDIO_GET_MULTCOUNT;
  507. unsigned IOCTL_HDIO_GET_NOWERR = HDIO_GET_NOWERR;
  508. unsigned IOCTL_HDIO_GET_UNMASKINTR = HDIO_GET_UNMASKINTR;
  509. unsigned IOCTL_HDIO_SET_32BIT = HDIO_SET_32BIT;
  510. unsigned IOCTL_HDIO_SET_DMA = HDIO_SET_DMA;
  511. unsigned IOCTL_HDIO_SET_KEEPSETTINGS = HDIO_SET_KEEPSETTINGS;
  512. unsigned IOCTL_HDIO_SET_MULTCOUNT = HDIO_SET_MULTCOUNT;
  513. unsigned IOCTL_HDIO_SET_NOWERR = HDIO_SET_NOWERR;
  514. unsigned IOCTL_HDIO_SET_UNMASKINTR = HDIO_SET_UNMASKINTR;
  515. unsigned IOCTL_MTIOCPOS = MTIOCPOS;
  516. unsigned IOCTL_PPPIOCGASYNCMAP = PPPIOCGASYNCMAP;
  517. unsigned IOCTL_PPPIOCGDEBUG = PPPIOCGDEBUG;
  518. unsigned IOCTL_PPPIOCGFLAGS = PPPIOCGFLAGS;
  519. unsigned IOCTL_PPPIOCGUNIT = PPPIOCGUNIT;
  520. unsigned IOCTL_PPPIOCGXASYNCMAP = PPPIOCGXASYNCMAP;
  521. unsigned IOCTL_PPPIOCSASYNCMAP = PPPIOCSASYNCMAP;
  522. unsigned IOCTL_PPPIOCSDEBUG = PPPIOCSDEBUG;
  523. unsigned IOCTL_PPPIOCSFLAGS = PPPIOCSFLAGS;
  524. unsigned IOCTL_PPPIOCSMAXCID = PPPIOCSMAXCID;
  525. unsigned IOCTL_PPPIOCSMRU = PPPIOCSMRU;
  526. unsigned IOCTL_PPPIOCSXASYNCMAP = PPPIOCSXASYNCMAP;
  527. unsigned IOCTL_SIOCADDRT = SIOCADDRT;
  528. unsigned IOCTL_SIOCDARP = SIOCDARP;
  529. unsigned IOCTL_SIOCDELRT = SIOCDELRT;
  530. unsigned IOCTL_SIOCDRARP = SIOCDRARP;
  531. unsigned IOCTL_SIOCGARP = SIOCGARP;
  532. unsigned IOCTL_SIOCGIFENCAP = SIOCGIFENCAP;
  533. unsigned IOCTL_SIOCGIFHWADDR = SIOCGIFHWADDR;
  534. unsigned IOCTL_SIOCGIFMAP = SIOCGIFMAP;
  535. unsigned IOCTL_SIOCGIFMEM = SIOCGIFMEM;
  536. unsigned IOCTL_SIOCGIFNAME = SIOCGIFNAME;
  537. unsigned IOCTL_SIOCGIFSLAVE = SIOCGIFSLAVE;
  538. unsigned IOCTL_SIOCGRARP = SIOCGRARP;
  539. unsigned IOCTL_SIOCGSTAMP = SIOCGSTAMP;
  540. unsigned IOCTL_SIOCSARP = SIOCSARP;
  541. unsigned IOCTL_SIOCSIFENCAP = SIOCSIFENCAP;
  542. unsigned IOCTL_SIOCSIFHWADDR = SIOCSIFHWADDR;
  543. unsigned IOCTL_SIOCSIFLINK = SIOCSIFLINK;
  544. unsigned IOCTL_SIOCSIFMAP = SIOCSIFMAP;
  545. unsigned IOCTL_SIOCSIFMEM = SIOCSIFMEM;
  546. unsigned IOCTL_SIOCSIFSLAVE = SIOCSIFSLAVE;
  547. unsigned IOCTL_SIOCSRARP = SIOCSRARP;
  548. # if SOUND_VERSION >= 0x040000
  549. unsigned IOCTL_SNDCTL_COPR_HALT = IOCTL_NOT_PRESENT;
  550. unsigned IOCTL_SNDCTL_COPR_LOAD = IOCTL_NOT_PRESENT;
  551. unsigned IOCTL_SNDCTL_COPR_RCODE = IOCTL_NOT_PRESENT;
  552. unsigned IOCTL_SNDCTL_COPR_RCVMSG = IOCTL_NOT_PRESENT;
  553. unsigned IOCTL_SNDCTL_COPR_RDATA = IOCTL_NOT_PRESENT;
  554. unsigned IOCTL_SNDCTL_COPR_RESET = IOCTL_NOT_PRESENT;
  555. unsigned IOCTL_SNDCTL_COPR_RUN = IOCTL_NOT_PRESENT;
  556. unsigned IOCTL_SNDCTL_COPR_SENDMSG = IOCTL_NOT_PRESENT;
  557. unsigned IOCTL_SNDCTL_COPR_WCODE = IOCTL_NOT_PRESENT;
  558. unsigned IOCTL_SNDCTL_COPR_WDATA = IOCTL_NOT_PRESENT;
  559. unsigned IOCTL_SOUND_PCM_READ_BITS = IOCTL_NOT_PRESENT;
  560. unsigned IOCTL_SOUND_PCM_READ_CHANNELS = IOCTL_NOT_PRESENT;
  561. unsigned IOCTL_SOUND_PCM_READ_FILTER = IOCTL_NOT_PRESENT;
  562. unsigned IOCTL_SOUND_PCM_READ_RATE = IOCTL_NOT_PRESENT;
  563. unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS = IOCTL_NOT_PRESENT;
  564. unsigned IOCTL_SOUND_PCM_WRITE_FILTER = IOCTL_NOT_PRESENT;
  565. # else // SOUND_VERSION
  566. unsigned IOCTL_SNDCTL_COPR_HALT = SNDCTL_COPR_HALT;
  567. unsigned IOCTL_SNDCTL_COPR_LOAD = SNDCTL_COPR_LOAD;
  568. unsigned IOCTL_SNDCTL_COPR_RCODE = SNDCTL_COPR_RCODE;
  569. unsigned IOCTL_SNDCTL_COPR_RCVMSG = SNDCTL_COPR_RCVMSG;
  570. unsigned IOCTL_SNDCTL_COPR_RDATA = SNDCTL_COPR_RDATA;
  571. unsigned IOCTL_SNDCTL_COPR_RESET = SNDCTL_COPR_RESET;
  572. unsigned IOCTL_SNDCTL_COPR_RUN = SNDCTL_COPR_RUN;
  573. unsigned IOCTL_SNDCTL_COPR_SENDMSG = SNDCTL_COPR_SENDMSG;
  574. unsigned IOCTL_SNDCTL_COPR_WCODE = SNDCTL_COPR_WCODE;
  575. unsigned IOCTL_SNDCTL_COPR_WDATA = SNDCTL_COPR_WDATA;
  576. unsigned IOCTL_SOUND_PCM_READ_BITS = SOUND_PCM_READ_BITS;
  577. unsigned IOCTL_SOUND_PCM_READ_CHANNELS = SOUND_PCM_READ_CHANNELS;
  578. unsigned IOCTL_SOUND_PCM_READ_FILTER = SOUND_PCM_READ_FILTER;
  579. unsigned IOCTL_SOUND_PCM_READ_RATE = SOUND_PCM_READ_RATE;
  580. unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS = SOUND_PCM_WRITE_CHANNELS;
  581. unsigned IOCTL_SOUND_PCM_WRITE_FILTER = SOUND_PCM_WRITE_FILTER;
  582. #endif // SOUND_VERSION
  583. unsigned IOCTL_TCFLSH = TCFLSH;
  584. unsigned IOCTL_TCGETA = TCGETA;
  585. unsigned IOCTL_TCGETS = TCGETS;
  586. unsigned IOCTL_TCSBRK = TCSBRK;
  587. unsigned IOCTL_TCSBRKP = TCSBRKP;
  588. unsigned IOCTL_TCSETA = TCSETA;
  589. unsigned IOCTL_TCSETAF = TCSETAF;
  590. unsigned IOCTL_TCSETAW = TCSETAW;
  591. unsigned IOCTL_TCSETS = TCSETS;
  592. unsigned IOCTL_TCSETSF = TCSETSF;
  593. unsigned IOCTL_TCSETSW = TCSETSW;
  594. unsigned IOCTL_TCXONC = TCXONC;
  595. unsigned IOCTL_TIOCGLCKTRMIOS = TIOCGLCKTRMIOS;
  596. unsigned IOCTL_TIOCGSOFTCAR = TIOCGSOFTCAR;
  597. unsigned IOCTL_TIOCINQ = TIOCINQ;
  598. unsigned IOCTL_TIOCLINUX = TIOCLINUX;
  599. unsigned IOCTL_TIOCSERCONFIG = TIOCSERCONFIG;
  600. unsigned IOCTL_TIOCSERGETLSR = TIOCSERGETLSR;
  601. unsigned IOCTL_TIOCSERGWILD = TIOCSERGWILD;
  602. unsigned IOCTL_TIOCSERSWILD = TIOCSERSWILD;
  603. unsigned IOCTL_TIOCSLCKTRMIOS = TIOCSLCKTRMIOS;
  604. unsigned IOCTL_TIOCSSOFTCAR = TIOCSSOFTCAR;
  605. unsigned IOCTL_VT_DISALLOCATE = VT_DISALLOCATE;
  606. unsigned IOCTL_VT_GETSTATE = VT_GETSTATE;
  607. unsigned IOCTL_VT_RESIZE = VT_RESIZE;
  608. unsigned IOCTL_VT_RESIZEX = VT_RESIZEX;
  609. unsigned IOCTL_VT_SENDSIG = VT_SENDSIG;
  610. #endif // SANITIZER_LINUX
  611. #if SANITIZER_LINUX || SANITIZER_FREEBSD
  612. unsigned IOCTL_MTIOCGET = MTIOCGET;
  613. unsigned IOCTL_MTIOCTOP = MTIOCTOP;
  614. unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE = SNDCTL_DSP_GETBLKSIZE;
  615. unsigned IOCTL_SNDCTL_DSP_GETFMTS = SNDCTL_DSP_GETFMTS;
  616. unsigned IOCTL_SNDCTL_DSP_NONBLOCK = SNDCTL_DSP_NONBLOCK;
  617. unsigned IOCTL_SNDCTL_DSP_POST = SNDCTL_DSP_POST;
  618. unsigned IOCTL_SNDCTL_DSP_RESET = SNDCTL_DSP_RESET;
  619. unsigned IOCTL_SNDCTL_DSP_SETFMT = SNDCTL_DSP_SETFMT;
  620. unsigned IOCTL_SNDCTL_DSP_SETFRAGMENT = SNDCTL_DSP_SETFRAGMENT;
  621. unsigned IOCTL_SNDCTL_DSP_SPEED = SNDCTL_DSP_SPEED;
  622. unsigned IOCTL_SNDCTL_DSP_STEREO = SNDCTL_DSP_STEREO;
  623. unsigned IOCTL_SNDCTL_DSP_SUBDIVIDE = SNDCTL_DSP_SUBDIVIDE;
  624. unsigned IOCTL_SNDCTL_DSP_SYNC = SNDCTL_DSP_SYNC;
  625. unsigned IOCTL_SNDCTL_FM_4OP_ENABLE = SNDCTL_FM_4OP_ENABLE;
  626. unsigned IOCTL_SNDCTL_FM_LOAD_INSTR = SNDCTL_FM_LOAD_INSTR;
  627. unsigned IOCTL_SNDCTL_MIDI_INFO = SNDCTL_MIDI_INFO;
  628. unsigned IOCTL_SNDCTL_MIDI_PRETIME = SNDCTL_MIDI_PRETIME;
  629. unsigned IOCTL_SNDCTL_SEQ_CTRLRATE = SNDCTL_SEQ_CTRLRATE;
  630. unsigned IOCTL_SNDCTL_SEQ_GETINCOUNT = SNDCTL_SEQ_GETINCOUNT;
  631. unsigned IOCTL_SNDCTL_SEQ_GETOUTCOUNT = SNDCTL_SEQ_GETOUTCOUNT;
  632. unsigned IOCTL_SNDCTL_SEQ_NRMIDIS = SNDCTL_SEQ_NRMIDIS;
  633. unsigned IOCTL_SNDCTL_SEQ_NRSYNTHS = SNDCTL_SEQ_NRSYNTHS;
  634. unsigned IOCTL_SNDCTL_SEQ_OUTOFBAND = SNDCTL_SEQ_OUTOFBAND;
  635. unsigned IOCTL_SNDCTL_SEQ_PANIC = SNDCTL_SEQ_PANIC;
  636. unsigned IOCTL_SNDCTL_SEQ_PERCMODE = SNDCTL_SEQ_PERCMODE;
  637. unsigned IOCTL_SNDCTL_SEQ_RESET = SNDCTL_SEQ_RESET;
  638. unsigned IOCTL_SNDCTL_SEQ_RESETSAMPLES = SNDCTL_SEQ_RESETSAMPLES;
  639. unsigned IOCTL_SNDCTL_SEQ_SYNC = SNDCTL_SEQ_SYNC;
  640. unsigned IOCTL_SNDCTL_SEQ_TESTMIDI = SNDCTL_SEQ_TESTMIDI;
  641. unsigned IOCTL_SNDCTL_SEQ_THRESHOLD = SNDCTL_SEQ_THRESHOLD;
  642. unsigned IOCTL_SNDCTL_SYNTH_INFO = SNDCTL_SYNTH_INFO;
  643. unsigned IOCTL_SNDCTL_SYNTH_MEMAVL = SNDCTL_SYNTH_MEMAVL;
  644. unsigned IOCTL_SNDCTL_TMR_CONTINUE = SNDCTL_TMR_CONTINUE;
  645. unsigned IOCTL_SNDCTL_TMR_METRONOME = SNDCTL_TMR_METRONOME;
  646. unsigned IOCTL_SNDCTL_TMR_SELECT = SNDCTL_TMR_SELECT;
  647. unsigned IOCTL_SNDCTL_TMR_SOURCE = SNDCTL_TMR_SOURCE;
  648. unsigned IOCTL_SNDCTL_TMR_START = SNDCTL_TMR_START;
  649. unsigned IOCTL_SNDCTL_TMR_STOP = SNDCTL_TMR_STOP;
  650. unsigned IOCTL_SNDCTL_TMR_TEMPO = SNDCTL_TMR_TEMPO;
  651. unsigned IOCTL_SNDCTL_TMR_TIMEBASE = SNDCTL_TMR_TIMEBASE;
  652. unsigned IOCTL_SOUND_MIXER_READ_ALTPCM = SOUND_MIXER_READ_ALTPCM;
  653. unsigned IOCTL_SOUND_MIXER_READ_BASS = SOUND_MIXER_READ_BASS;
  654. unsigned IOCTL_SOUND_MIXER_READ_CAPS = SOUND_MIXER_READ_CAPS;
  655. unsigned IOCTL_SOUND_MIXER_READ_CD = SOUND_MIXER_READ_CD;
  656. unsigned IOCTL_SOUND_MIXER_READ_DEVMASK = SOUND_MIXER_READ_DEVMASK;
  657. unsigned IOCTL_SOUND_MIXER_READ_ENHANCE = SOUND_MIXER_READ_ENHANCE;
  658. unsigned IOCTL_SOUND_MIXER_READ_IGAIN = SOUND_MIXER_READ_IGAIN;
  659. unsigned IOCTL_SOUND_MIXER_READ_IMIX = SOUND_MIXER_READ_IMIX;
  660. unsigned IOCTL_SOUND_MIXER_READ_LINE = SOUND_MIXER_READ_LINE;
  661. unsigned IOCTL_SOUND_MIXER_READ_LINE1 = SOUND_MIXER_READ_LINE1;
  662. unsigned IOCTL_SOUND_MIXER_READ_LINE2 = SOUND_MIXER_READ_LINE2;
  663. unsigned IOCTL_SOUND_MIXER_READ_LINE3 = SOUND_MIXER_READ_LINE3;
  664. unsigned IOCTL_SOUND_MIXER_READ_LOUD = SOUND_MIXER_READ_LOUD;
  665. unsigned IOCTL_SOUND_MIXER_READ_MIC = SOUND_MIXER_READ_MIC;
  666. unsigned IOCTL_SOUND_MIXER_READ_MUTE = SOUND_MIXER_READ_MUTE;
  667. unsigned IOCTL_SOUND_MIXER_READ_OGAIN = SOUND_MIXER_READ_OGAIN;
  668. unsigned IOCTL_SOUND_MIXER_READ_PCM = SOUND_MIXER_READ_PCM;
  669. unsigned IOCTL_SOUND_MIXER_READ_RECLEV = SOUND_MIXER_READ_RECLEV;
  670. unsigned IOCTL_SOUND_MIXER_READ_RECMASK = SOUND_MIXER_READ_RECMASK;
  671. unsigned IOCTL_SOUND_MIXER_READ_RECSRC = SOUND_MIXER_READ_RECSRC;
  672. unsigned IOCTL_SOUND_MIXER_READ_SPEAKER = SOUND_MIXER_READ_SPEAKER;
  673. unsigned IOCTL_SOUND_MIXER_READ_STEREODEVS = SOUND_MIXER_READ_STEREODEVS;
  674. unsigned IOCTL_SOUND_MIXER_READ_SYNTH = SOUND_MIXER_READ_SYNTH;
  675. unsigned IOCTL_SOUND_MIXER_READ_TREBLE = SOUND_MIXER_READ_TREBLE;
  676. unsigned IOCTL_SOUND_MIXER_READ_VOLUME = SOUND_MIXER_READ_VOLUME;
  677. unsigned IOCTL_SOUND_MIXER_WRITE_ALTPCM = SOUND_MIXER_WRITE_ALTPCM;
  678. unsigned IOCTL_SOUND_MIXER_WRITE_BASS = SOUND_MIXER_WRITE_BASS;
  679. unsigned IOCTL_SOUND_MIXER_WRITE_CD = SOUND_MIXER_WRITE_CD;
  680. unsigned IOCTL_SOUND_MIXER_WRITE_ENHANCE = SOUND_MIXER_WRITE_ENHANCE;
  681. unsigned IOCTL_SOUND_MIXER_WRITE_IGAIN = SOUND_MIXER_WRITE_IGAIN;
  682. unsigned IOCTL_SOUND_MIXER_WRITE_IMIX = SOUND_MIXER_WRITE_IMIX;
  683. unsigned IOCTL_SOUND_MIXER_WRITE_LINE = SOUND_MIXER_WRITE_LINE;
  684. unsigned IOCTL_SOUND_MIXER_WRITE_LINE1 = SOUND_MIXER_WRITE_LINE1;
  685. unsigned IOCTL_SOUND_MIXER_WRITE_LINE2 = SOUND_MIXER_WRITE_LINE2;
  686. unsigned IOCTL_SOUND_MIXER_WRITE_LINE3 = SOUND_MIXER_WRITE_LINE3;
  687. unsigned IOCTL_SOUND_MIXER_WRITE_LOUD = SOUND_MIXER_WRITE_LOUD;
  688. unsigned IOCTL_SOUND_MIXER_WRITE_MIC = SOUND_MIXER_WRITE_MIC;
  689. unsigned IOCTL_SOUND_MIXER_WRITE_MUTE = SOUND_MIXER_WRITE_MUTE;
  690. unsigned IOCTL_SOUND_MIXER_WRITE_OGAIN = SOUND_MIXER_WRITE_OGAIN;
  691. unsigned IOCTL_SOUND_MIXER_WRITE_PCM = SOUND_MIXER_WRITE_PCM;
  692. unsigned IOCTL_SOUND_MIXER_WRITE_RECLEV = SOUND_MIXER_WRITE_RECLEV;
  693. unsigned IOCTL_SOUND_MIXER_WRITE_RECSRC = SOUND_MIXER_WRITE_RECSRC;
  694. unsigned IOCTL_SOUND_MIXER_WRITE_SPEAKER = SOUND_MIXER_WRITE_SPEAKER;
  695. unsigned IOCTL_SOUND_MIXER_WRITE_SYNTH = SOUND_MIXER_WRITE_SYNTH;
  696. unsigned IOCTL_SOUND_MIXER_WRITE_TREBLE = SOUND_MIXER_WRITE_TREBLE;
  697. unsigned IOCTL_SOUND_MIXER_WRITE_VOLUME = SOUND_MIXER_WRITE_VOLUME;
  698. unsigned IOCTL_VT_ACTIVATE = VT_ACTIVATE;
  699. unsigned IOCTL_VT_GETMODE = VT_GETMODE;
  700. unsigned IOCTL_VT_OPENQRY = VT_OPENQRY;
  701. unsigned IOCTL_VT_RELDISP = VT_RELDISP;
  702. unsigned IOCTL_VT_SETMODE = VT_SETMODE;
  703. unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE;
  704. #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
  705. #if SANITIZER_LINUX && !SANITIZER_ANDROID
  706. unsigned IOCTL_CYGETDEFTHRESH = CYGETDEFTHRESH;
  707. unsigned IOCTL_CYGETDEFTIMEOUT = CYGETDEFTIMEOUT;
  708. unsigned IOCTL_CYGETMON = CYGETMON;
  709. unsigned IOCTL_CYGETTHRESH = CYGETTHRESH;
  710. unsigned IOCTL_CYGETTIMEOUT = CYGETTIMEOUT;
  711. unsigned IOCTL_CYSETDEFTHRESH = CYSETDEFTHRESH;
  712. unsigned IOCTL_CYSETDEFTIMEOUT = CYSETDEFTIMEOUT;
  713. unsigned IOCTL_CYSETTHRESH = CYSETTHRESH;
  714. unsigned IOCTL_CYSETTIMEOUT = CYSETTIMEOUT;
  715. unsigned IOCTL_EQL_EMANCIPATE = EQL_EMANCIPATE;
  716. unsigned IOCTL_EQL_ENSLAVE = EQL_ENSLAVE;
  717. unsigned IOCTL_EQL_GETMASTRCFG = EQL_GETMASTRCFG;
  718. unsigned IOCTL_EQL_GETSLAVECFG = EQL_GETSLAVECFG;
  719. unsigned IOCTL_EQL_SETMASTRCFG = EQL_SETMASTRCFG;
  720. unsigned IOCTL_EQL_SETSLAVECFG = EQL_SETSLAVECFG;
  721. #if EV_VERSION > (0x010000)
  722. unsigned IOCTL_EVIOCGKEYCODE_V2 = EVIOCGKEYCODE_V2;
  723. unsigned IOCTL_EVIOCGPROP = EVIOCGPROP(0);
  724. unsigned IOCTL_EVIOCSKEYCODE_V2 = EVIOCSKEYCODE_V2;
  725. #else
  726. unsigned IOCTL_EVIOCGKEYCODE_V2 = IOCTL_NOT_PRESENT;
  727. unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT;
  728. unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT;
  729. #endif
  730. unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS;
  731. unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION;
  732. unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS;
  733. unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION;
  734. unsigned IOCTL_GIO_CMAP = GIO_CMAP;
  735. unsigned IOCTL_GIO_FONT = GIO_FONT;
  736. unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP;
  737. unsigned IOCTL_GIO_UNISCRNMAP = GIO_UNISCRNMAP;
  738. unsigned IOCTL_KDADDIO = KDADDIO;
  739. unsigned IOCTL_KDDELIO = KDDELIO;
  740. unsigned IOCTL_KDGETKEYCODE = KDGETKEYCODE;
  741. unsigned IOCTL_KDGKBDIACR = KDGKBDIACR;
  742. unsigned IOCTL_KDGKBENT = KDGKBENT;
  743. unsigned IOCTL_KDGKBLED = KDGKBLED;
  744. unsigned IOCTL_KDGKBMETA = KDGKBMETA;
  745. unsigned IOCTL_KDGKBSENT = KDGKBSENT;
  746. unsigned IOCTL_KDMAPDISP = KDMAPDISP;
  747. unsigned IOCTL_KDSETKEYCODE = KDSETKEYCODE;
  748. unsigned IOCTL_KDSIGACCEPT = KDSIGACCEPT;
  749. unsigned IOCTL_KDSKBDIACR = KDSKBDIACR;
  750. unsigned IOCTL_KDSKBENT = KDSKBENT;
  751. unsigned IOCTL_KDSKBLED = KDSKBLED;
  752. unsigned IOCTL_KDSKBMETA = KDSKBMETA;
  753. unsigned IOCTL_KDSKBSENT = KDSKBSENT;
  754. unsigned IOCTL_KDUNMAPDISP = KDUNMAPDISP;
  755. unsigned IOCTL_LPABORT = LPABORT;
  756. unsigned IOCTL_LPABORTOPEN = LPABORTOPEN;
  757. unsigned IOCTL_LPCAREFUL = LPCAREFUL;
  758. unsigned IOCTL_LPCHAR = LPCHAR;
  759. unsigned IOCTL_LPGETIRQ = LPGETIRQ;
  760. unsigned IOCTL_LPGETSTATUS = LPGETSTATUS;
  761. unsigned IOCTL_LPRESET = LPRESET;
  762. unsigned IOCTL_LPSETIRQ = LPSETIRQ;
  763. unsigned IOCTL_LPTIME = LPTIME;
  764. unsigned IOCTL_LPWAIT = LPWAIT;
  765. unsigned IOCTL_MTIOCGETCONFIG = MTIOCGETCONFIG;
  766. unsigned IOCTL_MTIOCSETCONFIG = MTIOCSETCONFIG;
  767. unsigned IOCTL_PIO_CMAP = PIO_CMAP;
  768. unsigned IOCTL_PIO_FONT = PIO_FONT;
  769. unsigned IOCTL_PIO_UNIMAP = PIO_UNIMAP;
  770. unsigned IOCTL_PIO_UNIMAPCLR = PIO_UNIMAPCLR;
  771. unsigned IOCTL_PIO_UNISCRNMAP = PIO_UNISCRNMAP;
  772. unsigned IOCTL_SCSI_IOCTL_GET_IDLUN = SCSI_IOCTL_GET_IDLUN;
  773. unsigned IOCTL_SCSI_IOCTL_PROBE_HOST = SCSI_IOCTL_PROBE_HOST;
  774. unsigned IOCTL_SCSI_IOCTL_TAGGED_DISABLE = SCSI_IOCTL_TAGGED_DISABLE;
  775. unsigned IOCTL_SCSI_IOCTL_TAGGED_ENABLE = SCSI_IOCTL_TAGGED_ENABLE;
  776. unsigned IOCTL_SIOCAIPXITFCRT = SIOCAIPXITFCRT;
  777. unsigned IOCTL_SIOCAIPXPRISLT = SIOCAIPXPRISLT;
  778. unsigned IOCTL_SIOCAX25ADDUID = SIOCAX25ADDUID;
  779. unsigned IOCTL_SIOCAX25DELUID = SIOCAX25DELUID;
  780. unsigned IOCTL_SIOCAX25GETPARMS = SIOCAX25GETPARMS;
  781. unsigned IOCTL_SIOCAX25GETUID = SIOCAX25GETUID;
  782. unsigned IOCTL_SIOCAX25NOUID = SIOCAX25NOUID;
  783. unsigned IOCTL_SIOCAX25SETPARMS = SIOCAX25SETPARMS;
  784. unsigned IOCTL_SIOCDEVPLIP = SIOCDEVPLIP;
  785. unsigned IOCTL_SIOCIPXCFGDATA = SIOCIPXCFGDATA;
  786. unsigned IOCTL_SIOCNRDECOBS = SIOCNRDECOBS;
  787. unsigned IOCTL_SIOCNRGETPARMS = SIOCNRGETPARMS;
  788. unsigned IOCTL_SIOCNRRTCTL = SIOCNRRTCTL;
  789. unsigned IOCTL_SIOCNRSETPARMS = SIOCNRSETPARMS;
  790. unsigned IOCTL_TIOCGSERIAL = TIOCGSERIAL;
  791. unsigned IOCTL_TIOCSERGETMULTI = TIOCSERGETMULTI;
  792. unsigned IOCTL_TIOCSERSETMULTI = TIOCSERSETMULTI;
  793. unsigned IOCTL_TIOCSSERIAL = TIOCSSERIAL;
  794. #endif // SANITIZER_LINUX && !SANITIZER_ANDROID
  795. #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
  796. unsigned IOCTL_GIO_SCRNMAP = GIO_SCRNMAP;
  797. unsigned IOCTL_KDDISABIO = KDDISABIO;
  798. unsigned IOCTL_KDENABIO = KDENABIO;
  799. unsigned IOCTL_KDGETLED = KDGETLED;
  800. unsigned IOCTL_KDGETMODE = KDGETMODE;
  801. unsigned IOCTL_KDGKBMODE = KDGKBMODE;
  802. unsigned IOCTL_KDGKBTYPE = KDGKBTYPE;
  803. unsigned IOCTL_KDMKTONE = KDMKTONE;
  804. unsigned IOCTL_KDSETLED = KDSETLED;
  805. unsigned IOCTL_KDSETMODE = KDSETMODE;
  806. unsigned IOCTL_KDSKBMODE = KDSKBMODE;
  807. unsigned IOCTL_KIOCSOUND = KIOCSOUND;
  808. unsigned IOCTL_PIO_SCRNMAP = PIO_SCRNMAP;
  809. unsigned IOCTL_SNDCTL_DSP_GETISPACE = SNDCTL_DSP_GETISPACE;
  810. unsigned IOCTL_SNDCTL_DSP_GETOSPACE = SNDCTL_DSP_GETOSPACE;
  811. #endif // (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
  812. const int errno_EINVAL = EINVAL;
  813. // EOWNERDEAD is not present in some older platforms.
  814. #if defined(EOWNERDEAD)
  815. const int errno_EOWNERDEAD = EOWNERDEAD;
  816. #else
  817. const int errno_EOWNERDEAD = -1;
  818. #endif
  819. const int si_SEGV_MAPERR = SEGV_MAPERR;
  820. const int si_SEGV_ACCERR = SEGV_ACCERR;
  821. } // namespace __sanitizer
  822. COMPILER_CHECK(sizeof(__sanitizer_pthread_attr_t) >= sizeof(pthread_attr_t));
  823. COMPILER_CHECK(sizeof(socklen_t) == sizeof(unsigned));
  824. CHECK_TYPE_SIZE(pthread_key_t);
  825. #if SANITIZER_LINUX
  826. // FIXME: We define those on Linux and Mac, but only check on Linux.
  827. COMPILER_CHECK(IOC_NRBITS == _IOC_NRBITS);
  828. COMPILER_CHECK(IOC_TYPEBITS == _IOC_TYPEBITS);
  829. COMPILER_CHECK(IOC_SIZEBITS == _IOC_SIZEBITS);
  830. COMPILER_CHECK(IOC_DIRBITS == _IOC_DIRBITS);
  831. COMPILER_CHECK(IOC_NRMASK == _IOC_NRMASK);
  832. COMPILER_CHECK(IOC_TYPEMASK == _IOC_TYPEMASK);
  833. COMPILER_CHECK(IOC_SIZEMASK == _IOC_SIZEMASK);
  834. COMPILER_CHECK(IOC_DIRMASK == _IOC_DIRMASK);
  835. COMPILER_CHECK(IOC_NRSHIFT == _IOC_NRSHIFT);
  836. COMPILER_CHECK(IOC_TYPESHIFT == _IOC_TYPESHIFT);
  837. COMPILER_CHECK(IOC_SIZESHIFT == _IOC_SIZESHIFT);
  838. COMPILER_CHECK(IOC_DIRSHIFT == _IOC_DIRSHIFT);
  839. COMPILER_CHECK(IOC_NONE == _IOC_NONE);
  840. COMPILER_CHECK(IOC_WRITE == _IOC_WRITE);
  841. COMPILER_CHECK(IOC_READ == _IOC_READ);
  842. COMPILER_CHECK(EVIOC_ABS_MAX == ABS_MAX);
  843. COMPILER_CHECK(EVIOC_EV_MAX == EV_MAX);
  844. COMPILER_CHECK(IOC_SIZE(0x12345678) == _IOC_SIZE(0x12345678));
  845. COMPILER_CHECK(IOC_DIR(0x12345678) == _IOC_DIR(0x12345678));
  846. COMPILER_CHECK(IOC_NR(0x12345678) == _IOC_NR(0x12345678));
  847. COMPILER_CHECK(IOC_TYPE(0x12345678) == _IOC_TYPE(0x12345678));
  848. #endif // SANITIZER_LINUX
  849. #if SANITIZER_LINUX || SANITIZER_FREEBSD
  850. // There are more undocumented fields in dl_phdr_info that we are not interested
  851. // in.
  852. COMPILER_CHECK(sizeof(__sanitizer_dl_phdr_info) <= sizeof(dl_phdr_info));
  853. CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_addr);
  854. CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_name);
  855. CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
  856. CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
  857. #endif // SANITIZER_LINUX || SANITIZER_FREEBSD
  858. #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
  859. CHECK_TYPE_SIZE(glob_t);
  860. CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
  861. CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
  862. CHECK_SIZE_AND_OFFSET(glob_t, gl_offs);
  863. CHECK_SIZE_AND_OFFSET(glob_t, gl_flags);
  864. CHECK_SIZE_AND_OFFSET(glob_t, gl_closedir);
  865. CHECK_SIZE_AND_OFFSET(glob_t, gl_readdir);
  866. CHECK_SIZE_AND_OFFSET(glob_t, gl_opendir);
  867. CHECK_SIZE_AND_OFFSET(glob_t, gl_lstat);
  868. CHECK_SIZE_AND_OFFSET(glob_t, gl_stat);
  869. #endif
  870. CHECK_TYPE_SIZE(addrinfo);
  871. CHECK_SIZE_AND_OFFSET(addrinfo, ai_flags);
  872. CHECK_SIZE_AND_OFFSET(addrinfo, ai_family);
  873. CHECK_SIZE_AND_OFFSET(addrinfo, ai_socktype);
  874. CHECK_SIZE_AND_OFFSET(addrinfo, ai_protocol);
  875. CHECK_SIZE_AND_OFFSET(addrinfo, ai_protocol);
  876. CHECK_SIZE_AND_OFFSET(addrinfo, ai_addrlen);
  877. CHECK_SIZE_AND_OFFSET(addrinfo, ai_canonname);
  878. CHECK_SIZE_AND_OFFSET(addrinfo, ai_addr);
  879. CHECK_TYPE_SIZE(hostent);
  880. CHECK_SIZE_AND_OFFSET(hostent, h_name);
  881. CHECK_SIZE_AND_OFFSET(hostent, h_aliases);
  882. CHECK_SIZE_AND_OFFSET(hostent, h_addrtype);
  883. CHECK_SIZE_AND_OFFSET(hostent, h_length);
  884. CHECK_SIZE_AND_OFFSET(hostent, h_addr_list);
  885. CHECK_TYPE_SIZE(iovec);
  886. CHECK_SIZE_AND_OFFSET(iovec, iov_base);
  887. CHECK_SIZE_AND_OFFSET(iovec, iov_len);
  888. CHECK_TYPE_SIZE(msghdr);
  889. CHECK_SIZE_AND_OFFSET(msghdr, msg_name);
  890. CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen);
  891. CHECK_SIZE_AND_OFFSET(msghdr, msg_iov);
  892. CHECK_SIZE_AND_OFFSET(msghdr, msg_iovlen);
  893. CHECK_SIZE_AND_OFFSET(msghdr, msg_control);
  894. CHECK_SIZE_AND_OFFSET(msghdr, msg_controllen);
  895. CHECK_SIZE_AND_OFFSET(msghdr, msg_flags);
  896. CHECK_TYPE_SIZE(cmsghdr);
  897. CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
  898. CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
  899. CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
  900. COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
  901. CHECK_SIZE_AND_OFFSET(dirent, d_ino);
  902. #if SANITIZER_MAC
  903. CHECK_SIZE_AND_OFFSET(dirent, d_seekoff);
  904. #elif SANITIZER_FREEBSD
  905. // There is no 'd_off' field on FreeBSD.
  906. #else
  907. CHECK_SIZE_AND_OFFSET(dirent, d_off);
  908. #endif
  909. CHECK_SIZE_AND_OFFSET(dirent, d_reclen);
  910. #if SANITIZER_LINUX && !SANITIZER_ANDROID
  911. COMPILER_CHECK(sizeof(__sanitizer_dirent64) <= sizeof(dirent64));
  912. CHECK_SIZE_AND_OFFSET(dirent64, d_ino);
  913. CHECK_SIZE_AND_OFFSET(dirent64, d_off);
  914. CHECK_SIZE_AND_OFFSET(dirent64, d_reclen);
  915. #endif
  916. CHECK_TYPE_SIZE(ifconf);
  917. CHECK_SIZE_AND_OFFSET(ifconf, ifc_len);
  918. CHECK_SIZE_AND_OFFSET(ifconf, ifc_ifcu);
  919. CHECK_TYPE_SIZE(pollfd);
  920. CHECK_SIZE_AND_OFFSET(pollfd, fd);
  921. CHECK_SIZE_AND_OFFSET(pollfd, events);
  922. CHECK_SIZE_AND_OFFSET(pollfd, revents);
  923. CHECK_TYPE_SIZE(nfds_t);
  924. CHECK_TYPE_SIZE(sigset_t);
  925. COMPILER_CHECK(sizeof(__sanitizer_sigaction) == sizeof(struct sigaction));
  926. // Can't write checks for sa_handler and sa_sigaction due to them being
  927. // preprocessor macros.
  928. CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
  929. CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_flags);
  930. #if SANITIZER_LINUX
  931. CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_restorer);
  932. #endif
  933. #if SANITIZER_LINUX
  934. CHECK_TYPE_SIZE(__sysctl_args);
  935. CHECK_SIZE_AND_OFFSET(__sysctl_args, name);
  936. CHECK_SIZE_AND_OFFSET(__sysctl_args, nlen);
  937. CHECK_SIZE_AND_OFFSET(__sysctl_args, oldval);
  938. CHECK_SIZE_AND_OFFSET(__sysctl_args, oldlenp);
  939. CHECK_SIZE_AND_OFFSET(__sysctl_args, newval);
  940. CHECK_SIZE_AND_OFFSET(__sysctl_args, newlen);
  941. CHECK_TYPE_SIZE(__kernel_uid_t);
  942. CHECK_TYPE_SIZE(__kernel_gid_t);
  943. #if SANITIZER_USES_UID16_SYSCALLS
  944. CHECK_TYPE_SIZE(__kernel_old_uid_t);
  945. CHECK_TYPE_SIZE(__kernel_old_gid_t);
  946. #endif
  947. CHECK_TYPE_SIZE(__kernel_off_t);
  948. CHECK_TYPE_SIZE(__kernel_loff_t);
  949. CHECK_TYPE_SIZE(__kernel_fd_set);
  950. #endif
  951. #if !SANITIZER_ANDROID
  952. CHECK_TYPE_SIZE(wordexp_t);
  953. CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordc);
  954. CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordv);
  955. CHECK_SIZE_AND_OFFSET(wordexp_t, we_offs);
  956. #endif
  957. CHECK_TYPE_SIZE(tm);
  958. CHECK_SIZE_AND_OFFSET(tm, tm_sec);
  959. CHECK_SIZE_AND_OFFSET(tm, tm_min);
  960. CHECK_SIZE_AND_OFFSET(tm, tm_hour);
  961. CHECK_SIZE_AND_OFFSET(tm, tm_mday);
  962. CHECK_SIZE_AND_OFFSET(tm, tm_mon);
  963. CHECK_SIZE_AND_OFFSET(tm, tm_year);
  964. CHECK_SIZE_AND_OFFSET(tm, tm_wday);
  965. CHECK_SIZE_AND_OFFSET(tm, tm_yday);
  966. CHECK_SIZE_AND_OFFSET(tm, tm_isdst);
  967. CHECK_SIZE_AND_OFFSET(tm, tm_gmtoff);
  968. CHECK_SIZE_AND_OFFSET(tm, tm_zone);
  969. #if SANITIZER_LINUX
  970. CHECK_TYPE_SIZE(mntent);
  971. CHECK_SIZE_AND_OFFSET(mntent, mnt_fsname);
  972. CHECK_SIZE_AND_OFFSET(mntent, mnt_dir);
  973. CHECK_SIZE_AND_OFFSET(mntent, mnt_type);
  974. CHECK_SIZE_AND_OFFSET(mntent, mnt_opts);
  975. CHECK_SIZE_AND_OFFSET(mntent, mnt_freq);
  976. CHECK_SIZE_AND_OFFSET(mntent, mnt_passno);
  977. #endif
  978. CHECK_TYPE_SIZE(ether_addr);
  979. #if (SANITIZER_LINUX || SANITIZER_FREEBSD) && !SANITIZER_ANDROID
  980. CHECK_TYPE_SIZE(ipc_perm);
  981. # if SANITIZER_FREEBSD
  982. CHECK_SIZE_AND_OFFSET(ipc_perm, key);
  983. CHECK_SIZE_AND_OFFSET(ipc_perm, seq);
  984. # else
  985. CHECK_SIZE_AND_OFFSET(ipc_perm, __key);
  986. CHECK_SIZE_AND_OFFSET(ipc_perm, __seq);
  987. # endif
  988. CHECK_SIZE_AND_OFFSET(ipc_perm, uid);
  989. CHECK_SIZE_AND_OFFSET(ipc_perm, gid);
  990. CHECK_SIZE_AND_OFFSET(ipc_perm, cuid);
  991. CHECK_SIZE_AND_OFFSET(ipc_perm, cgid);
  992. #ifndef __GLIBC_PREREQ
  993. #define __GLIBC_PREREQ(x, y) 0
  994. #endif
  995. #if !defined(__aarch64__) || !SANITIZER_LINUX || __GLIBC_PREREQ (2, 21)
  996. /* On aarch64 glibc 2.20 and earlier provided incorrect mode field. */
  997. CHECK_SIZE_AND_OFFSET(ipc_perm, mode);
  998. #endif
  999. CHECK_TYPE_SIZE(shmid_ds);
  1000. CHECK_SIZE_AND_OFFSET(shmid_ds, shm_perm);
  1001. CHECK_SIZE_AND_OFFSET(shmid_ds, shm_segsz);
  1002. CHECK_SIZE_AND_OFFSET(shmid_ds, shm_atime);
  1003. CHECK_SIZE_AND_OFFSET(shmid_ds, shm_dtime);
  1004. CHECK_SIZE_AND_OFFSET(shmid_ds, shm_ctime);
  1005. CHECK_SIZE_AND_OFFSET(shmid_ds, shm_cpid);
  1006. CHECK_SIZE_AND_OFFSET(shmid_ds, shm_lpid);
  1007. CHECK_SIZE_AND_OFFSET(shmid_ds, shm_nattch);
  1008. #endif
  1009. CHECK_TYPE_SIZE(clock_t);
  1010. #if SANITIZER_LINUX
  1011. CHECK_TYPE_SIZE(clockid_t);
  1012. #endif
  1013. #if !SANITIZER_ANDROID
  1014. CHECK_TYPE_SIZE(ifaddrs);
  1015. CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_next);
  1016. CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_name);
  1017. CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_addr);
  1018. CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_netmask);
  1019. #if SANITIZER_LINUX || SANITIZER_FREEBSD
  1020. // Compare against the union, because we can't reach into the union in a
  1021. // compliant way.
  1022. #ifdef ifa_dstaddr
  1023. #undef ifa_dstaddr
  1024. #endif
  1025. # if SANITIZER_FREEBSD
  1026. CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
  1027. # else
  1028. COMPILER_CHECK(sizeof(((__sanitizer_ifaddrs *)NULL)->ifa_dstaddr) ==
  1029. sizeof(((ifaddrs *)NULL)->ifa_ifu));
  1030. COMPILER_CHECK(offsetof(__sanitizer_ifaddrs, ifa_dstaddr) ==
  1031. offsetof(ifaddrs, ifa_ifu));
  1032. # endif // SANITIZER_FREEBSD
  1033. #else
  1034. CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
  1035. #endif // SANITIZER_LINUX
  1036. CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data);
  1037. #endif
  1038. #if SANITIZER_LINUX
  1039. COMPILER_CHECK(sizeof(__sanitizer_mallinfo) == sizeof(struct mallinfo));
  1040. #endif
  1041. #if !SANITIZER_ANDROID
  1042. CHECK_TYPE_SIZE(timeb);
  1043. CHECK_SIZE_AND_OFFSET(timeb, time);
  1044. CHECK_SIZE_AND_OFFSET(timeb, millitm);
  1045. CHECK_SIZE_AND_OFFSET(timeb, timezone);
  1046. CHECK_SIZE_AND_OFFSET(timeb, dstflag);
  1047. #endif
  1048. CHECK_TYPE_SIZE(passwd);
  1049. CHECK_SIZE_AND_OFFSET(passwd, pw_name);
  1050. CHECK_SIZE_AND_OFFSET(passwd, pw_passwd);
  1051. CHECK_SIZE_AND_OFFSET(passwd, pw_uid);
  1052. CHECK_SIZE_AND_OFFSET(passwd, pw_gid);
  1053. CHECK_SIZE_AND_OFFSET(passwd, pw_dir);
  1054. CHECK_SIZE_AND_OFFSET(passwd, pw_shell);
  1055. #if !SANITIZER_ANDROID
  1056. CHECK_SIZE_AND_OFFSET(passwd, pw_gecos);
  1057. #endif
  1058. #if SANITIZER_MAC
  1059. CHECK_SIZE_AND_OFFSET(passwd, pw_change);
  1060. CHECK_SIZE_AND_OFFSET(passwd, pw_expire);
  1061. CHECK_SIZE_AND_OFFSET(passwd, pw_class);
  1062. #endif
  1063. CHECK_TYPE_SIZE(group);
  1064. CHECK_SIZE_AND_OFFSET(group, gr_name);
  1065. CHECK_SIZE_AND_OFFSET(group, gr_passwd);
  1066. CHECK_SIZE_AND_OFFSET(group, gr_gid);
  1067. CHECK_SIZE_AND_OFFSET(group, gr_mem);
  1068. #if HAVE_RPC_XDR_H || HAVE_TIRPC_RPC_XDR_H
  1069. CHECK_TYPE_SIZE(XDR);
  1070. CHECK_SIZE_AND_OFFSET(XDR, x_op);
  1071. CHECK_SIZE_AND_OFFSET(XDR, x_ops);
  1072. CHECK_SIZE_AND_OFFSET(XDR, x_public);
  1073. CHECK_SIZE_AND_OFFSET(XDR, x_private);
  1074. CHECK_SIZE_AND_OFFSET(XDR, x_base);
  1075. CHECK_SIZE_AND_OFFSET(XDR, x_handy);
  1076. COMPILER_CHECK(__sanitizer_XDR_ENCODE == XDR_ENCODE);
  1077. COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE);
  1078. COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE);
  1079. #endif
  1080. #if SANITIZER_LINUX && !SANITIZER_ANDROID
  1081. COMPILER_CHECK(sizeof(__sanitizer_FILE) <= sizeof(FILE));
  1082. CHECK_SIZE_AND_OFFSET(FILE, _flags);
  1083. CHECK_SIZE_AND_OFFSET(FILE, _IO_read_ptr);
  1084. CHECK_SIZE_AND_OFFSET(FILE, _IO_read_end);
  1085. CHECK_SIZE_AND_OFFSET(FILE, _IO_read_base);
  1086. CHECK_SIZE_AND_OFFSET(FILE, _IO_write_ptr);
  1087. CHECK_SIZE_AND_OFFSET(FILE, _IO_write_end);
  1088. CHECK_SIZE_AND_OFFSET(FILE, _IO_write_base);
  1089. CHECK_SIZE_AND_OFFSET(FILE, _IO_buf_base);
  1090. CHECK_SIZE_AND_OFFSET(FILE, _IO_buf_end);
  1091. CHECK_SIZE_AND_OFFSET(FILE, _IO_save_base);
  1092. CHECK_SIZE_AND_OFFSET(FILE, _IO_backup_base);
  1093. CHECK_SIZE_AND_OFFSET(FILE, _IO_save_end);
  1094. CHECK_SIZE_AND_OFFSET(FILE, _markers);
  1095. CHECK_SIZE_AND_OFFSET(FILE, _chain);
  1096. CHECK_SIZE_AND_OFFSET(FILE, _fileno);
  1097. #endif
  1098. #if SANITIZER_LINUX && !SANITIZER_ANDROID
  1099. COMPILER_CHECK(sizeof(__sanitizer__obstack_chunk) <= sizeof(_obstack_chunk));
  1100. CHECK_SIZE_AND_OFFSET(_obstack_chunk, limit);
  1101. CHECK_SIZE_AND_OFFSET(_obstack_chunk, prev);
  1102. CHECK_TYPE_SIZE(obstack);
  1103. CHECK_SIZE_AND_OFFSET(obstack, chunk_size);
  1104. CHECK_SIZE_AND_OFFSET(obstack, chunk);
  1105. CHECK_SIZE_AND_OFFSET(obstack, object_base);
  1106. CHECK_SIZE_AND_OFFSET(obstack, next_free);
  1107. #endif
  1108. #endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_MAC