[testsuite] require pic for pr103074.c
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_platform_limits_freebsd.cpp
blob37e72cd5d45eac92f72c6784ee3518e4ab3e3d99
1 //===-- sanitizer_platform_limits_freebsd.cpp -----------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file is a part of Sanitizer common code.
11 // Sizes and layouts of platform-specific FreeBSD data structures.
12 //===----------------------------------------------------------------------===//
14 #include "sanitizer_platform.h"
16 #if SANITIZER_FREEBSD
18 #include <sys/capsicum.h>
19 #include <sys/consio.h>
20 #include <sys/filio.h>
21 #include <sys/ipc.h>
22 #include <sys/kbio.h>
23 #include <sys/link_elf.h>
24 #include <sys/mman.h>
25 #include <sys/mount.h>
26 #include <sys/mqueue.h>
27 #include <sys/msg.h>
28 #include <sys/mtio.h>
29 #include <sys/ptrace.h>
30 #include <sys/resource.h>
31 #include <sys/signal.h>
32 #include <sys/socket.h>
33 #include <sys/sockio.h>
34 #include <sys/soundcard.h>
35 #include <sys/stat.h>
36 #include <sys/statvfs.h>
37 #include <sys/time.h>
38 #pragma clang diagnostic push
39 #pragma clang diagnostic ignored "-W#warnings"
40 #include <sys/timeb.h>
41 #pragma clang diagnostic pop
42 #include <sys/times.h>
43 #include <sys/timespec.h>
44 #include <sys/types.h>
45 #include <sys/ucontext.h>
46 #include <sys/utsname.h>
48 #include <arpa/inet.h>
49 #include <net/ethernet.h>
50 #include <net/if.h>
51 #include <net/ppp_defs.h>
52 #include <net/route.h>
53 #include <netdb.h>
54 #include <netinet/in.h>
55 #include <netinet/ip_mroute.h>
57 #include <dirent.h>
58 #include <dlfcn.h>
59 #include <fstab.h>
60 #include <fts.h>
61 #include <glob.h>
62 #include <grp.h>
63 #include <ifaddrs.h>
64 #include <limits.h>
65 #include <poll.h>
66 #include <pthread.h>
67 #include <pwd.h>
68 #include <regex.h>
69 #include <semaphore.h>
70 #include <signal.h>
71 #include <stddef.h>
72 #include <md5.h>
73 #include <sha224.h>
74 #include <sha256.h>
75 #include <sha384.h>
76 #include <sha512.h>
77 #include <stdio.h>
78 #include <stringlist.h>
79 #include <term.h>
80 #include <termios.h>
81 #include <time.h>
82 #include <ttyent.h>
83 #include <utime.h>
84 #include <utmpx.h>
85 #include <vis.h>
86 #include <wchar.h>
87 #include <wordexp.h>
89 #define _KERNEL // to declare 'shminfo' structure
90 #include <sys/shm.h>
91 #undef _KERNEL
93 #undef IOC_DIRMASK
95 // Include these after system headers to avoid name clashes and ambiguities.
96 #include "sanitizer_internal_defs.h"
97 #include "sanitizer_libc.h"
98 #include "sanitizer_platform_limits_freebsd.h"
100 namespace __sanitizer {
101 void *__sanitizer_get_link_map_by_dlopen_handle(void *handle) {
102 void *p = nullptr;
103 return internal_dlinfo(handle, RTLD_DI_LINKMAP, &p) == 0 ? p : nullptr;
106 unsigned struct_cap_rights_sz = sizeof(cap_rights_t);
107 unsigned struct_utsname_sz = sizeof(struct utsname);
108 unsigned struct_stat_sz = sizeof(struct stat);
109 unsigned struct_rusage_sz = sizeof(struct rusage);
110 unsigned struct_tm_sz = sizeof(struct tm);
111 unsigned struct_passwd_sz = sizeof(struct passwd);
112 unsigned struct_group_sz = sizeof(struct group);
113 unsigned siginfo_t_sz = sizeof(siginfo_t);
114 unsigned struct_sigaction_sz = sizeof(struct sigaction);
115 unsigned struct_stack_t_sz = sizeof(stack_t);
116 unsigned struct_itimerval_sz = sizeof(struct itimerval);
117 unsigned pthread_t_sz = sizeof(pthread_t);
118 unsigned pthread_mutex_t_sz = sizeof(pthread_mutex_t);
119 unsigned pthread_cond_t_sz = sizeof(pthread_cond_t);
120 unsigned pid_t_sz = sizeof(pid_t);
121 unsigned timeval_sz = sizeof(timeval);
122 unsigned uid_t_sz = sizeof(uid_t);
123 unsigned gid_t_sz = sizeof(gid_t);
124 unsigned fpos_t_sz = sizeof(fpos_t);
125 unsigned mbstate_t_sz = sizeof(mbstate_t);
126 unsigned sigset_t_sz = sizeof(sigset_t);
127 unsigned struct_timezone_sz = sizeof(struct timezone);
128 unsigned struct_tms_sz = sizeof(struct tms);
129 unsigned struct_sigevent_sz = sizeof(struct sigevent);
130 unsigned struct_sched_param_sz = sizeof(struct sched_param);
131 unsigned struct_statfs_sz = sizeof(struct statfs);
132 unsigned struct_sockaddr_sz = sizeof(struct sockaddr);
133 unsigned ucontext_t_sz(void *ctx) { return sizeof(ucontext_t); }
134 unsigned struct_rlimit_sz = sizeof(struct rlimit);
135 unsigned struct_timespec_sz = sizeof(struct timespec);
136 unsigned struct_utimbuf_sz = sizeof(struct utimbuf);
137 unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
138 unsigned struct_timeb_sz = sizeof(struct timeb);
139 unsigned struct_msqid_ds_sz = sizeof(struct msqid_ds);
140 unsigned struct_mq_attr_sz = sizeof(struct mq_attr);
141 unsigned struct_statvfs_sz = sizeof(struct statvfs);
142 unsigned struct_shminfo_sz = sizeof(struct shminfo);
143 unsigned struct_shm_info_sz = sizeof(struct shm_info);
144 unsigned struct_regmatch_sz = sizeof(regmatch_t);
145 unsigned struct_regex_sz = sizeof(regex_t);
146 unsigned struct_fstab_sz = sizeof(struct fstab);
147 unsigned struct_FTS_sz = sizeof(FTS);
148 unsigned struct_FTSENT_sz = sizeof(FTSENT);
149 unsigned struct_StringList_sz = sizeof(StringList);
151 const uptr sig_ign = (uptr)SIG_IGN;
152 const uptr sig_dfl = (uptr)SIG_DFL;
153 const uptr sig_err = (uptr)SIG_ERR;
154 const uptr sa_siginfo = (uptr)SA_SIGINFO;
156 int shmctl_ipc_stat = (int)IPC_STAT;
157 int shmctl_ipc_info = (int)IPC_INFO;
158 int shmctl_shm_info = (int)SHM_INFO;
159 int shmctl_shm_stat = (int)SHM_STAT;
160 unsigned struct_utmpx_sz = sizeof(struct utmpx);
162 int map_fixed = MAP_FIXED;
164 int af_inet = (int)AF_INET;
165 int af_inet6 = (int)AF_INET6;
167 uptr __sanitizer_in_addr_sz(int af) {
168 if (af == AF_INET)
169 return sizeof(struct in_addr);
170 else if (af == AF_INET6)
171 return sizeof(struct in6_addr);
172 else
173 return 0;
176 unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
177 int glob_nomatch = GLOB_NOMATCH;
178 int glob_altdirfunc = GLOB_ALTDIRFUNC;
179 const int wordexp_wrde_dooffs = WRDE_DOOFFS;
181 unsigned path_max = PATH_MAX;
183 int struct_ttyent_sz = sizeof(struct ttyent);
185 // ioctl arguments
186 unsigned struct_ifreq_sz = sizeof(struct ifreq);
187 unsigned struct_termios_sz = sizeof(struct termios);
188 unsigned struct_winsize_sz = sizeof(struct winsize);
189 #if SOUND_VERSION >= 0x040000
190 unsigned struct_copr_buffer_sz = 0;
191 unsigned struct_copr_debug_buf_sz = 0;
192 unsigned struct_copr_msg_sz = 0;
193 #else
194 unsigned struct_copr_buffer_sz = sizeof(struct copr_buffer);
195 unsigned struct_copr_debug_buf_sz = sizeof(struct copr_debug_buf);
196 unsigned struct_copr_msg_sz = sizeof(struct copr_msg);
197 #endif
198 unsigned struct_midi_info_sz = sizeof(struct midi_info);
199 unsigned struct_mtget_sz = sizeof(struct mtget);
200 unsigned struct_mtop_sz = sizeof(struct mtop);
201 unsigned struct_sbi_instrument_sz = sizeof(struct sbi_instrument);
202 unsigned struct_seq_event_rec_sz = sizeof(struct seq_event_rec);
203 unsigned struct_synth_info_sz = sizeof(struct synth_info);
204 unsigned struct_audio_buf_info_sz = sizeof(struct audio_buf_info);
205 unsigned struct_ppp_stats_sz = sizeof(struct ppp_stats);
206 unsigned struct_sioc_sg_req_sz = sizeof(struct sioc_sg_req);
207 unsigned struct_sioc_vif_req_sz = sizeof(struct sioc_vif_req);
208 unsigned struct_procctl_reaper_status_sz = sizeof(struct __sanitizer_procctl_reaper_status);
209 unsigned struct_procctl_reaper_pidinfo_sz = sizeof(struct __sanitizer_procctl_reaper_pidinfo);
210 unsigned struct_procctl_reaper_pids_sz = sizeof(struct __sanitizer_procctl_reaper_pids);
211 unsigned struct_procctl_reaper_kill_sz = sizeof(struct __sanitizer_procctl_reaper_kill);
212 const unsigned long __sanitizer_bufsiz = BUFSIZ;
214 const unsigned IOCTL_NOT_PRESENT = 0;
216 unsigned IOCTL_FIOASYNC = FIOASYNC;
217 unsigned IOCTL_FIOCLEX = FIOCLEX;
218 unsigned IOCTL_FIOGETOWN = FIOGETOWN;
219 unsigned IOCTL_FIONBIO = FIONBIO;
220 unsigned IOCTL_FIONCLEX = FIONCLEX;
221 unsigned IOCTL_FIOSETOWN = FIOSETOWN;
222 unsigned IOCTL_SIOCADDMULTI = SIOCADDMULTI;
223 unsigned IOCTL_SIOCATMARK = SIOCATMARK;
224 unsigned IOCTL_SIOCDELMULTI = SIOCDELMULTI;
225 unsigned IOCTL_SIOCGIFADDR = SIOCGIFADDR;
226 unsigned IOCTL_SIOCGIFBRDADDR = SIOCGIFBRDADDR;
227 unsigned IOCTL_SIOCGIFCONF = SIOCGIFCONF;
228 unsigned IOCTL_SIOCGIFDSTADDR = SIOCGIFDSTADDR;
229 unsigned IOCTL_SIOCGIFFLAGS = SIOCGIFFLAGS;
230 unsigned IOCTL_SIOCGIFMETRIC = SIOCGIFMETRIC;
231 unsigned IOCTL_SIOCGIFMTU = SIOCGIFMTU;
232 unsigned IOCTL_SIOCGIFNETMASK = SIOCGIFNETMASK;
233 unsigned IOCTL_SIOCGPGRP = SIOCGPGRP;
234 unsigned IOCTL_SIOCSIFADDR = SIOCSIFADDR;
235 unsigned IOCTL_SIOCSIFBRDADDR = SIOCSIFBRDADDR;
236 unsigned IOCTL_SIOCSIFDSTADDR = SIOCSIFDSTADDR;
237 unsigned IOCTL_SIOCSIFFLAGS = SIOCSIFFLAGS;
238 unsigned IOCTL_SIOCSIFMETRIC = SIOCSIFMETRIC;
239 unsigned IOCTL_SIOCSIFMTU = SIOCSIFMTU;
240 unsigned IOCTL_SIOCSIFNETMASK = SIOCSIFNETMASK;
241 unsigned IOCTL_SIOCSPGRP = SIOCSPGRP;
242 unsigned IOCTL_TIOCCONS = TIOCCONS;
243 unsigned IOCTL_TIOCEXCL = TIOCEXCL;
244 unsigned IOCTL_TIOCGETD = TIOCGETD;
245 unsigned IOCTL_TIOCGPGRP = TIOCGPGRP;
246 unsigned IOCTL_TIOCGWINSZ = TIOCGWINSZ;
247 unsigned IOCTL_TIOCMBIC = TIOCMBIC;
248 unsigned IOCTL_TIOCMBIS = TIOCMBIS;
249 unsigned IOCTL_TIOCMGET = TIOCMGET;
250 unsigned IOCTL_TIOCMSET = TIOCMSET;
251 unsigned IOCTL_TIOCNOTTY = TIOCNOTTY;
252 unsigned IOCTL_TIOCNXCL = TIOCNXCL;
253 unsigned IOCTL_TIOCOUTQ = TIOCOUTQ;
254 unsigned IOCTL_TIOCPKT = TIOCPKT;
255 unsigned IOCTL_TIOCSCTTY = TIOCSCTTY;
256 unsigned IOCTL_TIOCSETD = TIOCSETD;
257 unsigned IOCTL_TIOCSPGRP = TIOCSPGRP;
258 unsigned IOCTL_TIOCSTI = TIOCSTI;
259 unsigned IOCTL_TIOCSWINSZ = TIOCSWINSZ;
260 unsigned IOCTL_SIOCGETSGCNT = SIOCGETSGCNT;
261 unsigned IOCTL_SIOCGETVIFCNT = SIOCGETVIFCNT;
262 unsigned IOCTL_MTIOCGET = MTIOCGET;
263 unsigned IOCTL_MTIOCTOP = MTIOCTOP;
264 unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE = SNDCTL_DSP_GETBLKSIZE;
265 unsigned IOCTL_SNDCTL_DSP_GETFMTS = SNDCTL_DSP_GETFMTS;
266 unsigned IOCTL_SNDCTL_DSP_NONBLOCK = SNDCTL_DSP_NONBLOCK;
267 unsigned IOCTL_SNDCTL_DSP_POST = SNDCTL_DSP_POST;
268 unsigned IOCTL_SNDCTL_DSP_RESET = SNDCTL_DSP_RESET;
269 unsigned IOCTL_SNDCTL_DSP_SETFMT = SNDCTL_DSP_SETFMT;
270 unsigned IOCTL_SNDCTL_DSP_SETFRAGMENT = SNDCTL_DSP_SETFRAGMENT;
271 unsigned IOCTL_SNDCTL_DSP_SPEED = SNDCTL_DSP_SPEED;
272 unsigned IOCTL_SNDCTL_DSP_STEREO = SNDCTL_DSP_STEREO;
273 unsigned IOCTL_SNDCTL_DSP_SUBDIVIDE = SNDCTL_DSP_SUBDIVIDE;
274 unsigned IOCTL_SNDCTL_DSP_SYNC = SNDCTL_DSP_SYNC;
275 unsigned IOCTL_SNDCTL_FM_4OP_ENABLE = SNDCTL_FM_4OP_ENABLE;
276 unsigned IOCTL_SNDCTL_FM_LOAD_INSTR = SNDCTL_FM_LOAD_INSTR;
277 unsigned IOCTL_SNDCTL_MIDI_INFO = SNDCTL_MIDI_INFO;
278 unsigned IOCTL_SNDCTL_MIDI_PRETIME = SNDCTL_MIDI_PRETIME;
279 unsigned IOCTL_SNDCTL_SEQ_CTRLRATE = SNDCTL_SEQ_CTRLRATE;
280 unsigned IOCTL_SNDCTL_SEQ_GETINCOUNT = SNDCTL_SEQ_GETINCOUNT;
281 unsigned IOCTL_SNDCTL_SEQ_GETOUTCOUNT = SNDCTL_SEQ_GETOUTCOUNT;
282 unsigned IOCTL_SNDCTL_SEQ_NRMIDIS = SNDCTL_SEQ_NRMIDIS;
283 unsigned IOCTL_SNDCTL_SEQ_NRSYNTHS = SNDCTL_SEQ_NRSYNTHS;
284 unsigned IOCTL_SNDCTL_SEQ_OUTOFBAND = SNDCTL_SEQ_OUTOFBAND;
285 unsigned IOCTL_SNDCTL_SEQ_PANIC = SNDCTL_SEQ_PANIC;
286 unsigned IOCTL_SNDCTL_SEQ_PERCMODE = SNDCTL_SEQ_PERCMODE;
287 unsigned IOCTL_SNDCTL_SEQ_RESET = SNDCTL_SEQ_RESET;
288 unsigned IOCTL_SNDCTL_SEQ_RESETSAMPLES = SNDCTL_SEQ_RESETSAMPLES;
289 unsigned IOCTL_SNDCTL_SEQ_SYNC = SNDCTL_SEQ_SYNC;
290 unsigned IOCTL_SNDCTL_SEQ_TESTMIDI = SNDCTL_SEQ_TESTMIDI;
291 unsigned IOCTL_SNDCTL_SEQ_THRESHOLD = SNDCTL_SEQ_THRESHOLD;
292 unsigned IOCTL_SNDCTL_SYNTH_INFO = SNDCTL_SYNTH_INFO;
293 unsigned IOCTL_SNDCTL_SYNTH_MEMAVL = SNDCTL_SYNTH_MEMAVL;
294 unsigned IOCTL_SNDCTL_TMR_CONTINUE = SNDCTL_TMR_CONTINUE;
295 unsigned IOCTL_SNDCTL_TMR_METRONOME = SNDCTL_TMR_METRONOME;
296 unsigned IOCTL_SNDCTL_TMR_SELECT = SNDCTL_TMR_SELECT;
297 unsigned IOCTL_SNDCTL_TMR_SOURCE = SNDCTL_TMR_SOURCE;
298 unsigned IOCTL_SNDCTL_TMR_START = SNDCTL_TMR_START;
299 unsigned IOCTL_SNDCTL_TMR_STOP = SNDCTL_TMR_STOP;
300 unsigned IOCTL_SNDCTL_TMR_TEMPO = SNDCTL_TMR_TEMPO;
301 unsigned IOCTL_SNDCTL_TMR_TIMEBASE = SNDCTL_TMR_TIMEBASE;
302 unsigned IOCTL_SOUND_MIXER_READ_ALTPCM = SOUND_MIXER_READ_ALTPCM;
303 unsigned IOCTL_SOUND_MIXER_READ_BASS = SOUND_MIXER_READ_BASS;
304 unsigned IOCTL_SOUND_MIXER_READ_CAPS = SOUND_MIXER_READ_CAPS;
305 unsigned IOCTL_SOUND_MIXER_READ_CD = SOUND_MIXER_READ_CD;
306 unsigned IOCTL_SOUND_MIXER_READ_DEVMASK = SOUND_MIXER_READ_DEVMASK;
307 unsigned IOCTL_SOUND_MIXER_READ_ENHANCE = SOUND_MIXER_READ_ENHANCE;
308 unsigned IOCTL_SOUND_MIXER_READ_IGAIN = SOUND_MIXER_READ_IGAIN;
309 unsigned IOCTL_SOUND_MIXER_READ_IMIX = SOUND_MIXER_READ_IMIX;
310 unsigned IOCTL_SOUND_MIXER_READ_LINE = SOUND_MIXER_READ_LINE;
311 unsigned IOCTL_SOUND_MIXER_READ_LINE1 = SOUND_MIXER_READ_LINE1;
312 unsigned IOCTL_SOUND_MIXER_READ_LINE2 = SOUND_MIXER_READ_LINE2;
313 unsigned IOCTL_SOUND_MIXER_READ_LINE3 = SOUND_MIXER_READ_LINE3;
314 unsigned IOCTL_SOUND_MIXER_READ_LOUD = SOUND_MIXER_READ_LOUD;
315 unsigned IOCTL_SOUND_MIXER_READ_MIC = SOUND_MIXER_READ_MIC;
316 unsigned IOCTL_SOUND_MIXER_READ_MUTE = SOUND_MIXER_READ_MUTE;
317 unsigned IOCTL_SOUND_MIXER_READ_OGAIN = SOUND_MIXER_READ_OGAIN;
318 unsigned IOCTL_SOUND_MIXER_READ_PCM = SOUND_MIXER_READ_PCM;
319 unsigned IOCTL_SOUND_MIXER_READ_RECLEV = SOUND_MIXER_READ_RECLEV;
320 unsigned IOCTL_SOUND_MIXER_READ_RECMASK = SOUND_MIXER_READ_RECMASK;
321 unsigned IOCTL_SOUND_MIXER_READ_RECSRC = SOUND_MIXER_READ_RECSRC;
322 unsigned IOCTL_SOUND_MIXER_READ_SPEAKER = SOUND_MIXER_READ_SPEAKER;
323 unsigned IOCTL_SOUND_MIXER_READ_STEREODEVS = SOUND_MIXER_READ_STEREODEVS;
324 unsigned IOCTL_SOUND_MIXER_READ_SYNTH = SOUND_MIXER_READ_SYNTH;
325 unsigned IOCTL_SOUND_MIXER_READ_TREBLE = SOUND_MIXER_READ_TREBLE;
326 unsigned IOCTL_SOUND_MIXER_READ_VOLUME = SOUND_MIXER_READ_VOLUME;
327 unsigned IOCTL_SOUND_MIXER_WRITE_ALTPCM = SOUND_MIXER_WRITE_ALTPCM;
328 unsigned IOCTL_SOUND_MIXER_WRITE_BASS = SOUND_MIXER_WRITE_BASS;
329 unsigned IOCTL_SOUND_MIXER_WRITE_CD = SOUND_MIXER_WRITE_CD;
330 unsigned IOCTL_SOUND_MIXER_WRITE_ENHANCE = SOUND_MIXER_WRITE_ENHANCE;
331 unsigned IOCTL_SOUND_MIXER_WRITE_IGAIN = SOUND_MIXER_WRITE_IGAIN;
332 unsigned IOCTL_SOUND_MIXER_WRITE_IMIX = SOUND_MIXER_WRITE_IMIX;
333 unsigned IOCTL_SOUND_MIXER_WRITE_LINE = SOUND_MIXER_WRITE_LINE;
334 unsigned IOCTL_SOUND_MIXER_WRITE_LINE1 = SOUND_MIXER_WRITE_LINE1;
335 unsigned IOCTL_SOUND_MIXER_WRITE_LINE2 = SOUND_MIXER_WRITE_LINE2;
336 unsigned IOCTL_SOUND_MIXER_WRITE_LINE3 = SOUND_MIXER_WRITE_LINE3;
337 unsigned IOCTL_SOUND_MIXER_WRITE_LOUD = SOUND_MIXER_WRITE_LOUD;
338 unsigned IOCTL_SOUND_MIXER_WRITE_MIC = SOUND_MIXER_WRITE_MIC;
339 unsigned IOCTL_SOUND_MIXER_WRITE_MUTE = SOUND_MIXER_WRITE_MUTE;
340 unsigned IOCTL_SOUND_MIXER_WRITE_OGAIN = SOUND_MIXER_WRITE_OGAIN;
341 unsigned IOCTL_SOUND_MIXER_WRITE_PCM = SOUND_MIXER_WRITE_PCM;
342 unsigned IOCTL_SOUND_MIXER_WRITE_RECLEV = SOUND_MIXER_WRITE_RECLEV;
343 unsigned IOCTL_SOUND_MIXER_WRITE_RECSRC = SOUND_MIXER_WRITE_RECSRC;
344 unsigned IOCTL_SOUND_MIXER_WRITE_SPEAKER = SOUND_MIXER_WRITE_SPEAKER;
345 unsigned IOCTL_SOUND_MIXER_WRITE_SYNTH = SOUND_MIXER_WRITE_SYNTH;
346 unsigned IOCTL_SOUND_MIXER_WRITE_TREBLE = SOUND_MIXER_WRITE_TREBLE;
347 unsigned IOCTL_SOUND_MIXER_WRITE_VOLUME = SOUND_MIXER_WRITE_VOLUME;
348 unsigned IOCTL_VT_ACTIVATE = VT_ACTIVATE;
349 unsigned IOCTL_VT_GETMODE = VT_GETMODE;
350 unsigned IOCTL_VT_OPENQRY = VT_OPENQRY;
351 unsigned IOCTL_VT_RELDISP = VT_RELDISP;
352 unsigned IOCTL_VT_SETMODE = VT_SETMODE;
353 unsigned IOCTL_VT_WAITACTIVE = VT_WAITACTIVE;
354 unsigned IOCTL_GIO_SCRNMAP = GIO_SCRNMAP;
355 unsigned IOCTL_KDDISABIO = KDDISABIO;
356 unsigned IOCTL_KDENABIO = KDENABIO;
357 unsigned IOCTL_KDGETLED = KDGETLED;
358 unsigned IOCTL_KDGETMODE = KDGETMODE;
359 unsigned IOCTL_KDGKBMODE = KDGKBMODE;
360 unsigned IOCTL_KDGKBTYPE = KDGKBTYPE;
361 unsigned IOCTL_KDMKTONE = KDMKTONE;
362 unsigned IOCTL_KDSETLED = KDSETLED;
363 unsigned IOCTL_KDSETMODE = KDSETMODE;
364 unsigned IOCTL_KDSKBMODE = KDSKBMODE;
365 unsigned IOCTL_KIOCSOUND = KIOCSOUND;
366 unsigned IOCTL_PIO_SCRNMAP = PIO_SCRNMAP;
367 unsigned IOCTL_SNDCTL_DSP_GETISPACE = SNDCTL_DSP_GETISPACE;
369 const int si_SEGV_MAPERR = SEGV_MAPERR;
370 const int si_SEGV_ACCERR = SEGV_ACCERR;
371 const int unvis_valid = UNVIS_VALID;
372 const int unvis_validpush = UNVIS_VALIDPUSH;
374 const unsigned MD5_CTX_sz = sizeof(MD5_CTX);
375 const unsigned MD5_return_length = MD5_DIGEST_STRING_LENGTH;
377 #define SHA2_CONST(LEN) \
378 const unsigned SHA##LEN##_CTX_sz = sizeof(SHA##LEN##_CTX); \
379 const unsigned SHA##LEN##_return_length = SHA##LEN##_DIGEST_STRING_LENGTH; \
380 const unsigned SHA##LEN##_block_length = SHA##LEN##_BLOCK_LENGTH; \
381 const unsigned SHA##LEN##_digest_length = SHA##LEN##_DIGEST_LENGTH
383 SHA2_CONST(224);
384 SHA2_CONST(256);
385 SHA2_CONST(384);
386 SHA2_CONST(512);
388 #undef SHA2_CONST
389 } // namespace __sanitizer
391 using namespace __sanitizer;
393 COMPILER_CHECK(sizeof(__sanitizer_pthread_attr_t) >= sizeof(pthread_attr_t));
395 COMPILER_CHECK(sizeof(socklen_t) == sizeof(unsigned));
396 CHECK_TYPE_SIZE(pthread_key_t);
398 // There are more undocumented fields in dl_phdr_info that we are not interested
399 // in.
400 COMPILER_CHECK(sizeof(__sanitizer_dl_phdr_info) <= sizeof(dl_phdr_info));
401 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_addr);
402 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_name);
403 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
404 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
406 CHECK_TYPE_SIZE(glob_t);
407 CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
408 CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
409 CHECK_SIZE_AND_OFFSET(glob_t, gl_offs);
410 CHECK_SIZE_AND_OFFSET(glob_t, gl_flags);
411 CHECK_SIZE_AND_OFFSET(glob_t, gl_closedir);
412 CHECK_SIZE_AND_OFFSET(glob_t, gl_readdir);
413 CHECK_SIZE_AND_OFFSET(glob_t, gl_opendir);
414 CHECK_SIZE_AND_OFFSET(glob_t, gl_lstat);
415 CHECK_SIZE_AND_OFFSET(glob_t, gl_stat);
417 CHECK_TYPE_SIZE(addrinfo);
418 CHECK_SIZE_AND_OFFSET(addrinfo, ai_flags);
419 CHECK_SIZE_AND_OFFSET(addrinfo, ai_family);
420 CHECK_SIZE_AND_OFFSET(addrinfo, ai_socktype);
421 CHECK_SIZE_AND_OFFSET(addrinfo, ai_protocol);
422 CHECK_SIZE_AND_OFFSET(addrinfo, ai_protocol);
423 CHECK_SIZE_AND_OFFSET(addrinfo, ai_addrlen);
424 CHECK_SIZE_AND_OFFSET(addrinfo, ai_canonname);
425 CHECK_SIZE_AND_OFFSET(addrinfo, ai_addr);
427 CHECK_TYPE_SIZE(hostent);
428 CHECK_SIZE_AND_OFFSET(hostent, h_name);
429 CHECK_SIZE_AND_OFFSET(hostent, h_aliases);
430 CHECK_SIZE_AND_OFFSET(hostent, h_addrtype);
431 CHECK_SIZE_AND_OFFSET(hostent, h_length);
432 CHECK_SIZE_AND_OFFSET(hostent, h_addr_list);
434 CHECK_TYPE_SIZE(iovec);
435 CHECK_SIZE_AND_OFFSET(iovec, iov_base);
436 CHECK_SIZE_AND_OFFSET(iovec, iov_len);
438 CHECK_TYPE_SIZE(msghdr);
439 CHECK_SIZE_AND_OFFSET(msghdr, msg_name);
440 CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen);
441 CHECK_SIZE_AND_OFFSET(msghdr, msg_iov);
442 CHECK_SIZE_AND_OFFSET(msghdr, msg_iovlen);
443 CHECK_SIZE_AND_OFFSET(msghdr, msg_control);
444 CHECK_SIZE_AND_OFFSET(msghdr, msg_controllen);
445 CHECK_SIZE_AND_OFFSET(msghdr, msg_flags);
447 CHECK_TYPE_SIZE(cmsghdr);
448 CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
449 CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
450 CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
452 COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
453 CHECK_SIZE_AND_OFFSET(dirent, d_ino);
454 CHECK_SIZE_AND_OFFSET(dirent, d_reclen);
456 CHECK_TYPE_SIZE(ifconf);
457 CHECK_SIZE_AND_OFFSET(ifconf, ifc_len);
458 CHECK_SIZE_AND_OFFSET(ifconf, ifc_ifcu);
460 CHECK_TYPE_SIZE(pollfd);
461 CHECK_SIZE_AND_OFFSET(pollfd, fd);
462 CHECK_SIZE_AND_OFFSET(pollfd, events);
463 CHECK_SIZE_AND_OFFSET(pollfd, revents);
465 CHECK_TYPE_SIZE(nfds_t);
467 CHECK_TYPE_SIZE(sigset_t);
469 COMPILER_CHECK(sizeof(__sanitizer_sigaction) == sizeof(struct sigaction));
470 // Can't write checks for sa_handler and sa_sigaction due to them being
471 // preprocessor macros.
472 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
474 CHECK_TYPE_SIZE(wordexp_t);
475 CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordc);
476 CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordv);
477 CHECK_SIZE_AND_OFFSET(wordexp_t, we_offs);
479 CHECK_TYPE_SIZE(tm);
480 CHECK_SIZE_AND_OFFSET(tm, tm_sec);
481 CHECK_SIZE_AND_OFFSET(tm, tm_min);
482 CHECK_SIZE_AND_OFFSET(tm, tm_hour);
483 CHECK_SIZE_AND_OFFSET(tm, tm_mday);
484 CHECK_SIZE_AND_OFFSET(tm, tm_mon);
485 CHECK_SIZE_AND_OFFSET(tm, tm_year);
486 CHECK_SIZE_AND_OFFSET(tm, tm_wday);
487 CHECK_SIZE_AND_OFFSET(tm, tm_yday);
488 CHECK_SIZE_AND_OFFSET(tm, tm_isdst);
489 CHECK_SIZE_AND_OFFSET(tm, tm_gmtoff);
490 CHECK_SIZE_AND_OFFSET(tm, tm_zone);
492 CHECK_TYPE_SIZE(ether_addr);
494 CHECK_TYPE_SIZE(ipc_perm);
495 CHECK_SIZE_AND_OFFSET(ipc_perm, key);
496 CHECK_SIZE_AND_OFFSET(ipc_perm, seq);
497 CHECK_SIZE_AND_OFFSET(ipc_perm, uid);
498 CHECK_SIZE_AND_OFFSET(ipc_perm, gid);
499 CHECK_SIZE_AND_OFFSET(ipc_perm, cuid);
500 CHECK_SIZE_AND_OFFSET(ipc_perm, cgid);
502 CHECK_TYPE_SIZE(shmid_ds);
503 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_perm);
504 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_segsz);
505 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_atime);
506 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_dtime);
507 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_ctime);
508 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_cpid);
509 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_lpid);
510 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_nattch);
512 CHECK_TYPE_SIZE(clock_t);
514 CHECK_TYPE_SIZE(ifaddrs);
515 CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_next);
516 CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_name);
517 CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_addr);
518 CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_netmask);
519 #undef ifa_dstaddr
520 CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
521 CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data);
523 CHECK_TYPE_SIZE(timeb);
524 CHECK_SIZE_AND_OFFSET(timeb, time);
525 CHECK_SIZE_AND_OFFSET(timeb, millitm);
526 CHECK_SIZE_AND_OFFSET(timeb, timezone);
527 CHECK_SIZE_AND_OFFSET(timeb, dstflag);
529 CHECK_TYPE_SIZE(passwd);
530 CHECK_SIZE_AND_OFFSET(passwd, pw_name);
531 CHECK_SIZE_AND_OFFSET(passwd, pw_passwd);
532 CHECK_SIZE_AND_OFFSET(passwd, pw_uid);
533 CHECK_SIZE_AND_OFFSET(passwd, pw_gid);
534 CHECK_SIZE_AND_OFFSET(passwd, pw_dir);
535 CHECK_SIZE_AND_OFFSET(passwd, pw_shell);
537 CHECK_SIZE_AND_OFFSET(passwd, pw_gecos);
539 CHECK_TYPE_SIZE(group);
540 CHECK_SIZE_AND_OFFSET(group, gr_name);
541 CHECK_SIZE_AND_OFFSET(group, gr_passwd);
542 CHECK_SIZE_AND_OFFSET(group, gr_gid);
543 CHECK_SIZE_AND_OFFSET(group, gr_mem);
545 #if HAVE_RPC_XDR_H
546 CHECK_TYPE_SIZE(XDR);
547 CHECK_SIZE_AND_OFFSET(XDR, x_op);
548 CHECK_SIZE_AND_OFFSET(XDR, x_ops);
549 CHECK_SIZE_AND_OFFSET(XDR, x_public);
550 CHECK_SIZE_AND_OFFSET(XDR, x_private);
551 CHECK_SIZE_AND_OFFSET(XDR, x_base);
552 CHECK_SIZE_AND_OFFSET(XDR, x_handy);
553 COMPILER_CHECK(__sanitizer_XDR_ENCODE == XDR_ENCODE);
554 COMPILER_CHECK(__sanitizer_XDR_DECODE == XDR_DECODE);
555 COMPILER_CHECK(__sanitizer_XDR_FREE == XDR_FREE);
556 #endif
558 CHECK_TYPE_SIZE(sem_t);
560 COMPILER_CHECK(sizeof(__sanitizer_cap_rights_t) >= sizeof(cap_rights_t));
561 #endif // SANITIZER_FREEBSD