1 /* $OpenBSD: macros.h,v 1.1 2020/02/28 12:48:30 mpi Exp $ */ 2 /* Public domain - Moritz Buhl */ 3 4 #include <sys/param.h> 5 #include <sys/socket.h> 6 #include <sys/stdint.h> 7 #include <sys/sysctl.h> 8 #include <sys/types.h> 9 10 #include <stdbool.h> 11 #include <string.h> 12 #include <stdio.h> 13 14 #define __FBSDID(str) 15 #define __RCSID(str) 16 #define __COPYRIGHT(str) 17 18 #define __arraycount(_a) nitems(_a) 19 #define __unreachable() atf_tc_fail("unreachable") 20 #define __UNCONST(a) (a) 21 22 #define __dead2 __dead 23 24 /* t_chroot.c */ 25 #define fchroot(fd) 0 26 27 /* t_clock_gettime.c */ 28 int sysctlbyname(char *, void *, size_t *, void *, size_t); 29 30 int 31 sysctlbyname(char* s, void *oldp, size_t *oldlenp, void *newp, size_t newlen) 32 { 33 int mib[3], miblen; 34 35 mib[0] = CTL_KERN; 36 if (strcmp(s, "kern.timecounter.hardware") == 0) { 37 mib[1] = KERN_TIMECOUNTER; 38 mib[2] = KERN_TIMECOUNTER_HARDWARE; 39 miblen = 3; 40 } else if (strcmp(s, "kern.timecounter.choice") == 0) { 41 mib[1] = KERN_TIMECOUNTER; 42 mib[2] = KERN_TIMECOUNTER_CHOICE; 43 miblen = 3; 44 } else if (strcmp(s, "kern.securelevel") == 0) { 45 mib[1] = KERN_SECURELVL; 46 miblen = 2; 47 } else { 48 fprintf(stderr, "%s(): mib '%s' not supported\n", __func__, s); 49 return -42; 50 } 51 52 return sysctl(mib, miblen, oldp, oldlenp, newp, newlen); 53 } 54 55 /* t_mlock.c */ 56 #define MAP_WIRED __MAP_NOREPLACE 57 58 /* t_pipe2.c */ 59 #define O_NOSIGPIPE 0 60 61 /* t_poll.c */ 62 #define pollts(a, b, c, e) 0 63 64 /* t_sendrecv.c */ 65 #define SO_RERROR SO_DEBUG 66 67 /* t_write.c */ 68 #define _PATH_DEVZERO "/dev/zero" 69