1 //===-- sanitizer_platform_limits_openbsd.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 OpenBSD data structures.
12 //===----------------------------------------------------------------------===//
14 #ifndef SANITIZER_PLATFORM_LIMITS_OPENBSD_H
15 #define SANITIZER_PLATFORM_LIMITS_OPENBSD_H
19 #include "sanitizer_internal_defs.h"
20 #include "sanitizer_platform.h"
22 #define _GET_LINK_MAP_BY_DLOPEN_HANDLE(handle, shift) \
23 ((link_map *)((handle) == nullptr ? nullptr : ((char *)(handle) + (shift))))
25 #if defined(__x86_64__)
26 #define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \
27 _GET_LINK_MAP_BY_DLOPEN_HANDLE(handle, 312)
28 #elif defined(__i386__)
29 #define GET_LINK_MAP_BY_DLOPEN_HANDLE(handle) \
30 _GET_LINK_MAP_BY_DLOPEN_HANDLE(handle, 164)
33 #define RLIMIT_AS RLIMIT_DATA
35 namespace __sanitizer
{
36 extern unsigned struct_utsname_sz
;
37 extern unsigned struct_stat_sz
;
38 extern unsigned struct_rusage_sz
;
39 extern unsigned siginfo_t_sz
;
40 extern unsigned struct_itimerval_sz
;
41 extern unsigned pthread_t_sz
;
42 extern unsigned pthread_mutex_t_sz
;
43 extern unsigned pthread_cond_t_sz
;
44 extern unsigned pid_t_sz
;
45 extern unsigned timeval_sz
;
46 extern unsigned uid_t_sz
;
47 extern unsigned gid_t_sz
;
48 extern unsigned mbstate_t_sz
;
49 extern unsigned struct_timezone_sz
;
50 extern unsigned struct_tms_sz
;
51 extern unsigned struct_itimerspec_sz
;
52 extern unsigned struct_sigevent_sz
;
53 extern unsigned struct_statfs_sz
;
54 extern unsigned struct_sockaddr_sz
;
56 extern unsigned struct_rlimit_sz
;
57 extern unsigned struct_utimbuf_sz
;
58 extern unsigned struct_timespec_sz
;
60 struct __sanitizer_iocb
{
67 #if SANITIZER_WORDSIZE == 64
77 struct __sanitizer___sysctl_args
{
86 struct __sanitizer_sem_t
{
90 struct __sanitizer_ipc_perm
{
100 struct __sanitizer_shmid_ds
{
101 __sanitizer_ipc_perm shm_perm
;
107 long __shm_atimensec
;
109 long __shm_dtimensec
;
111 long __shm_ctimensec
;
115 extern unsigned struct_msqid_ds_sz
;
116 extern unsigned struct_mq_attr_sz
;
117 extern unsigned struct_timex_sz
;
118 extern unsigned struct_statvfs_sz
;
120 struct __sanitizer_iovec
{
125 struct __sanitizer_ifaddrs
{
126 struct __sanitizer_ifaddrs
*ifa_next
;
128 unsigned int ifa_flags
;
129 struct __sanitizer_sockaddr
*ifa_addr
; // (struct sockaddr *)
130 struct __sanitizer_sockaddr
*ifa_netmask
; // (struct sockaddr *)
131 struct __sanitizer_sockaddr
*ifa_dstaddr
; // (struct sockaddr *)
135 typedef unsigned __sanitizer_pthread_key_t
;
137 typedef long long __sanitizer_time_t
;
138 typedef int __sanitizer_suseconds_t
;
140 struct __sanitizer_timeval
{
141 __sanitizer_time_t tv_sec
;
142 __sanitizer_suseconds_t tv_usec
;
145 struct __sanitizer_itimerval
{
146 struct __sanitizer_timeval it_interval
;
147 struct __sanitizer_timeval it_value
;
150 struct __sanitizer_passwd
{
155 __sanitizer_time_t pw_change
;
160 __sanitizer_time_t pw_expire
;
163 struct __sanitizer_group
{
170 struct __sanitizer_ether_addr
{
174 struct __sanitizer_tm
{
188 struct __sanitizer_msghdr
{
190 unsigned msg_namelen
;
191 struct __sanitizer_iovec
*msg_iov
;
194 unsigned msg_controllen
;
197 struct __sanitizer_cmsghdr
{
203 struct __sanitizer_dirent
{
209 typedef u64 __sanitizer_clock_t
;
210 typedef u32 __sanitizer_clockid_t
;
212 typedef u32 __sanitizer___kernel_uid_t
;
213 typedef u32 __sanitizer___kernel_gid_t
;
214 typedef u64 __sanitizer___kernel_off_t
;
217 } __sanitizer___kernel_fd_set
;
220 unsigned int pta_magic
;
223 } __sanitizer_pthread_attr_t
;
225 typedef unsigned int __sanitizer_sigset_t
;
227 struct __sanitizer_siginfo
{
228 // The size is determined by looking at sizeof of real siginfo_t on linux.
229 u64 opaque
[128 / sizeof(u64
)];
232 using __sanitizer_sighandler_ptr
= void (*)(int sig
);
233 using __sanitizer_sigactionhandler_ptr
= void (*)(int sig
,
234 __sanitizer_siginfo
*siginfo
,
237 struct __sanitizer_sigaction
{
239 __sanitizer_sighandler_ptr handler
;
240 __sanitizer_sigactionhandler_ptr sigaction
;
242 __sanitizer_sigset_t sa_mask
;
246 typedef __sanitizer_sigset_t __sanitizer_kernel_sigset_t
;
248 struct __sanitizer_kernel_sigaction_t
{
250 void (*handler
)(int signo
);
251 void (*sigaction
)(int signo
, void *info
, void *ctx
);
253 unsigned long sa_flags
;
254 void (*sa_restorer
)(void);
255 __sanitizer_kernel_sigset_t sa_mask
;
258 extern const uptr sig_ign
;
259 extern const uptr sig_dfl
;
260 extern const uptr sig_err
;
261 extern const uptr sa_siginfo
;
265 uptr
__sanitizer_in_addr_sz(int af
);
267 struct __sanitizer_dl_phdr_info
{
268 #if SANITIZER_WORDSIZE == 64
273 const char *dlpi_name
;
274 const void *dlpi_phdr
;
275 #if SANITIZER_WORDSIZE == 64
282 extern unsigned struct_ElfW_Phdr_sz
;
284 struct __sanitizer_addrinfo
{
290 struct __sanitizer_sockaddr
*ai_addr
;
292 struct __sanitizer_addrinfo
*ai_next
;
295 struct __sanitizer_hostent
{
303 struct __sanitizer_pollfd
{
309 typedef unsigned __sanitizer_nfds_t
;
311 struct __sanitizer_glob_t
{
318 int (*gl_errfunc
)(const char *, int);
319 void (*gl_closedir
)(void *dirp
);
320 struct dirent
*(*gl_readdir
)(void *dirp
);
321 void *(*gl_opendir
)(const char *);
322 int (*gl_lstat
)(const char *, void * /* struct stat* */);
323 int (*gl_stat
)(const char *, void * /* struct stat* */);
326 extern int glob_nomatch
;
327 extern int glob_altdirfunc
;
329 extern unsigned path_max
;
331 typedef char __sanitizer_FILE
;
332 #define SANITIZER_HAS_STRUCT_FILE 0
334 extern int shmctl_ipc_stat
;
336 // This simplifies generic code
337 #define struct_shminfo_sz -1
338 #define struct_shm_info_sz -1
339 #define shmctl_shm_stat -1
340 #define shmctl_ipc_info -1
341 #define shmctl_shm_info -1
343 extern unsigned struct_utmp_sz
;
344 extern unsigned struct_utmpx_sz
;
346 extern int map_fixed
;
349 struct __sanitizer_ifconf
{
356 extern const int si_SEGV_MAPERR
;
357 extern const int si_SEGV_ACCERR
;
358 } // namespace __sanitizer
360 #define CHECK_TYPE_SIZE(TYPE) \
361 COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
363 #define CHECK_SIZE_AND_OFFSET(CLASS, MEMBER) \
364 COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *)NULL)->MEMBER) == \
365 sizeof(((CLASS *)NULL)->MEMBER)); \
366 COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) == \
367 offsetof(CLASS, MEMBER))
369 // For sigaction, which is a function and struct at the same time,
370 // and thus requires explicit "struct" in sizeof() expression.
371 #define CHECK_STRUCT_SIZE_AND_OFFSET(CLASS, MEMBER) \
372 COMPILER_CHECK(sizeof(((struct __sanitizer_##CLASS *)NULL)->MEMBER) == \
373 sizeof(((struct CLASS *)NULL)->MEMBER)); \
374 COMPILER_CHECK(offsetof(struct __sanitizer_##CLASS, MEMBER) == \
375 offsetof(struct CLASS, MEMBER))
377 #define SIGACTION_SYMNAME __sigaction14
379 #endif // SANITIZER_OPENBSD