testsuite: multiline.exp: implement optional target/xfail selector
[official-gcc.git] / libsanitizer / sanitizer_common / sanitizer_platform_limits_netbsd.cc
blob3c18ca6ce25a89137cbcf5c2a7e79796fa44e88c
1 //===-- sanitizer_platform_limits_netbsd.cc -------------------------------===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of Sanitizer common code.
9 //
10 // Sizes and layouts of platform-specific NetBSD data structures.
11 //===----------------------------------------------------------------------===//
13 #include "sanitizer_platform.h"
15 #if SANITIZER_NETBSD
16 #include <arpa/inet.h>
17 #include <dirent.h>
18 #include <glob.h>
19 #include <grp.h>
20 #include <ifaddrs.h>
21 #include <limits.h>
22 #include <link_elf.h>
23 #include <net/if.h>
24 #include <net/if_ether.h>
25 #include <net/ppp_defs.h>
26 #include <net/route.h>
27 #include <netdb.h>
28 #include <netinet/in.h>
29 #include <netinet/ip_mroute.h>
30 #include <poll.h>
31 #include <pthread.h>
32 #include <pwd.h>
33 #include <semaphore.h>
34 #include <signal.h>
35 #include <stddef.h>
36 #include <sys/filio.h>
37 #include <sys/ipc.h>
38 #include <sys/mman.h>
39 #include <sys/mount.h>
40 #include <sys/mqueue.h>
41 #include <sys/msg.h>
42 #include <sys/mtio.h>
43 #include <sys/ptrace.h>
44 #include <sys/resource.h>
45 #include <sys/shm.h>
46 #include <sys/signal.h>
47 #include <sys/socket.h>
48 #include <sys/sockio.h>
49 #include <sys/soundcard.h>
50 #include <sys/stat.h>
51 #include <sys/statvfs.h>
52 #include <sys/time.h>
53 #include <sys/timeb.h>
54 #include <sys/times.h>
55 #include <sys/timespec.h>
56 #include <sys/timex.h>
57 #include <sys/types.h>
58 #include <sys/ucontext.h>
59 #include <sys/utsname.h>
60 #include <term.h>
61 #include <termios.h>
62 #include <time.h>
63 #include <utime.h>
64 #include <utmp.h>
65 #include <utmpx.h>
66 #include <wchar.h>
67 #include <wordexp.h>
69 // Include these after system headers to avoid name clashes and ambiguities.
70 #include "sanitizer_internal_defs.h"
71 #include "sanitizer_platform_limits_netbsd.h"
73 namespace __sanitizer {
74 unsigned struct_utsname_sz = sizeof(struct utsname);
75 unsigned struct_stat_sz = sizeof(struct stat);
76 unsigned struct_rusage_sz = sizeof(struct rusage);
77 unsigned struct_tm_sz = sizeof(struct tm);
78 unsigned struct_passwd_sz = sizeof(struct passwd);
79 unsigned struct_group_sz = sizeof(struct group);
80 unsigned siginfo_t_sz = sizeof(siginfo_t);
81 unsigned struct_sigaction_sz = sizeof(struct sigaction);
82 unsigned struct_itimerval_sz = sizeof(struct itimerval);
83 unsigned pthread_t_sz = sizeof(pthread_t);
84 unsigned pthread_cond_t_sz = sizeof(pthread_cond_t);
85 unsigned pid_t_sz = sizeof(pid_t);
86 unsigned timeval_sz = sizeof(timeval);
87 unsigned uid_t_sz = sizeof(uid_t);
88 unsigned gid_t_sz = sizeof(gid_t);
89 unsigned mbstate_t_sz = sizeof(mbstate_t);
90 unsigned sigset_t_sz = sizeof(sigset_t);
91 unsigned struct_timezone_sz = sizeof(struct timezone);
92 unsigned struct_tms_sz = sizeof(struct tms);
93 unsigned struct_sigevent_sz = sizeof(struct sigevent);
94 unsigned struct_sched_param_sz = sizeof(struct sched_param);
95 unsigned struct_sockaddr_sz = sizeof(struct sockaddr);
96 unsigned ucontext_t_sz = sizeof(ucontext_t);
97 unsigned struct_rlimit_sz = sizeof(struct rlimit);
98 unsigned struct_timespec_sz = sizeof(struct timespec);
99 unsigned struct_utimbuf_sz = sizeof(struct utimbuf);
100 unsigned struct_itimerspec_sz = sizeof(struct itimerspec);
101 unsigned struct_timex_sz = sizeof(struct timex);
102 unsigned struct_msqid_ds_sz = sizeof(struct msqid_ds);
103 unsigned struct_mq_attr_sz = sizeof(struct mq_attr);
104 unsigned struct_statvfs_sz = sizeof(struct statvfs);
106 uptr sig_ign = (uptr)SIG_IGN;
107 uptr sig_dfl = (uptr)SIG_DFL;
108 uptr sa_siginfo = (uptr)SA_SIGINFO;
110 int shmctl_ipc_stat = (int)IPC_STAT;
112 unsigned struct_utmp_sz = sizeof(struct utmp);
113 unsigned struct_utmpx_sz = sizeof(struct utmpx);
115 int map_fixed = MAP_FIXED;
117 int af_inet = (int)AF_INET;
118 int af_inet6 = (int)AF_INET6;
120 uptr __sanitizer_in_addr_sz(int af) {
121 if (af == AF_INET)
122 return sizeof(struct in_addr);
123 else if (af == AF_INET6)
124 return sizeof(struct in6_addr);
125 else
126 return 0;
129 int glob_nomatch = GLOB_NOMATCH;
130 int glob_altdirfunc = GLOB_ALTDIRFUNC;
132 unsigned path_max = PATH_MAX;
134 // ioctl arguments
135 unsigned struct_ifreq_sz = sizeof(struct ifreq);
136 unsigned struct_termios_sz = sizeof(struct termios);
137 unsigned struct_winsize_sz = sizeof(struct winsize);
138 unsigned struct_mtget_sz = sizeof(struct mtget);
139 unsigned struct_mtop_sz = sizeof(struct mtop);
140 unsigned struct_audio_buf_info_sz = sizeof(struct audio_buf_info);
141 unsigned struct_ppp_stats_sz = sizeof(struct ppp_stats);
142 unsigned struct_sioc_sg_req_sz = sizeof(struct sioc_sg_req);
143 unsigned struct_sioc_vif_req_sz = sizeof(struct sioc_vif_req);
145 const unsigned IOCTL_NOT_PRESENT = 0;
147 unsigned IOCTL_FIOASYNC = FIOASYNC;
148 unsigned IOCTL_FIOCLEX = FIOCLEX;
149 unsigned IOCTL_FIOGETOWN = FIOGETOWN;
150 unsigned IOCTL_FIONBIO = FIONBIO;
151 unsigned IOCTL_FIONCLEX = FIONCLEX;
152 unsigned IOCTL_FIOSETOWN = FIOSETOWN;
153 unsigned IOCTL_SIOCADDMULTI = SIOCADDMULTI;
154 unsigned IOCTL_SIOCATMARK = SIOCATMARK;
155 unsigned IOCTL_SIOCDELMULTI = SIOCDELMULTI;
156 unsigned IOCTL_SIOCGIFADDR = SIOCGIFADDR;
157 unsigned IOCTL_SIOCGIFBRDADDR = SIOCGIFBRDADDR;
158 unsigned IOCTL_SIOCGIFCONF = SIOCGIFCONF;
159 unsigned IOCTL_SIOCGIFDSTADDR = SIOCGIFDSTADDR;
160 unsigned IOCTL_SIOCGIFFLAGS = SIOCGIFFLAGS;
161 unsigned IOCTL_SIOCGIFMETRIC = SIOCGIFMETRIC;
162 unsigned IOCTL_SIOCGIFMTU = SIOCGIFMTU;
163 unsigned IOCTL_SIOCGIFNETMASK = SIOCGIFNETMASK;
164 unsigned IOCTL_SIOCGPGRP = SIOCGPGRP;
165 unsigned IOCTL_SIOCSIFADDR = SIOCSIFADDR;
166 unsigned IOCTL_SIOCSIFBRDADDR = SIOCSIFBRDADDR;
167 unsigned IOCTL_SIOCSIFDSTADDR = SIOCSIFDSTADDR;
168 unsigned IOCTL_SIOCSIFFLAGS = SIOCSIFFLAGS;
169 unsigned IOCTL_SIOCSIFMETRIC = SIOCSIFMETRIC;
170 unsigned IOCTL_SIOCSIFMTU = SIOCSIFMTU;
171 unsigned IOCTL_SIOCSIFNETMASK = SIOCSIFNETMASK;
172 unsigned IOCTL_SIOCSPGRP = SIOCSPGRP;
173 unsigned IOCTL_TIOCCONS = TIOCCONS;
174 unsigned IOCTL_TIOCEXCL = TIOCEXCL;
175 unsigned IOCTL_TIOCGETD = TIOCGETD;
176 unsigned IOCTL_TIOCGPGRP = TIOCGPGRP;
177 unsigned IOCTL_TIOCGWINSZ = TIOCGWINSZ;
178 unsigned IOCTL_TIOCMBIC = TIOCMBIC;
179 unsigned IOCTL_TIOCMBIS = TIOCMBIS;
180 unsigned IOCTL_TIOCMGET = TIOCMGET;
181 unsigned IOCTL_TIOCMSET = TIOCMSET;
182 unsigned IOCTL_TIOCNOTTY = TIOCNOTTY;
183 unsigned IOCTL_TIOCNXCL = TIOCNXCL;
184 unsigned IOCTL_TIOCOUTQ = TIOCOUTQ;
185 unsigned IOCTL_TIOCPKT = TIOCPKT;
186 unsigned IOCTL_TIOCSCTTY = TIOCSCTTY;
187 unsigned IOCTL_TIOCSETD = TIOCSETD;
188 unsigned IOCTL_TIOCSPGRP = TIOCSPGRP;
189 unsigned IOCTL_TIOCSTI = TIOCSTI;
190 unsigned IOCTL_TIOCSWINSZ = TIOCSWINSZ;
191 unsigned IOCTL_SIOCGETSGCNT = SIOCGETSGCNT;
192 unsigned IOCTL_SIOCGETVIFCNT = SIOCGETVIFCNT;
194 const int si_SEGV_MAPERR = SEGV_MAPERR;
195 const int si_SEGV_ACCERR = SEGV_ACCERR;
196 } // namespace __sanitizer
198 using namespace __sanitizer;
200 COMPILER_CHECK(sizeof(__sanitizer_pthread_attr_t) >= sizeof(pthread_attr_t));
202 COMPILER_CHECK(sizeof(socklen_t) == sizeof(unsigned));
203 CHECK_TYPE_SIZE(pthread_key_t);
205 // There are more undocumented fields in dl_phdr_info that we are not interested
206 // in.
207 COMPILER_CHECK(sizeof(__sanitizer_dl_phdr_info) <= sizeof(dl_phdr_info));
208 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_addr);
209 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_name);
210 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phdr);
211 CHECK_SIZE_AND_OFFSET(dl_phdr_info, dlpi_phnum);
213 CHECK_TYPE_SIZE(glob_t);
214 CHECK_SIZE_AND_OFFSET(glob_t, gl_pathc);
215 CHECK_SIZE_AND_OFFSET(glob_t, gl_pathv);
216 CHECK_SIZE_AND_OFFSET(glob_t, gl_offs);
217 CHECK_SIZE_AND_OFFSET(glob_t, gl_flags);
218 CHECK_SIZE_AND_OFFSET(glob_t, gl_closedir);
219 CHECK_SIZE_AND_OFFSET(glob_t, gl_readdir);
220 CHECK_SIZE_AND_OFFSET(glob_t, gl_opendir);
221 CHECK_SIZE_AND_OFFSET(glob_t, gl_lstat);
222 CHECK_SIZE_AND_OFFSET(glob_t, gl_stat);
224 CHECK_TYPE_SIZE(addrinfo);
225 CHECK_SIZE_AND_OFFSET(addrinfo, ai_flags);
226 CHECK_SIZE_AND_OFFSET(addrinfo, ai_family);
227 CHECK_SIZE_AND_OFFSET(addrinfo, ai_socktype);
228 CHECK_SIZE_AND_OFFSET(addrinfo, ai_protocol);
229 CHECK_SIZE_AND_OFFSET(addrinfo, ai_protocol);
230 CHECK_SIZE_AND_OFFSET(addrinfo, ai_addrlen);
231 CHECK_SIZE_AND_OFFSET(addrinfo, ai_canonname);
232 CHECK_SIZE_AND_OFFSET(addrinfo, ai_addr);
234 CHECK_TYPE_SIZE(hostent);
235 CHECK_SIZE_AND_OFFSET(hostent, h_name);
236 CHECK_SIZE_AND_OFFSET(hostent, h_aliases);
237 CHECK_SIZE_AND_OFFSET(hostent, h_addrtype);
238 CHECK_SIZE_AND_OFFSET(hostent, h_length);
239 CHECK_SIZE_AND_OFFSET(hostent, h_addr_list);
241 CHECK_TYPE_SIZE(iovec);
242 CHECK_SIZE_AND_OFFSET(iovec, iov_base);
243 CHECK_SIZE_AND_OFFSET(iovec, iov_len);
245 CHECK_TYPE_SIZE(msghdr);
246 CHECK_SIZE_AND_OFFSET(msghdr, msg_name);
247 CHECK_SIZE_AND_OFFSET(msghdr, msg_namelen);
248 CHECK_SIZE_AND_OFFSET(msghdr, msg_iov);
249 CHECK_SIZE_AND_OFFSET(msghdr, msg_iovlen);
250 CHECK_SIZE_AND_OFFSET(msghdr, msg_control);
251 CHECK_SIZE_AND_OFFSET(msghdr, msg_controllen);
252 CHECK_SIZE_AND_OFFSET(msghdr, msg_flags);
254 CHECK_TYPE_SIZE(cmsghdr);
255 CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_len);
256 CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_level);
257 CHECK_SIZE_AND_OFFSET(cmsghdr, cmsg_type);
259 COMPILER_CHECK(sizeof(__sanitizer_dirent) <= sizeof(dirent));
260 CHECK_SIZE_AND_OFFSET(dirent, d_fileno);
261 CHECK_SIZE_AND_OFFSET(dirent, d_reclen);
263 CHECK_TYPE_SIZE(ifconf);
264 CHECK_SIZE_AND_OFFSET(ifconf, ifc_len);
265 CHECK_SIZE_AND_OFFSET(ifconf, ifc_ifcu);
267 CHECK_TYPE_SIZE(pollfd);
268 CHECK_SIZE_AND_OFFSET(pollfd, fd);
269 CHECK_SIZE_AND_OFFSET(pollfd, events);
270 CHECK_SIZE_AND_OFFSET(pollfd, revents);
272 CHECK_TYPE_SIZE(nfds_t);
274 CHECK_TYPE_SIZE(sigset_t);
276 COMPILER_CHECK(sizeof(__sanitizer_sigaction) == sizeof(struct sigaction));
277 // Can't write checks for sa_handler and sa_sigaction due to them being
278 // preprocessor macros.
279 CHECK_STRUCT_SIZE_AND_OFFSET(sigaction, sa_mask);
281 CHECK_TYPE_SIZE(wordexp_t);
282 CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordc);
283 CHECK_SIZE_AND_OFFSET(wordexp_t, we_wordv);
284 CHECK_SIZE_AND_OFFSET(wordexp_t, we_offs);
286 CHECK_TYPE_SIZE(tm);
287 CHECK_SIZE_AND_OFFSET(tm, tm_sec);
288 CHECK_SIZE_AND_OFFSET(tm, tm_min);
289 CHECK_SIZE_AND_OFFSET(tm, tm_hour);
290 CHECK_SIZE_AND_OFFSET(tm, tm_mday);
291 CHECK_SIZE_AND_OFFSET(tm, tm_mon);
292 CHECK_SIZE_AND_OFFSET(tm, tm_year);
293 CHECK_SIZE_AND_OFFSET(tm, tm_wday);
294 CHECK_SIZE_AND_OFFSET(tm, tm_yday);
295 CHECK_SIZE_AND_OFFSET(tm, tm_isdst);
296 CHECK_SIZE_AND_OFFSET(tm, tm_gmtoff);
297 CHECK_SIZE_AND_OFFSET(tm, tm_zone);
299 CHECK_TYPE_SIZE(ether_addr);
301 CHECK_TYPE_SIZE(ipc_perm);
302 CHECK_SIZE_AND_OFFSET(ipc_perm, _key);
303 CHECK_SIZE_AND_OFFSET(ipc_perm, _seq);
304 CHECK_SIZE_AND_OFFSET(ipc_perm, uid);
305 CHECK_SIZE_AND_OFFSET(ipc_perm, gid);
306 CHECK_SIZE_AND_OFFSET(ipc_perm, cuid);
307 CHECK_SIZE_AND_OFFSET(ipc_perm, cgid);
308 CHECK_SIZE_AND_OFFSET(ipc_perm, mode);
310 CHECK_TYPE_SIZE(shmid_ds);
311 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_perm);
312 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_segsz);
313 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_atime);
314 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_dtime);
315 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_ctime);
316 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_cpid);
317 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_lpid);
318 CHECK_SIZE_AND_OFFSET(shmid_ds, shm_nattch);
320 CHECK_TYPE_SIZE(clock_t);
322 CHECK_TYPE_SIZE(ifaddrs);
323 CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_next);
324 CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_name);
325 CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_addr);
326 CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_netmask);
327 // Compare against the union, because we can't reach into the union in a
328 // compliant way.
329 #ifdef ifa_dstaddr
330 #undef ifa_dstaddr
331 #endif
332 CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_dstaddr);
333 CHECK_SIZE_AND_OFFSET(ifaddrs, ifa_data);
335 CHECK_TYPE_SIZE(timeb);
336 CHECK_SIZE_AND_OFFSET(timeb, time);
337 CHECK_SIZE_AND_OFFSET(timeb, millitm);
338 CHECK_SIZE_AND_OFFSET(timeb, timezone);
339 CHECK_SIZE_AND_OFFSET(timeb, dstflag);
341 CHECK_TYPE_SIZE(passwd);
342 CHECK_SIZE_AND_OFFSET(passwd, pw_name);
343 CHECK_SIZE_AND_OFFSET(passwd, pw_passwd);
344 CHECK_SIZE_AND_OFFSET(passwd, pw_uid);
345 CHECK_SIZE_AND_OFFSET(passwd, pw_gid);
346 CHECK_SIZE_AND_OFFSET(passwd, pw_dir);
347 CHECK_SIZE_AND_OFFSET(passwd, pw_shell);
349 CHECK_SIZE_AND_OFFSET(passwd, pw_gecos);
351 CHECK_TYPE_SIZE(group);
352 CHECK_SIZE_AND_OFFSET(group, gr_name);
353 CHECK_SIZE_AND_OFFSET(group, gr_passwd);
354 CHECK_SIZE_AND_OFFSET(group, gr_gid);
355 CHECK_SIZE_AND_OFFSET(group, gr_mem);
357 #endif // SANITIZER_NETBSD