sanitizer_platform_limits_posix.h 40 KB

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