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_sched_param_sz
;
42 extern unsigned struct_statfs64_sz
;
43 extern unsigned struct_statfs_sz
;
44 extern unsigned struct_sockaddr_sz
;
45 extern unsigned ucontext_t_sz
;
47 extern unsigned struct_timespec_sz
;
48 extern unsigned struct_rlimit_sz
;
49 extern unsigned struct_utimbuf_sz
;
51 struct __sanitizer_sem_t
{
60 struct __sanitizer_ipc_perm
{
61 unsigned int uid
; // uid_t
62 unsigned int gid
; // gid_t
63 unsigned int cuid
; // uid_t
64 unsigned int cgid
; // gid_t
65 unsigned int mode
; // mode_t
66 unsigned int seq
; // uint_t
73 struct __sanitizer_shmid_ds
{
74 __sanitizer_ipc_perm shm_perm
;
75 unsigned long shm_segsz
; // size_t
76 unsigned long shm_flags
; // uintptr_t
77 unsigned short shm_lkcnt
; // ushort_t
78 int shm_lpid
; // pid_t
79 int shm_cpid
; // pid_t
80 unsigned long shm_nattch
; // shmatt_t
81 unsigned long shm_cnattch
; // ulong_t
83 long shm_atime
; // time_t
87 u64 shm_gransize
; // uint64_t
88 u64 shm_allocated
; // uint64_t
89 u64 shm_pad4
[1]; // int64_t
91 long shm_atime
; // time_t
92 int shm_pad1
; // int32_t
93 long shm_dtime
; // time_t
94 int shm_pad2
; // int32_t
95 long shm_ctime
; // time_t
97 u64 shm_gransize
; // uint64_t
98 u64 shm_allocated
; // uint64_t
102 extern unsigned struct_statvfs_sz
;
103 #if SANITIZER_SOLARIS32
104 extern unsigned struct_statvfs64_sz
;
107 struct __sanitizer_iovec
{
112 struct __sanitizer_ifaddrs
{
113 struct __sanitizer_ifaddrs
*ifa_next
;
115 u64 ifa_flags
; // uint64_t
116 void *ifa_addr
; // (struct sockaddr *)
117 void *ifa_netmask
; // (struct sockaddr *)
118 // This is a union on Linux.
122 void *ifa_dstaddr
; // (struct sockaddr *)
126 typedef unsigned __sanitizer_pthread_key_t
;
128 struct __sanitizer_XDR
{
137 const int __sanitizer_XDR_ENCODE
= 0;
138 const int __sanitizer_XDR_DECODE
= 1;
139 const int __sanitizer_XDR_FREE
= 2;
141 struct __sanitizer_passwd
{
144 unsigned int pw_uid
; // uid_t
145 unsigned int pw_gid
; // gid_t
153 struct __sanitizer_group
{
160 typedef long __sanitizer_time_t
;
162 typedef long __sanitizer_suseconds_t
;
164 struct __sanitizer_timeval
{
165 __sanitizer_time_t tv_sec
;
166 __sanitizer_suseconds_t tv_usec
;
169 struct __sanitizer_itimerval
{
170 struct __sanitizer_timeval it_interval
;
171 struct __sanitizer_timeval it_value
;
174 struct __sanitizer_timeb
{
175 __sanitizer_time_t time
;
176 unsigned short millitm
;
181 struct __sanitizer_ether_addr
{
185 struct __sanitizer_tm
{
197 struct __sanitizer_msghdr
{
199 unsigned msg_namelen
;
200 struct __sanitizer_iovec
*msg_iov
;
203 unsigned msg_controllen
;
206 struct __sanitizer_cmsghdr
{
212 #if SANITIZER_SOLARIS && (defined(_LP64) || _FILE_OFFSET_BITS == 64)
213 struct __sanitizer_dirent
{
214 unsigned long long d_ino
;
216 unsigned short d_reclen
;
217 // more fields that we don't care about
220 struct __sanitizer_dirent
{
223 unsigned short d_reclen
;
224 // more fields that we don't care about
228 struct __sanitizer_dirent64
{
229 unsigned long long d_ino
;
230 unsigned long long d_off
;
231 unsigned short d_reclen
;
232 // more fields that we don't care about
235 typedef long __sanitizer_clock_t
;
236 typedef int __sanitizer_clockid_t
;
238 // This thing depends on the platform. We are only interested in the upper
239 // limit. Verified with a compiler assert in .cpp.
240 union __sanitizer_pthread_attr_t
{
245 struct __sanitizer_sigset_t
{
247 unsigned int __bits
[4];
250 struct __sanitizer_siginfo
{
251 // The size is determined by looking at sizeof of real siginfo_t on linux.
252 u64 opaque
[128 / sizeof(u64
)];
255 using __sanitizer_sighandler_ptr
= void (*)(int sig
);
256 using __sanitizer_sigactionhandler_ptr
=
257 void (*)(int sig
, __sanitizer_siginfo
*siginfo
, void *uctx
);
259 struct __sanitizer_sigaction
{
262 __sanitizer_sigactionhandler_ptr sigaction
;
263 __sanitizer_sighandler_ptr handler
;
265 __sanitizer_sigset_t sa_mask
;
271 struct __sanitizer_kernel_sigset_t
{
275 struct __sanitizer_kernel_sigaction_t
{
277 void (*handler
)(int signo
);
278 void (*sigaction
)(int signo
, __sanitizer_siginfo
*info
, void *ctx
);
280 unsigned long sa_flags
;
281 void (*sa_restorer
)(void);
282 __sanitizer_kernel_sigset_t sa_mask
;
285 extern const uptr sig_ign
;
286 extern const uptr sig_dfl
;
287 extern const uptr sig_err
;
288 extern const uptr sa_siginfo
;
292 uptr
__sanitizer_in_addr_sz(int af
);
294 struct __sanitizer_dl_phdr_info
{
296 const char *dlpi_name
;
297 const void *dlpi_phdr
;
301 extern unsigned struct_ElfW_Phdr_sz
;
303 struct __sanitizer_addrinfo
{
308 #if defined(__sparcv9)
314 struct __sanitizer_addrinfo
*ai_next
;
317 struct __sanitizer_hostent
{
325 struct __sanitizer_pollfd
{
331 typedef unsigned long __sanitizer_nfds_t
;
333 struct __sanitizer_glob_t
{
341 extern int glob_nomatch
;
342 extern int glob_altdirfunc
;
344 extern unsigned path_max
;
346 struct __sanitizer_wordexp_t
{
354 typedef void __sanitizer_FILE
;
355 #define SANITIZER_HAS_STRUCT_FILE 0
357 // This simplifies generic code
358 #define struct_shminfo_sz -1
359 #define struct_shm_info_sz -1
360 #define shmctl_shm_stat -1
361 #define shmctl_ipc_info -1
362 #define shmctl_shm_info -1
364 extern int shmctl_ipc_stat
;
366 extern unsigned struct_utmp_sz
;
367 extern unsigned struct_utmpx_sz
;
369 extern int map_fixed
;
372 struct __sanitizer_ifconf
{
381 #define IOC_TYPEBITS 8
382 #define IOC_SIZEBITS 12
383 #define IOC_DIRBITS 4
385 #define IOC_NONE 2U // IOC_VOID
386 #define IOC_READ 4U // IOC_OUT
387 #define IOC_WRITE 8U // IOC_IN
389 #define IOC_NRMASK ((1 << IOC_NRBITS) - 1)
390 #define IOC_TYPEMASK ((1 << IOC_TYPEBITS) - 1)
391 #define IOC_SIZEMASK ((1 << IOC_SIZEBITS) - 1)
392 #define IOC_DIRMASK ((1 << IOC_DIRBITS) - 1)
393 #define IOC_NRSHIFT 0
394 #define IOC_TYPESHIFT (IOC_NRSHIFT + IOC_NRBITS)
395 #define IOC_SIZESHIFT (IOC_TYPESHIFT + IOC_TYPEBITS)
396 #define IOC_DIRSHIFT (IOC_SIZESHIFT + IOC_SIZEBITS)
398 #define IOC_DIR(nr) (((nr) >> IOC_DIRSHIFT) & IOC_DIRMASK)
399 #define IOC_TYPE(nr) (((nr) >> IOC_TYPESHIFT) & IOC_TYPEMASK)
400 #define IOC_NR(nr) (((nr) >> IOC_NRSHIFT) & IOC_NRMASK)
402 #if defined(__sparc__)
403 // In sparc the 14 bits SIZE field overlaps with the
404 // least significant bit of DIR, so either IOC_READ or
405 // IOC_WRITE shall be 1 in order to get a non-zero SIZE.
406 #define IOC_SIZE(nr) \
407 ((((((nr) >> 29) & 0x7) & (4U | 2U)) == 0) ? 0 : (((nr) >> 16) & 0x3fff))
409 #define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK)
412 extern unsigned struct_ifreq_sz
;
413 extern unsigned struct_termios_sz
;
414 extern unsigned struct_winsize_sz
;
416 extern unsigned struct_sioc_sg_req_sz
;
417 extern unsigned struct_sioc_vif_req_sz
;
419 // ioctl request identifiers
421 // A special value to mark ioctls that are not present on the target platform,
422 // when it can not be determined without including any system headers.
423 extern const unsigned IOCTL_NOT_PRESENT
;
425 extern unsigned IOCTL_FIOASYNC
;
426 extern unsigned IOCTL_FIOCLEX
;
427 extern unsigned IOCTL_FIOGETOWN
;
428 extern unsigned IOCTL_FIONBIO
;
429 extern unsigned IOCTL_FIONCLEX
;
430 extern unsigned IOCTL_FIOSETOWN
;
431 extern unsigned IOCTL_SIOCADDMULTI
;
432 extern unsigned IOCTL_SIOCATMARK
;
433 extern unsigned IOCTL_SIOCDELMULTI
;
434 extern unsigned IOCTL_SIOCGIFADDR
;
435 extern unsigned IOCTL_SIOCGIFBRDADDR
;
436 extern unsigned IOCTL_SIOCGIFCONF
;
437 extern unsigned IOCTL_SIOCGIFDSTADDR
;
438 extern unsigned IOCTL_SIOCGIFFLAGS
;
439 extern unsigned IOCTL_SIOCGIFMETRIC
;
440 extern unsigned IOCTL_SIOCGIFMTU
;
441 extern unsigned IOCTL_SIOCGIFNETMASK
;
442 extern unsigned IOCTL_SIOCGPGRP
;
443 extern unsigned IOCTL_SIOCSIFADDR
;
444 extern unsigned IOCTL_SIOCSIFBRDADDR
;
445 extern unsigned IOCTL_SIOCSIFDSTADDR
;
446 extern unsigned IOCTL_SIOCSIFFLAGS
;
447 extern unsigned IOCTL_SIOCSIFMETRIC
;
448 extern unsigned IOCTL_SIOCSIFMTU
;
449 extern unsigned IOCTL_SIOCSIFNETMASK
;
450 extern unsigned IOCTL_SIOCSPGRP
;
451 extern unsigned IOCTL_TIOCEXCL
;
452 extern unsigned IOCTL_TIOCGETD
;
453 extern unsigned IOCTL_TIOCGPGRP
;
454 extern unsigned IOCTL_TIOCGWINSZ
;
455 extern unsigned IOCTL_TIOCMBIC
;
456 extern unsigned IOCTL_TIOCMBIS
;
457 extern unsigned IOCTL_TIOCMGET
;
458 extern unsigned IOCTL_TIOCMSET
;
459 extern unsigned IOCTL_TIOCNOTTY
;
460 extern unsigned IOCTL_TIOCNXCL
;
461 extern unsigned IOCTL_TIOCOUTQ
;
462 extern unsigned IOCTL_TIOCPKT
;
463 extern unsigned IOCTL_TIOCSCTTY
;
464 extern unsigned IOCTL_TIOCSETD
;
465 extern unsigned IOCTL_TIOCSPGRP
;
466 extern unsigned IOCTL_TIOCSTI
;
467 extern unsigned IOCTL_TIOCSWINSZ
;
468 extern unsigned IOCTL_MTIOCGET
;
469 extern unsigned IOCTL_MTIOCTOP
;
471 extern const int si_SEGV_MAPERR
;
472 extern const int si_SEGV_ACCERR
;
473 } // namespace __sanitizer
475 #define CHECK_TYPE_SIZE(TYPE) \
476 COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
478 #define CHECK_SIZE_AND_OFFSET(CLASS, MEMBER) \
479 COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *) NULL)->MEMBER) == \
480 sizeof(((CLASS *) NULL)->MEMBER)); \
481 COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) == \
482 offsetof(CLASS, MEMBER))
484 // For sigaction, which is a function and struct at the same time,
485 // and thus requires explicit "struct" in sizeof() expression.
486 #define CHECK_STRUCT_SIZE_AND_OFFSET(CLASS, MEMBER) \
487 COMPILER_CHECK(sizeof(((struct __sanitizer_##CLASS *) NULL)->MEMBER) == \
488 sizeof(((struct CLASS *) NULL)->MEMBER)); \
489 COMPILER_CHECK(offsetof(struct __sanitizer_##CLASS, MEMBER) == \
490 offsetof(struct CLASS, MEMBER))
492 #endif // SANITIZER_SOLARIS