1 2# Copyright (C) Igor Sysoev 3# Copyright (C) NGINX, Inc. 4 5 6# Linux 3.17 with glibc 2.25, FreeBSD 12, Solaris 11.3. 7 8nxt_feature="getrandom()" 9nxt_feature_name=NXT_HAVE_GETRANDOM 10nxt_feature_run=yes 11nxt_feature_incs= 12nxt_feature_libs= 13nxt_feature_test="#include <unistd.h> 14 #include <sys/random.h> 15 16 int main() { 17 char buf[4]; 18 19 if (getrandom(buf, 4, 0) < 0) { 20 return 1; 21 } 22 23 return 0; 24 }" 25. auto/feature 26 27 28if [ $nxt_found = no ]; then 29 30 # Linux 3.17 SYS_getrandom. 31 32 nxt_feature="SYS_getrandom in Linux" 33 nxt_feature_name=NXT_HAVE_LINUX_SYS_GETRANDOM 34 nxt_feature_test="#include <unistd.h> 35 #include <sys/syscall.h> 36 #include <linux/random.h> 37 38 int main() { 39 char buf[4]; 40 41 if (syscall(SYS_getrandom, buf, 4, 0) < 0) { 42 return 1; 43 } 44 45 return 0; 46 }" 47 . auto/feature 48fi 49 50 51if [ $nxt_found = no ]; then 52 53 # OpenBSD 5.6 lacks <sys/random.h>. 54 55 nxt_feature="getentropy()" 56 nxt_feature_name=NXT_HAVE_GETENTROPY 57 nxt_feature_test="#include <unistd.h> 58 59 int main() { 60 char buf[4]; 61 62 if (getentropy(buf, 4) == -1) { 63 return 1; 64 } 65 66 return 0; 67 }" 68 . auto/feature 69fi 70 71 72if [ $nxt_found = no ]; then 73 74 # macOS 10.12. 75 76 nxt_feature="getentropy() in sys/random.h" 77 nxt_feature_name=NXT_HAVE_GETENTROPY_SYS_RANDOM 78 nxt_feature_test="#include <unistd.h> 79 #include <sys/random.h> 80 81 int main() { 82 char buf[4]; 83 84 if (getentropy(buf, 4) == -1) { 85 return 1; 86 } 87 88 return 0; 89 }" 90 . auto/feature 91fi 92 93 94nxt_feature="ucontext" 95nxt_feature_name=NXT_HAVE_UCONTEXT 96nxt_feature_run= 97nxt_feature_incs= 98nxt_feature_libs= 99nxt_feature_test="#include <stdlib.h> 100 #include <ucontext.h> 101 102 int main() { 103 ucontext_t uc; 104 105 if (getcontext(&uc) == 0) { 106 makecontext(&uc, NULL, 0); 107 setcontext(&uc); 108 } 109 110 return 0; 111 }" 112. auto/feature 113 114 115if [ $nxt_found = no ]; then 116 117 # MacOSX 10.6 (Snow Leopard) has deprecated ucontext 118 # and requires _XOPEN_SOURCE to be defined. 119 120 nxt_feature="_XOPEN_SOURCE ucontext" 121 nxt_feature_name=NXT_HAVE_UCONTEXT 122 nxt_feature_run= 123 nxt_feature_incs= 124 nxt_feature_libs= 125 nxt_feature_test="#define _XOPEN_SOURCE 126 #include <stdlib.h> 127 #include <ucontext.h> 128 129 int main() { 130 ucontext_t uc; 131 132 if (getcontext(&uc) == 0) { 133 makecontext(&uc, NULL, 0); 134 setcontext(&uc); 135 } 136 137 return 0; 138 }" 139 . auto/feature 140fi 141 142 143# FreeBSD dlopen() is in libc. 144# MacOSX libdl.dylib is a symlink to libSystem.dylib. 145# GCC5 AddressSanitizer intercepts dlopen() and dlclose() but not dlsym() 146# so all dynamic linker functions should be tested. 147 148NXT_LIBDL= 149 150nxt_feature="dlopen()" 151nxt_feature_name=NXT_HAVE_DLOPEN 152nxt_feature_run= 153nxt_feature_incs= 154nxt_feature_libs= 155nxt_feature_test="#include <stdlib.h> 156 #include <dlfcn.h> 157 158 int main() { 159 void *h = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL); 160 dlsym(h, \"\"); 161 dlclose(h); 162 return 0; 163 }" 164. auto/feature 165 166if [ $nxt_found = no ]; then 167 168 # Linux and Solaris prior to 10 require libdl. 169 # Solaris 10 libdl.so.1 is a filter to /usr/lib/ld.so.1. 170 171 nxt_feature="dlopen() in libdl" 172 nxt_feature_libs="-ldl" 173 . auto/feature 174 175 if [ $nxt_found = yes ]; then 176 NXT_LIBDL="-ldl" 177 fi 178fi 179 180 181nxt_feature="posix_spawn()" 182nxt_feature_name=NXT_HAVE_POSIX_SPAWN 183nxt_feature_run= 184nxt_feature_incs= 185nxt_feature_libs= 186nxt_feature_test="#include <spawn.h> 187 #include <unistd.h> 188 189 int main() { 190 (void) posix_spawn(NULL, NULL, NULL, NULL, NULL, NULL); 191 return 0; 192 }" 193. auto/feature 194 195 196# NetBSD 1.0, OpenBSD 1.0, FreeBSD 2.2 setproctitle(). 197 198nxt_feature="setproctitle()" 199nxt_feature_name=NXT_HAVE_SETPROCTITLE 200nxt_feature_run= 201nxt_feature_incs= 202nxt_feature_libs= 203nxt_feature_test="#include <stdlib.h> 204 #include <unistd.h> 205 206 int main() { 207 setproctitle(\"%s\", \"title\"); 208 return 0; 209 }" 210. auto/feature 211