1 //===-- sanitizer_platform_limits_netbsd.h --------------------------------===//
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
6 //===----------------------------------------------------------------------===//
8 // This file is a part of Sanitizer common code.
10 // Sizes and layouts of platform-specific NetBSD data structures.
11 //===----------------------------------------------------------------------===//
13 #ifndef SANITIZER_PLATFORM_LIMITS_NETBSD_H
14 #define SANITIZER_PLATFORM_LIMITS_NETBSD_H
18 #include "sanitizer_internal_defs.h"
19 #include "sanitizer_platform.h"
21 #define _GET_LINK_MAP_BY_DLOPEN_HANDLE(handle, shift) \
22 ((link_map *)((handle) == nullptr ? nullptr : ((char *)(handle) + (shift))))
24 #if defined(__x86_64__)
25 #define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \
26 _GET_LINK_MAP_BY_DLOPEN_HANDLE(handle, 608)
27 #elif defined(__i386__)
28 #define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \
29 _GET_LINK_MAP_BY_DLOPEN_HANDLE(handle, 324)
32 namespace __sanitizer
{
33 extern unsigned struct_utsname_sz
;
34 extern unsigned struct_stat_sz
;
35 extern unsigned struct_rusage_sz
;
36 extern unsigned siginfo_t_sz
;
37 extern unsigned struct_itimerval_sz
;
38 extern unsigned pthread_t_sz
;
39 extern unsigned pthread_cond_t_sz
;
40 extern unsigned pid_t_sz
;
41 extern unsigned timeval_sz
;
42 extern unsigned uid_t_sz
;
43 extern unsigned gid_t_sz
;
44 extern unsigned mbstate_t_sz
;
45 extern unsigned struct_timezone_sz
;
46 extern unsigned struct_tms_sz
;
47 extern unsigned struct_itimerspec_sz
;
48 extern unsigned struct_sigevent_sz
;
49 extern unsigned struct_sched_param_sz
;
50 extern unsigned struct_statfs_sz
;
51 extern unsigned struct_sockaddr_sz
;
52 extern unsigned ucontext_t_sz
;
54 extern unsigned struct_rlimit_sz
;
55 extern unsigned struct_utimbuf_sz
;
56 extern unsigned struct_timespec_sz
;
58 struct __sanitizer_iocb
{
65 #if SANITIZER_WORDSIZE == 64
75 struct __sanitizer___sysctl_args
{
84 struct __sanitizer_sem_t
{
88 struct __sanitizer_ipc_perm
{
98 struct __sanitizer_shmid_ds
{
99 __sanitizer_ipc_perm shm_perm
;
100 unsigned long shm_segsz
;
103 unsigned int shm_nattch
;
110 extern unsigned struct_msqid_ds_sz
;
111 extern unsigned struct_mq_attr_sz
;
112 extern unsigned struct_timex_sz
;
113 extern unsigned struct_statvfs_sz
;
115 struct __sanitizer_iovec
{
120 struct __sanitizer_ifaddrs
{
121 struct __sanitizer_ifaddrs
*ifa_next
;
123 unsigned int ifa_flags
;
124 void *ifa_addr
; // (struct sockaddr *)
125 void *ifa_netmask
; // (struct sockaddr *)
126 void *ifa_dstaddr
; // (struct sockaddr *)
128 unsigned int ifa_addrflags
;
131 typedef unsigned __sanitizer_pthread_key_t
;
133 typedef long long __sanitizer_time_t
;
135 struct __sanitizer_passwd
{
140 __sanitizer_time_t pw_change
;
145 __sanitizer_time_t pw_expire
;
148 struct __sanitizer_group
{
155 struct __sanitizer_timeb
{
156 __sanitizer_time_t time
;
157 unsigned short millitm
;
162 struct __sanitizer_ether_addr
{
166 struct __sanitizer_tm
{
180 struct __sanitizer_msghdr
{
182 unsigned msg_namelen
;
183 struct __sanitizer_iovec
*msg_iov
;
186 unsigned msg_controllen
;
189 struct __sanitizer_cmsghdr
{
195 struct __sanitizer_dirent
{
198 // more fields that we don't care about
201 typedef int __sanitizer_clock_t
;
202 typedef int __sanitizer_clockid_t
;
204 typedef u32 __sanitizer___kernel_uid_t
;
205 typedef u32 __sanitizer___kernel_gid_t
;
206 typedef u64 __sanitizer___kernel_off_t
;
209 } __sanitizer___kernel_fd_set
;
212 unsigned int pta_magic
;
215 } __sanitizer_pthread_attr_t
;
217 struct __sanitizer_sigset_t
{
219 unsigned int __bits
[4];
222 struct __sanitizer_sigaction
{
224 void (*handler
)(int sig
);
225 void (*sigaction
)(int sig
, void *siginfo
, void *uctx
);
227 __sanitizer_sigset_t sa_mask
;
231 typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t
;
233 struct __sanitizer_kernel_sigaction_t
{
235 void (*handler
)(int signo
);
236 void (*sigaction
)(int signo
, void *info
, void *ctx
);
238 unsigned long sa_flags
;
239 void (*sa_restorer
)(void);
240 __sanitizer_kernel_sigset_t sa_mask
;
245 extern uptr sa_siginfo
;
249 uptr
__sanitizer_in_addr_sz(int af
);
251 struct __sanitizer_dl_phdr_info
{
253 const char *dlpi_name
;
254 const void *dlpi_phdr
;
258 extern unsigned struct_ElfW_Phdr_sz
;
260 struct __sanitizer_addrinfo
{
268 struct __sanitizer_addrinfo
*ai_next
;
271 struct __sanitizer_hostent
{
279 struct __sanitizer_pollfd
{
285 typedef unsigned __sanitizer_nfds_t
;
287 struct __sanitizer_glob_t
{
293 int (*gl_errfunc
)(const char *, int);
294 void (*gl_closedir
)(void *dirp
);
295 struct dirent
*(*gl_readdir
)(void *dirp
);
296 void *(*gl_opendir
)(const char *);
297 int (*gl_lstat
)(const char *, void * /* struct stat* */);
298 int (*gl_stat
)(const char *, void * /* struct stat* */);
301 extern int glob_nomatch
;
302 extern int glob_altdirfunc
;
304 extern unsigned path_max
;
306 struct __sanitizer_wordexp_t
{
314 typedef void __sanitizer_FILE
;
315 #define SANITIZER_HAS_STRUCT_FILE 0
317 extern int shmctl_ipc_stat
;
319 // This simplifies generic code
320 #define struct_shminfo_sz -1
321 #define struct_shm_info_sz -1
322 #define shmctl_shm_stat -1
323 #define shmctl_ipc_info -1
324 #define shmctl_shm_info -1
326 extern unsigned struct_utmp_sz
;
327 extern unsigned struct_utmpx_sz
;
329 extern int map_fixed
;
332 struct __sanitizer_ifconf
{
340 #define IOC_TYPEBITS 8
341 #define IOC_SIZEBITS 14
342 #define IOC_DIRBITS 2
346 #define IOC_NRMASK ((1 << IOC_NRBITS) - 1)
347 #define IOC_TYPEMASK ((1 << IOC_TYPEBITS) - 1)
348 #define IOC_SIZEMASK ((1 << IOC_SIZEBITS) - 1)
350 #define IOC_DIRMASK ((1 << IOC_DIRBITS) - 1)
351 #define IOC_NRSHIFT 0
352 #define IOC_TYPESHIFT (IOC_NRSHIFT + IOC_NRBITS)
353 #define IOC_SIZESHIFT (IOC_TYPESHIFT + IOC_TYPEBITS)
354 #define IOC_DIRSHIFT (IOC_SIZESHIFT + IOC_SIZEBITS)
355 #define EVIOC_EV_MAX 0x1f
356 #define EVIOC_ABS_MAX 0x3f
358 #define IOC_DIR(nr) (((nr) >> IOC_DIRSHIFT) & IOC_DIRMASK)
359 #define IOC_TYPE(nr) (((nr) >> IOC_TYPESHIFT) & IOC_TYPEMASK)
360 #define IOC_NR(nr) (((nr) >> IOC_NRSHIFT) & IOC_NRMASK)
361 #define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK)
363 extern unsigned struct_ifreq_sz
;
364 extern unsigned struct_termios_sz
;
365 extern unsigned struct_winsize_sz
;
367 extern unsigned struct_arpreq_sz
;
369 extern unsigned struct_mtget_sz
;
370 extern unsigned struct_mtop_sz
;
371 extern unsigned struct_rtentry_sz
;
372 extern unsigned struct_sbi_instrument_sz
;
373 extern unsigned struct_seq_event_rec_sz
;
374 extern unsigned struct_synth_info_sz
;
375 extern unsigned struct_vt_mode_sz
;
376 extern unsigned struct_audio_buf_info_sz
;
377 extern unsigned struct_ppp_stats_sz
;
378 extern unsigned struct_sioc_sg_req_sz
;
379 extern unsigned struct_sioc_vif_req_sz
;
381 // ioctl request identifiers
383 // A special value to mark ioctls that are not present on the target platform,
384 // when it can not be determined without including any system headers.
385 extern const unsigned IOCTL_NOT_PRESENT
;
387 extern unsigned IOCTL_FIOASYNC
;
388 extern unsigned IOCTL_FIOCLEX
;
389 extern unsigned IOCTL_FIOGETOWN
;
390 extern unsigned IOCTL_FIONBIO
;
391 extern unsigned IOCTL_FIONCLEX
;
392 extern unsigned IOCTL_FIOSETOWN
;
393 extern unsigned IOCTL_SIOCADDMULTI
;
394 extern unsigned IOCTL_SIOCATMARK
;
395 extern unsigned IOCTL_SIOCDELMULTI
;
396 extern unsigned IOCTL_SIOCGIFADDR
;
397 extern unsigned IOCTL_SIOCGIFBRDADDR
;
398 extern unsigned IOCTL_SIOCGIFCONF
;
399 extern unsigned IOCTL_SIOCGIFDSTADDR
;
400 extern unsigned IOCTL_SIOCGIFFLAGS
;
401 extern unsigned IOCTL_SIOCGIFMETRIC
;
402 extern unsigned IOCTL_SIOCGIFMTU
;
403 extern unsigned IOCTL_SIOCGIFNETMASK
;
404 extern unsigned IOCTL_SIOCGPGRP
;
405 extern unsigned IOCTL_SIOCSIFADDR
;
406 extern unsigned IOCTL_SIOCSIFBRDADDR
;
407 extern unsigned IOCTL_SIOCSIFDSTADDR
;
408 extern unsigned IOCTL_SIOCSIFFLAGS
;
409 extern unsigned IOCTL_SIOCSIFMETRIC
;
410 extern unsigned IOCTL_SIOCSIFMTU
;
411 extern unsigned IOCTL_SIOCSIFNETMASK
;
412 extern unsigned IOCTL_SIOCSPGRP
;
413 extern unsigned IOCTL_TIOCCONS
;
414 extern unsigned IOCTL_TIOCEXCL
;
415 extern unsigned IOCTL_TIOCGETD
;
416 extern unsigned IOCTL_TIOCGPGRP
;
417 extern unsigned IOCTL_TIOCGWINSZ
;
418 extern unsigned IOCTL_TIOCMBIC
;
419 extern unsigned IOCTL_TIOCMBIS
;
420 extern unsigned IOCTL_TIOCMGET
;
421 extern unsigned IOCTL_TIOCMSET
;
422 extern unsigned IOCTL_TIOCNOTTY
;
423 extern unsigned IOCTL_TIOCNXCL
;
424 extern unsigned IOCTL_TIOCOUTQ
;
425 extern unsigned IOCTL_TIOCPKT
;
426 extern unsigned IOCTL_TIOCSCTTY
;
427 extern unsigned IOCTL_TIOCSETD
;
428 extern unsigned IOCTL_TIOCSPGRP
;
429 extern unsigned IOCTL_TIOCSTI
;
430 extern unsigned IOCTL_TIOCSWINSZ
;
431 extern unsigned IOCTL_SIOCGETSGCNT
;
432 extern unsigned IOCTL_SIOCGETVIFCNT
;
433 extern unsigned IOCTL_MTIOCGET
;
434 extern unsigned IOCTL_MTIOCTOP
;
435 extern unsigned IOCTL_SIOCADDRT
;
436 extern unsigned IOCTL_SIOCDELRT
;
437 extern unsigned IOCTL_SNDCTL_DSP_GETBLKSIZE
;
438 extern unsigned IOCTL_SNDCTL_DSP_GETFMTS
;
439 extern unsigned IOCTL_SNDCTL_DSP_NONBLOCK
;
440 extern unsigned IOCTL_SNDCTL_DSP_POST
;
441 extern unsigned IOCTL_SNDCTL_DSP_RESET
;
442 extern unsigned IOCTL_SNDCTL_DSP_SETFMT
;
443 extern unsigned IOCTL_SNDCTL_DSP_SETFRAGMENT
;
444 extern unsigned IOCTL_SNDCTL_DSP_SPEED
;
445 extern unsigned IOCTL_SNDCTL_DSP_STEREO
;
446 extern unsigned IOCTL_SNDCTL_DSP_SUBDIVIDE
;
447 extern unsigned IOCTL_SNDCTL_DSP_SYNC
;
448 extern unsigned IOCTL_SNDCTL_FM_4OP_ENABLE
;
449 extern unsigned IOCTL_SNDCTL_FM_LOAD_INSTR
;
450 extern unsigned IOCTL_SNDCTL_MIDI_INFO
;
451 extern unsigned IOCTL_SNDCTL_MIDI_PRETIME
;
452 extern unsigned IOCTL_SNDCTL_SEQ_CTRLRATE
;
453 extern unsigned IOCTL_SNDCTL_SEQ_GETINCOUNT
;
454 extern unsigned IOCTL_SNDCTL_SEQ_GETOUTCOUNT
;
455 extern unsigned IOCTL_SNDCTL_SEQ_NRMIDIS
;
456 extern unsigned IOCTL_SNDCTL_SEQ_NRSYNTHS
;
457 extern unsigned IOCTL_SNDCTL_SEQ_OUTOFBAND
;
458 extern unsigned IOCTL_SNDCTL_SEQ_PANIC
;
459 extern unsigned IOCTL_SNDCTL_SEQ_PERCMODE
;
460 extern unsigned IOCTL_SNDCTL_SEQ_RESET
;
461 extern unsigned IOCTL_SNDCTL_SEQ_RESETSAMPLES
;
462 extern unsigned IOCTL_SNDCTL_SEQ_SYNC
;
463 extern unsigned IOCTL_SNDCTL_SEQ_TESTMIDI
;
464 extern unsigned IOCTL_SNDCTL_SEQ_THRESHOLD
;
465 extern unsigned IOCTL_SNDCTL_SYNTH_INFO
;
466 extern unsigned IOCTL_SNDCTL_SYNTH_MEMAVL
;
467 extern unsigned IOCTL_SNDCTL_TMR_CONTINUE
;
468 extern unsigned IOCTL_SNDCTL_TMR_METRONOME
;
469 extern unsigned IOCTL_SNDCTL_TMR_SELECT
;
470 extern unsigned IOCTL_SNDCTL_TMR_SOURCE
;
471 extern unsigned IOCTL_SNDCTL_TMR_START
;
472 extern unsigned IOCTL_SNDCTL_TMR_STOP
;
473 extern unsigned IOCTL_SNDCTL_TMR_TEMPO
;
474 extern unsigned IOCTL_SNDCTL_TMR_TIMEBASE
;
475 extern unsigned IOCTL_SOUND_MIXER_READ_ALTPCM
;
476 extern unsigned IOCTL_SOUND_MIXER_READ_BASS
;
477 extern unsigned IOCTL_SOUND_MIXER_READ_CAPS
;
478 extern unsigned IOCTL_SOUND_MIXER_READ_CD
;
479 extern unsigned IOCTL_SOUND_MIXER_READ_DEVMASK
;
480 extern unsigned IOCTL_SOUND_MIXER_READ_ENHANCE
;
481 extern unsigned IOCTL_SOUND_MIXER_READ_IGAIN
;
482 extern unsigned IOCTL_SOUND_MIXER_READ_IMIX
;
483 extern unsigned IOCTL_SOUND_MIXER_READ_LINE1
;
484 extern unsigned IOCTL_SOUND_MIXER_READ_LINE2
;
485 extern unsigned IOCTL_SOUND_MIXER_READ_LINE3
;
486 extern unsigned IOCTL_SOUND_MIXER_READ_LINE
;
487 extern unsigned IOCTL_SOUND_MIXER_READ_LOUD
;
488 extern unsigned IOCTL_SOUND_MIXER_READ_MIC
;
489 extern unsigned IOCTL_SOUND_MIXER_READ_MUTE
;
490 extern unsigned IOCTL_SOUND_MIXER_READ_OGAIN
;
491 extern unsigned IOCTL_SOUND_MIXER_READ_PCM
;
492 extern unsigned IOCTL_SOUND_MIXER_READ_RECLEV
;
493 extern unsigned IOCTL_SOUND_MIXER_READ_RECMASK
;
494 extern unsigned IOCTL_SOUND_MIXER_READ_RECSRC
;
495 extern unsigned IOCTL_SOUND_MIXER_READ_SPEAKER
;
496 extern unsigned IOCTL_SOUND_MIXER_READ_STEREODEVS
;
497 extern unsigned IOCTL_SOUND_MIXER_READ_SYNTH
;
498 extern unsigned IOCTL_SOUND_MIXER_READ_TREBLE
;
499 extern unsigned IOCTL_SOUND_MIXER_READ_VOLUME
;
500 extern unsigned IOCTL_SOUND_MIXER_WRITE_ALTPCM
;
501 extern unsigned IOCTL_SOUND_MIXER_WRITE_BASS
;
502 extern unsigned IOCTL_SOUND_MIXER_WRITE_CD
;
503 extern unsigned IOCTL_SOUND_MIXER_WRITE_ENHANCE
;
504 extern unsigned IOCTL_SOUND_MIXER_WRITE_IGAIN
;
505 extern unsigned IOCTL_SOUND_MIXER_WRITE_IMIX
;
506 extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE1
;
507 extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE2
;
508 extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE3
;
509 extern unsigned IOCTL_SOUND_MIXER_WRITE_LINE
;
510 extern unsigned IOCTL_SOUND_MIXER_WRITE_LOUD
;
511 extern unsigned IOCTL_SOUND_MIXER_WRITE_MIC
;
512 extern unsigned IOCTL_SOUND_MIXER_WRITE_MUTE
;
513 extern unsigned IOCTL_SOUND_MIXER_WRITE_OGAIN
;
514 extern unsigned IOCTL_SOUND_MIXER_WRITE_PCM
;
515 extern unsigned IOCTL_SOUND_MIXER_WRITE_RECLEV
;
516 extern unsigned IOCTL_SOUND_MIXER_WRITE_RECSRC
;
517 extern unsigned IOCTL_SOUND_MIXER_WRITE_SPEAKER
;
518 extern unsigned IOCTL_SOUND_MIXER_WRITE_SYNTH
;
519 extern unsigned IOCTL_SOUND_MIXER_WRITE_TREBLE
;
520 extern unsigned IOCTL_SOUND_MIXER_WRITE_VOLUME
;
521 extern unsigned IOCTL_SOUND_PCM_READ_BITS
;
522 extern unsigned IOCTL_SOUND_PCM_READ_CHANNELS
;
523 extern unsigned IOCTL_SOUND_PCM_READ_FILTER
;
524 extern unsigned IOCTL_SOUND_PCM_READ_RATE
;
525 extern unsigned IOCTL_SOUND_PCM_WRITE_CHANNELS
;
526 extern unsigned IOCTL_SOUND_PCM_WRITE_FILTER
;
527 extern unsigned IOCTL_VT_ACTIVATE
;
528 extern unsigned IOCTL_VT_GETMODE
;
529 extern unsigned IOCTL_VT_OPENQRY
;
530 extern unsigned IOCTL_VT_RELDISP
;
531 extern unsigned IOCTL_VT_SETMODE
;
532 extern unsigned IOCTL_VT_WAITACTIVE
;
533 extern unsigned IOCTL_KDDISABIO
;
534 extern unsigned IOCTL_KDENABIO
;
535 extern unsigned IOCTL_KDGETLED
;
536 extern unsigned IOCTL_KDGKBMODE
;
537 extern unsigned IOCTL_KDGKBTYPE
;
538 extern unsigned IOCTL_KDMKTONE
;
539 extern unsigned IOCTL_KDSETLED
;
540 extern unsigned IOCTL_KDSETMODE
;
541 extern unsigned IOCTL_KDSKBMODE
;
543 extern const int si_SEGV_MAPERR
;
544 extern const int si_SEGV_ACCERR
;
545 } // namespace __sanitizer
547 #define CHECK_TYPE_SIZE(TYPE) \
548 COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
550 #define CHECK_SIZE_AND_OFFSET(CLASS, MEMBER) \
551 COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *)NULL)->MEMBER) == \
552 sizeof(((CLASS *)NULL)->MEMBER)); \
553 COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) == \
554 offsetof(CLASS, MEMBER))
556 // For sigaction, which is a function and struct at the same time,
557 // and thus requires explicit "struct" in sizeof() expression.
558 #define CHECK_STRUCT_SIZE_AND_OFFSET(CLASS, MEMBER) \
559 COMPILER_CHECK(sizeof(((struct __sanitizer_##CLASS *)NULL)->MEMBER) == \
560 sizeof(((struct CLASS *)NULL)->MEMBER)); \
561 COMPILER_CHECK(offsetof(struct __sanitizer_##CLASS, MEMBER) == \
562 offsetof(struct CLASS, MEMBER))
564 #endif // SANITIZER_NETBSD