1 //===-- sanitizer_platform_limits_solaris.h -------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // This file is a part of Sanitizer common code.
11 // Sizes and layouts of platform-specific Solaris data structures.
12 //===----------------------------------------------------------------------===//
14 #ifndef SANITIZER_PLATFORM_LIMITS_SOLARIS_H
15 #define SANITIZER_PLATFORM_LIMITS_SOLARIS_H
19 #include "sanitizer_internal_defs.h"
20 #include "sanitizer_platform.h"
22 namespace __sanitizer
{
23 extern unsigned struct_utsname_sz
;
24 extern unsigned struct_stat_sz
;
25 extern unsigned struct_stat64_sz
;
26 extern unsigned struct_rusage_sz
;
27 extern unsigned siginfo_t_sz
;
28 extern unsigned struct_itimerval_sz
;
29 extern unsigned pthread_t_sz
;
30 extern unsigned pthread_mutex_t_sz
;
31 extern unsigned pthread_cond_t_sz
;
32 extern unsigned pid_t_sz
;
33 extern unsigned timeval_sz
;
34 extern unsigned uid_t_sz
;
35 extern unsigned gid_t_sz
;
36 extern unsigned mbstate_t_sz
;
37 extern unsigned struct_timezone_sz
;
38 extern unsigned struct_tms_sz
;
39 extern unsigned struct_itimerspec_sz
;
40 extern unsigned struct_sigevent_sz
;
41 extern unsigned struct_stack_t_sz
;
42 extern unsigned struct_sched_param_sz
;
43 extern unsigned struct_statfs64_sz
;
44 extern unsigned struct_statfs_sz
;
45 extern unsigned struct_sockaddr_sz
;
46 unsigned ucontext_t_sz(void *ctx
);
48 extern unsigned struct_timespec_sz
;
49 extern unsigned struct_rlimit_sz
;
50 extern unsigned struct_utimbuf_sz
;
52 struct __sanitizer_sem_t
{
61 struct __sanitizer_ipc_perm
{
62 unsigned int uid
; // uid_t
63 unsigned int gid
; // gid_t
64 unsigned int cuid
; // uid_t
65 unsigned int cgid
; // gid_t
66 unsigned int mode
; // mode_t
67 unsigned int seq
; // uint_t
74 struct __sanitizer_shmid_ds
{
75 __sanitizer_ipc_perm shm_perm
;
76 unsigned long shm_segsz
; // size_t
77 unsigned long shm_flags
; // uintptr_t
78 unsigned short shm_lkcnt
; // ushort_t
79 int shm_lpid
; // pid_t
80 int shm_cpid
; // pid_t
81 unsigned long shm_nattch
; // shmatt_t
82 unsigned long shm_cnattch
; // ulong_t
84 long shm_atime
; // time_t
88 u64 shm_gransize
; // uint64_t
89 u64 shm_allocated
; // uint64_t
90 u64 shm_pad4
[1]; // int64_t
92 long shm_atime
; // time_t
93 int shm_pad1
; // int32_t
94 long shm_dtime
; // time_t
95 int shm_pad2
; // int32_t
96 long shm_ctime
; // time_t
98 u64 shm_gransize
; // uint64_t
99 u64 shm_allocated
; // uint64_t
103 extern unsigned struct_statvfs_sz
;
104 #if SANITIZER_SOLARIS32
105 extern unsigned struct_statvfs64_sz
;
108 struct __sanitizer_iovec
{
113 struct __sanitizer_ifaddrs
{
114 struct __sanitizer_ifaddrs
*ifa_next
;
116 u64 ifa_flags
; // uint64_t
117 void *ifa_addr
; // (struct sockaddr *)
118 void *ifa_netmask
; // (struct sockaddr *)
119 // This is a union on Linux.
123 void *ifa_dstaddr
; // (struct sockaddr *)
127 typedef unsigned __sanitizer_pthread_key_t
;
129 struct __sanitizer_XDR
{
138 const int __sanitizer_XDR_ENCODE
= 0;
139 const int __sanitizer_XDR_DECODE
= 1;
140 const int __sanitizer_XDR_FREE
= 2;
142 struct __sanitizer_passwd
{
145 unsigned int pw_uid
; // uid_t
146 unsigned int pw_gid
; // gid_t
154 struct __sanitizer_group
{
161 typedef long __sanitizer_time_t
;
163 typedef long __sanitizer_suseconds_t
;
165 struct __sanitizer_timeval
{
166 __sanitizer_time_t tv_sec
;
167 __sanitizer_suseconds_t tv_usec
;
170 struct __sanitizer_itimerval
{
171 struct __sanitizer_timeval it_interval
;
172 struct __sanitizer_timeval it_value
;
175 struct __sanitizer_timeb
{
176 __sanitizer_time_t time
;
177 unsigned short millitm
;
182 struct __sanitizer_ether_addr
{
186 struct __sanitizer_tm
{
198 struct __sanitizer_msghdr
{
200 unsigned msg_namelen
;
201 struct __sanitizer_iovec
*msg_iov
;
204 unsigned msg_controllen
;
207 struct __sanitizer_cmsghdr
{
213 #if SANITIZER_SOLARIS && (defined(_LP64) || _FILE_OFFSET_BITS == 64)
214 struct __sanitizer_dirent
{
215 unsigned long long d_ino
;
217 unsigned short d_reclen
;
218 // more fields that we don't care about
221 struct __sanitizer_dirent
{
224 unsigned short d_reclen
;
225 // more fields that we don't care about
229 struct __sanitizer_dirent64
{
230 unsigned long long d_ino
;
231 unsigned long long d_off
;
232 unsigned short d_reclen
;
233 // more fields that we don't care about
236 typedef long __sanitizer_clock_t
;
237 typedef int __sanitizer_clockid_t
;
239 // This thing depends on the platform. We are only interested in the upper
240 // limit. Verified with a compiler assert in .cpp.
241 union __sanitizer_pthread_attr_t
{
246 struct __sanitizer_sigset_t
{
248 unsigned int __bits
[4];
251 struct __sanitizer_siginfo
{
252 // The size is determined by looking at sizeof of real siginfo_t on linux.
253 u64 opaque
[128 / sizeof(u64
)];
256 using __sanitizer_sighandler_ptr
= void (*)(int sig
);
257 using __sanitizer_sigactionhandler_ptr
=
258 void (*)(int sig
, __sanitizer_siginfo
*siginfo
, void *uctx
);
260 struct __sanitizer_sigaction
{
263 __sanitizer_sigactionhandler_ptr sigaction
;
264 __sanitizer_sighandler_ptr handler
;
266 __sanitizer_sigset_t sa_mask
;
272 struct __sanitizer_kernel_sigset_t
{
276 struct __sanitizer_kernel_sigaction_t
{
278 void (*handler
)(int signo
);
279 void (*sigaction
)(int signo
, __sanitizer_siginfo
*info
, void *ctx
);
281 unsigned long sa_flags
;
282 void (*sa_restorer
)(void);
283 __sanitizer_kernel_sigset_t sa_mask
;
286 extern const uptr sig_ign
;
287 extern const uptr sig_dfl
;
288 extern const uptr sig_err
;
289 extern const uptr sa_siginfo
;
293 uptr
__sanitizer_in_addr_sz(int af
);
295 struct __sanitizer_dl_phdr_info
{
297 const char *dlpi_name
;
298 const void *dlpi_phdr
;
302 extern unsigned struct_ElfW_Phdr_sz
;
304 struct __sanitizer_addrinfo
{
309 #if defined(__sparcv9)
315 struct __sanitizer_addrinfo
*ai_next
;
318 struct __sanitizer_hostent
{
326 struct __sanitizer_pollfd
{
332 typedef unsigned long __sanitizer_nfds_t
;
334 struct __sanitizer_glob_t
{
342 extern int glob_nomatch
;
343 extern int glob_altdirfunc
;
344 extern const int wordexp_wrde_dooffs
;
346 extern unsigned path_max
;
348 struct __sanitizer_wordexp_t
{
356 typedef void __sanitizer_FILE
;
357 #define SANITIZER_HAS_STRUCT_FILE 0
359 // This simplifies generic code
360 #define struct_shminfo_sz -1
361 #define struct_shm_info_sz -1
362 #define shmctl_shm_stat -1
363 #define shmctl_ipc_info -1
364 #define shmctl_shm_info -1
366 extern int shmctl_ipc_stat
;
368 extern unsigned struct_utmp_sz
;
369 extern unsigned struct_utmpx_sz
;
371 extern int map_fixed
;
374 struct __sanitizer_ifconf
{
383 #define IOC_TYPEBITS 8
384 #define IOC_SIZEBITS 12
385 #define IOC_DIRBITS 4
387 #define IOC_NONE 2U // IOC_VOID
388 #define IOC_READ 4U // IOC_OUT
389 #define IOC_WRITE 8U // IOC_IN
391 #define IOC_NRMASK ((1 << IOC_NRBITS) - 1)
392 #define IOC_TYPEMASK ((1 << IOC_TYPEBITS) - 1)
393 #define IOC_SIZEMASK ((1 << IOC_SIZEBITS) - 1)
394 #define IOC_DIRMASK ((1 << IOC_DIRBITS) - 1)
395 #define IOC_NRSHIFT 0
396 #define IOC_TYPESHIFT (IOC_NRSHIFT + IOC_NRBITS)
397 #define IOC_SIZESHIFT (IOC_TYPESHIFT + IOC_TYPEBITS)
398 #define IOC_DIRSHIFT (IOC_SIZESHIFT + IOC_SIZEBITS)
400 #define IOC_DIR(nr) (((nr) >> IOC_DIRSHIFT) & IOC_DIRMASK)
401 #define IOC_TYPE(nr) (((nr) >> IOC_TYPESHIFT) & IOC_TYPEMASK)
402 #define IOC_NR(nr) (((nr) >> IOC_NRSHIFT) & IOC_NRMASK)
404 #if defined(__sparc__)
405 // In sparc the 14 bits SIZE field overlaps with the
406 // least significant bit of DIR, so either IOC_READ or
407 // IOC_WRITE shall be 1 in order to get a non-zero SIZE.
408 #define IOC_SIZE(nr) \
409 ((((((nr) >> 29) & 0x7) & (4U | 2U)) == 0) ? 0 : (((nr) >> 16) & 0x3fff))
411 #define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK)
414 extern unsigned struct_ifreq_sz
;
415 extern unsigned struct_termios_sz
;
416 extern unsigned struct_winsize_sz
;
418 extern unsigned struct_sioc_sg_req_sz
;
419 extern unsigned struct_sioc_vif_req_sz
;
421 // ioctl request identifiers
423 // A special value to mark ioctls that are not present on the target platform,
424 // when it can not be determined without including any system headers.
425 extern const unsigned IOCTL_NOT_PRESENT
;
427 extern unsigned IOCTL_FIOASYNC
;
428 extern unsigned IOCTL_FIOCLEX
;
429 extern unsigned IOCTL_FIOGETOWN
;
430 extern unsigned IOCTL_FIONBIO
;
431 extern unsigned IOCTL_FIONCLEX
;
432 extern unsigned IOCTL_FIOSETOWN
;
433 extern unsigned IOCTL_SIOCADDMULTI
;
434 extern unsigned IOCTL_SIOCATMARK
;
435 extern unsigned IOCTL_SIOCDELMULTI
;
436 extern unsigned IOCTL_SIOCGIFADDR
;
437 extern unsigned IOCTL_SIOCGIFBRDADDR
;
438 extern unsigned IOCTL_SIOCGIFCONF
;
439 extern unsigned IOCTL_SIOCGIFDSTADDR
;
440 extern unsigned IOCTL_SIOCGIFFLAGS
;
441 extern unsigned IOCTL_SIOCGIFMETRIC
;
442 extern unsigned IOCTL_SIOCGIFMTU
;
443 extern unsigned IOCTL_SIOCGIFNETMASK
;
444 extern unsigned IOCTL_SIOCGPGRP
;
445 extern unsigned IOCTL_SIOCSIFADDR
;
446 extern unsigned IOCTL_SIOCSIFBRDADDR
;
447 extern unsigned IOCTL_SIOCSIFDSTADDR
;
448 extern unsigned IOCTL_SIOCSIFFLAGS
;
449 extern unsigned IOCTL_SIOCSIFMETRIC
;
450 extern unsigned IOCTL_SIOCSIFMTU
;
451 extern unsigned IOCTL_SIOCSIFNETMASK
;
452 extern unsigned IOCTL_SIOCSPGRP
;
453 extern unsigned IOCTL_TIOCEXCL
;
454 extern unsigned IOCTL_TIOCGETD
;
455 extern unsigned IOCTL_TIOCGPGRP
;
456 extern unsigned IOCTL_TIOCGWINSZ
;
457 extern unsigned IOCTL_TIOCMBIC
;
458 extern unsigned IOCTL_TIOCMBIS
;
459 extern unsigned IOCTL_TIOCMGET
;
460 extern unsigned IOCTL_TIOCMSET
;
461 extern unsigned IOCTL_TIOCNOTTY
;
462 extern unsigned IOCTL_TIOCNXCL
;
463 extern unsigned IOCTL_TIOCOUTQ
;
464 extern unsigned IOCTL_TIOCPKT
;
465 extern unsigned IOCTL_TIOCSCTTY
;
466 extern unsigned IOCTL_TIOCSETD
;
467 extern unsigned IOCTL_TIOCSPGRP
;
468 extern unsigned IOCTL_TIOCSTI
;
469 extern unsigned IOCTL_TIOCSWINSZ
;
470 extern unsigned IOCTL_MTIOCGET
;
471 extern unsigned IOCTL_MTIOCTOP
;
473 extern const int si_SEGV_MAPERR
;
474 extern const int si_SEGV_ACCERR
;
475 } // namespace __sanitizer
477 #define CHECK_TYPE_SIZE(TYPE) \
478 COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
480 #define CHECK_SIZE_AND_OFFSET(CLASS, MEMBER) \
481 COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *) NULL)->MEMBER) == \
482 sizeof(((CLASS *) NULL)->MEMBER)); \
483 COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) == \
484 offsetof(CLASS, MEMBER))
486 // For sigaction, which is a function and struct at the same time,
487 // and thus requires explicit "struct" in sizeof() expression.
488 #define CHECK_STRUCT_SIZE_AND_OFFSET(CLASS, MEMBER) \
489 COMPILER_CHECK(sizeof(((struct __sanitizer_##CLASS *) NULL)->MEMBER) == \
490 sizeof(((struct CLASS *) NULL)->MEMBER)); \
491 COMPILER_CHECK(offsetof(struct __sanitizer_##CLASS, MEMBER) == \
492 offsetof(struct CLASS, MEMBER))
494 #endif // SANITIZER_SOLARIS