Delete changes meant for a private branch.
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_platform_limits_solaris.h
blob77ae6e6a44dbd96dd00feaac6925ee1555579637
1 //===-- sanitizer_platform_limits_solaris.h -------------------------------===//
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 Solaris data structures.
12 //===----------------------------------------------------------------------===//
14 #ifndef SANITIZER_PLATFORM_LIMITS_SOLARIS_H
15 #define SANITIZER_PLATFORM_LIMITS_SOLARIS_H
17 #if SANITIZER_SOLARIS
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 {
52 //u64 data[6];
53 u32 sem_count;
54 u16 sem_type;
55 u16 sem_magic;
56 u64 sem_pad1[3];
57 u64 sem_pad2[2];
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
67 int key; // key_t
68 #if !defined(_LP64)
69 int pad[4];
70 #endif
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
82 #if defined(_LP64)
83 long shm_atime; // time_t
84 long shm_dtime;
85 long shm_ctime;
86 void *shm_amp;
87 u64 shm_gransize; // uint64_t
88 u64 shm_allocated; // uint64_t
89 u64 shm_pad4[1]; // int64_t
90 #else
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
96 void *shm_amp;
97 u64 shm_gransize; // uint64_t
98 u64 shm_allocated; // uint64_t
99 #endif
102 extern unsigned struct_statvfs_sz;
103 #if SANITIZER_SOLARIS32
104 extern unsigned struct_statvfs64_sz;
105 #endif
107 struct __sanitizer_iovec {
108 void *iov_base;
109 uptr iov_len;
112 struct __sanitizer_ifaddrs {
113 struct __sanitizer_ifaddrs *ifa_next;
114 char *ifa_name;
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.
119 # ifdef ifa_dstaddr
120 # undef ifa_dstaddr
121 # endif
122 void *ifa_dstaddr; // (struct sockaddr *)
123 void *ifa_data;
126 typedef unsigned __sanitizer_pthread_key_t;
128 struct __sanitizer_XDR {
129 int x_op;
130 void *x_ops;
131 uptr x_public;
132 uptr x_private;
133 uptr x_base;
134 unsigned x_handy;
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 {
142 char *pw_name;
143 char *pw_passwd;
144 unsigned int pw_uid; // uid_t
145 unsigned int pw_gid; // gid_t
146 char *pw_age;
147 char *pw_comment;
148 char *pw_gecos;
149 char *pw_dir;
150 char *pw_shell;
153 struct __sanitizer_group {
154 char *gr_name;
155 char *gr_passwd;
156 int gr_gid;
157 char **gr_mem;
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;
177 short timezone;
178 short dstflag;
181 struct __sanitizer_ether_addr {
182 u8 octet[6];
185 struct __sanitizer_tm {
186 int tm_sec;
187 int tm_min;
188 int tm_hour;
189 int tm_mday;
190 int tm_mon;
191 int tm_year;
192 int tm_wday;
193 int tm_yday;
194 int tm_isdst;
197 struct __sanitizer_msghdr {
198 void *msg_name;
199 unsigned msg_namelen;
200 struct __sanitizer_iovec *msg_iov;
201 unsigned msg_iovlen;
202 void *msg_control;
203 unsigned msg_controllen;
204 int msg_flags;
206 struct __sanitizer_cmsghdr {
207 unsigned cmsg_len;
208 int cmsg_level;
209 int cmsg_type;
212 #if SANITIZER_SOLARIS && (defined(_LP64) || _FILE_OFFSET_BITS == 64)
213 struct __sanitizer_dirent {
214 unsigned long long d_ino;
215 long long d_off;
216 unsigned short d_reclen;
217 // more fields that we don't care about
219 #else
220 struct __sanitizer_dirent {
221 unsigned long d_ino;
222 long d_off;
223 unsigned short d_reclen;
224 // more fields that we don't care about
226 #endif
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 {
241 char size[128];
242 void *align;
245 struct __sanitizer_sigset_t {
246 // uint32_t * 4
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 {
260 int sa_flags;
261 union {
262 __sanitizer_sigactionhandler_ptr sigaction;
263 __sanitizer_sighandler_ptr handler;
265 __sanitizer_sigset_t sa_mask;
266 #if !defined(_LP64)
267 int sa_resv[2];
268 #endif
271 struct __sanitizer_kernel_sigset_t {
272 u8 sig[8];
275 struct __sanitizer_kernel_sigaction_t {
276 union {
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;
290 extern int af_inet;
291 extern int af_inet6;
292 uptr __sanitizer_in_addr_sz(int af);
294 struct __sanitizer_dl_phdr_info {
295 uptr dlpi_addr;
296 const char *dlpi_name;
297 const void *dlpi_phdr;
298 short dlpi_phnum;
301 extern unsigned struct_ElfW_Phdr_sz;
303 struct __sanitizer_addrinfo {
304 int ai_flags;
305 int ai_family;
306 int ai_socktype;
307 int ai_protocol;
308 #if defined(__sparcv9)
309 int _ai_pad;
310 #endif
311 unsigned ai_addrlen;
312 char *ai_canonname;
313 void *ai_addr;
314 struct __sanitizer_addrinfo *ai_next;
317 struct __sanitizer_hostent {
318 char *h_name;
319 char **h_aliases;
320 int h_addrtype;
321 int h_length;
322 char **h_addr_list;
325 struct __sanitizer_pollfd {
326 int fd;
327 short events;
328 short revents;
331 typedef unsigned long __sanitizer_nfds_t;
333 struct __sanitizer_glob_t {
334 uptr gl_pathc;
335 char **gl_pathv;
336 uptr gl_offs;
337 char **gl_pathp;
338 int gl_pathn;
341 extern int glob_nomatch;
342 extern int glob_altdirfunc;
344 extern unsigned path_max;
346 struct __sanitizer_wordexp_t {
347 uptr we_wordc;
348 char **we_wordv;
349 uptr we_offs;
350 char **we_wordp;
351 int we_wordn;
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;
371 // ioctl arguments
372 struct __sanitizer_ifconf {
373 int ifc_len;
374 union {
375 void *ifcu_req;
376 } ifc_ifcu;
379 // <sys/ioccom.h>
380 #define IOC_NRBITS 8
381 #define IOC_TYPEBITS 8
382 #define IOC_SIZEBITS 12
383 #define IOC_DIRBITS 4
384 #undef IOC_NONE
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))
408 #else
409 #define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK)
410 #endif
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
494 #endif