10Sigor@sysoev.ru 20Sigor@sysoev.ru# Copyright (C) Igor Sysoev 30Sigor@sysoev.ru# Copyright (C) NGINX, Inc. 40Sigor@sysoev.ru 50Sigor@sysoev.ru 6732Spluknet@nginx.com# Linux 3.17 with glibc 2.25, FreeBSD 12, Solaris 11.3. 70Sigor@sysoev.ru 80Sigor@sysoev.runxt_feature="getrandom()" 90Sigor@sysoev.runxt_feature_name=NXT_HAVE_GETRANDOM 10676Spluknet@nginx.comnxt_feature_run=yes 110Sigor@sysoev.runxt_feature_incs= 120Sigor@sysoev.runxt_feature_libs= 13676Spluknet@nginx.comnxt_feature_test="#include <unistd.h> 14676Spluknet@nginx.com #include <sys/random.h> 150Sigor@sysoev.ru 160Sigor@sysoev.ru int main() { 170Sigor@sysoev.ru char buf[4]; 180Sigor@sysoev.ru 19676Spluknet@nginx.com if (getrandom(buf, 4, 0) < 0) { 20676Spluknet@nginx.com return 1; 21676Spluknet@nginx.com } 220Sigor@sysoev.ru 230Sigor@sysoev.ru return 0; 240Sigor@sysoev.ru }" 250Sigor@sysoev.ru. auto/feature 260Sigor@sysoev.ru 270Sigor@sysoev.ru 28676Spluknet@nginx.comif [ $nxt_found = no ]; then 29676Spluknet@nginx.com 30676Spluknet@nginx.com # Linux 3.17 SYS_getrandom. 31676Spluknet@nginx.com 32676Spluknet@nginx.com nxt_feature="SYS_getrandom in Linux" 33676Spluknet@nginx.com nxt_feature_name=NXT_HAVE_LINUX_SYS_GETRANDOM 34676Spluknet@nginx.com nxt_feature_test="#include <unistd.h> 35676Spluknet@nginx.com #include <sys/syscall.h> 36676Spluknet@nginx.com #include <linux/random.h> 37676Spluknet@nginx.com 38676Spluknet@nginx.com int main() { 39676Spluknet@nginx.com char buf[4]; 40676Spluknet@nginx.com 41676Spluknet@nginx.com if (syscall(SYS_getrandom, buf, 4, 0) < 0) { 42676Spluknet@nginx.com return 1; 43676Spluknet@nginx.com } 44676Spluknet@nginx.com 45676Spluknet@nginx.com return 0; 46676Spluknet@nginx.com }" 47676Spluknet@nginx.com . auto/feature 48676Spluknet@nginx.comfi 49676Spluknet@nginx.com 50676Spluknet@nginx.com 51733Spluknet@nginx.comif [ $nxt_found = no ]; then 52733Spluknet@nginx.com 53733Spluknet@nginx.com # OpenBSD 5.6 lacks <sys/random.h>. 54733Spluknet@nginx.com 55733Spluknet@nginx.com nxt_feature="getentropy()" 56733Spluknet@nginx.com nxt_feature_name=NXT_HAVE_GETENTROPY 57733Spluknet@nginx.com nxt_feature_test="#include <unistd.h> 58733Spluknet@nginx.com 59733Spluknet@nginx.com int main() { 60733Spluknet@nginx.com char buf[4]; 61733Spluknet@nginx.com 62733Spluknet@nginx.com if (getentropy(buf, 4) == -1) { 63733Spluknet@nginx.com return 1; 64733Spluknet@nginx.com } 65733Spluknet@nginx.com 66733Spluknet@nginx.com return 0; 67733Spluknet@nginx.com }" 68733Spluknet@nginx.com . auto/feature 69733Spluknet@nginx.comfi 70733Spluknet@nginx.com 71733Spluknet@nginx.com 72733Spluknet@nginx.comif [ $nxt_found = no ]; then 73733Spluknet@nginx.com 74733Spluknet@nginx.com # macOS 10.12. 75733Spluknet@nginx.com 76733Spluknet@nginx.com nxt_feature="getentropy() in sys/random.h" 77733Spluknet@nginx.com nxt_feature_name=NXT_HAVE_GETENTROPY_SYS_RANDOM 78733Spluknet@nginx.com nxt_feature_test="#include <unistd.h> 79733Spluknet@nginx.com #include <sys/random.h> 80733Spluknet@nginx.com 81733Spluknet@nginx.com int main() { 82733Spluknet@nginx.com char buf[4]; 83733Spluknet@nginx.com 84733Spluknet@nginx.com if (getentropy(buf, 4) == -1) { 85733Spluknet@nginx.com return 1; 86733Spluknet@nginx.com } 87733Spluknet@nginx.com 88733Spluknet@nginx.com return 0; 89733Spluknet@nginx.com }" 90733Spluknet@nginx.com . auto/feature 91733Spluknet@nginx.comfi 92733Spluknet@nginx.com 93733Spluknet@nginx.com 940Sigor@sysoev.runxt_feature="ucontext" 950Sigor@sysoev.runxt_feature_name=NXT_HAVE_UCONTEXT 960Sigor@sysoev.runxt_feature_run= 970Sigor@sysoev.runxt_feature_incs= 980Sigor@sysoev.runxt_feature_libs= 990Sigor@sysoev.runxt_feature_test="#include <stdlib.h> 1000Sigor@sysoev.ru #include <ucontext.h> 1010Sigor@sysoev.ru 1020Sigor@sysoev.ru int main() { 1030Sigor@sysoev.ru ucontext_t uc; 1040Sigor@sysoev.ru 1050Sigor@sysoev.ru if (getcontext(&uc) == 0) { 1060Sigor@sysoev.ru makecontext(&uc, NULL, 0); 1070Sigor@sysoev.ru setcontext(&uc); 1080Sigor@sysoev.ru } 1090Sigor@sysoev.ru 1100Sigor@sysoev.ru return 0; 1110Sigor@sysoev.ru }" 1120Sigor@sysoev.ru. auto/feature 1130Sigor@sysoev.ru 1140Sigor@sysoev.ru 1150Sigor@sysoev.ruif [ $nxt_found = no ]; then 1160Sigor@sysoev.ru 1170Sigor@sysoev.ru # MacOSX 10.6 (Snow Leopard) has deprecated ucontext 1180Sigor@sysoev.ru # and requires _XOPEN_SOURCE to be defined. 1190Sigor@sysoev.ru 1200Sigor@sysoev.ru nxt_feature="_XOPEN_SOURCE ucontext" 1210Sigor@sysoev.ru nxt_feature_name=NXT_HAVE_UCONTEXT 1220Sigor@sysoev.ru nxt_feature_run= 1230Sigor@sysoev.ru nxt_feature_incs= 1240Sigor@sysoev.ru nxt_feature_libs= 1250Sigor@sysoev.ru nxt_feature_test="#define _XOPEN_SOURCE 1260Sigor@sysoev.ru #include <stdlib.h> 1270Sigor@sysoev.ru #include <ucontext.h> 1280Sigor@sysoev.ru 1290Sigor@sysoev.ru int main() { 1300Sigor@sysoev.ru ucontext_t uc; 1310Sigor@sysoev.ru 1320Sigor@sysoev.ru if (getcontext(&uc) == 0) { 1330Sigor@sysoev.ru makecontext(&uc, NULL, 0); 1340Sigor@sysoev.ru setcontext(&uc); 1350Sigor@sysoev.ru } 1360Sigor@sysoev.ru 1370Sigor@sysoev.ru return 0; 1380Sigor@sysoev.ru }" 1390Sigor@sysoev.ru . auto/feature 1400Sigor@sysoev.rufi 1410Sigor@sysoev.ru 1420Sigor@sysoev.ru 1430Sigor@sysoev.ru# FreeBSD dlopen() is in libc. 1440Sigor@sysoev.ru# MacOSX libdl.dylib is a symlink to libSystem.dylib. 145216Sigor@sysoev.ru# GCC5 AddressSanitizer intercepts dlopen() and dlclose() but not dlsym() 146216Sigor@sysoev.ru# so all dynamic linker functions should be tested. 1470Sigor@sysoev.ru 1480Sigor@sysoev.ruNXT_LIBDL= 1490Sigor@sysoev.ru 1500Sigor@sysoev.runxt_feature="dlopen()" 1510Sigor@sysoev.runxt_feature_name=NXT_HAVE_DLOPEN 1520Sigor@sysoev.runxt_feature_run= 1530Sigor@sysoev.runxt_feature_incs= 1540Sigor@sysoev.runxt_feature_libs= 1550Sigor@sysoev.runxt_feature_test="#include <stdlib.h> 1560Sigor@sysoev.ru #include <dlfcn.h> 1570Sigor@sysoev.ru 1580Sigor@sysoev.ru int main() { 159216Sigor@sysoev.ru void *h = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL); 160216Sigor@sysoev.ru dlsym(h, \"\"); 161216Sigor@sysoev.ru dlclose(h); 1620Sigor@sysoev.ru return 0; 1630Sigor@sysoev.ru }" 1640Sigor@sysoev.ru. auto/feature 1650Sigor@sysoev.ru 1660Sigor@sysoev.ruif [ $nxt_found = no ]; then 1670Sigor@sysoev.ru 1680Sigor@sysoev.ru # Linux and Solaris prior to 10 require libdl. 1690Sigor@sysoev.ru # Solaris 10 libdl.so.1 is a filter to /usr/lib/ld.so.1. 1700Sigor@sysoev.ru 1710Sigor@sysoev.ru nxt_feature="dlopen() in libdl" 1720Sigor@sysoev.ru nxt_feature_libs="-ldl" 1730Sigor@sysoev.ru . auto/feature 1740Sigor@sysoev.ru 1750Sigor@sysoev.ru if [ $nxt_found = yes ]; then 1760Sigor@sysoev.ru NXT_LIBDL="-ldl" 1770Sigor@sysoev.ru fi 1780Sigor@sysoev.rufi 1790Sigor@sysoev.ru 1800Sigor@sysoev.ru 1810Sigor@sysoev.runxt_feature="posix_spawn()" 1820Sigor@sysoev.runxt_feature_name=NXT_HAVE_POSIX_SPAWN 1830Sigor@sysoev.runxt_feature_run= 1840Sigor@sysoev.runxt_feature_incs= 1850Sigor@sysoev.runxt_feature_libs= 1860Sigor@sysoev.runxt_feature_test="#include <spawn.h> 1870Sigor@sysoev.ru #include <unistd.h> 1880Sigor@sysoev.ru 1891292Spluknet@nginx.com int main(int argc, char *argv[]) { 1901292Spluknet@nginx.com (void) posix_spawn(NULL, \"\", NULL, NULL, argv, NULL); 1910Sigor@sysoev.ru return 0; 1920Sigor@sysoev.ru }" 1930Sigor@sysoev.ru. auto/feature 1940Sigor@sysoev.ru 1950Sigor@sysoev.ru 1960Sigor@sysoev.ru# NetBSD 1.0, OpenBSD 1.0, FreeBSD 2.2 setproctitle(). 1970Sigor@sysoev.ru 1980Sigor@sysoev.runxt_feature="setproctitle()" 1990Sigor@sysoev.runxt_feature_name=NXT_HAVE_SETPROCTITLE 2000Sigor@sysoev.runxt_feature_run= 2010Sigor@sysoev.runxt_feature_incs= 2020Sigor@sysoev.runxt_feature_libs= 2030Sigor@sysoev.runxt_feature_test="#include <stdlib.h> 2040Sigor@sysoev.ru #include <unistd.h> 2050Sigor@sysoev.ru 2060Sigor@sysoev.ru int main() { 2070Sigor@sysoev.ru setproctitle(\"%s\", \"title\"); 2080Sigor@sysoev.ru return 0; 2090Sigor@sysoev.ru }" 2100Sigor@sysoev.ru. auto/feature 211*1297St.nateldemoura@f5.com 212*1297St.nateldemoura@f5.com 213*1297St.nateldemoura@f5.com# Linux, FreeBSD, Solaris getgrouplist() 214*1297St.nateldemoura@f5.comnxt_feature="getgrouplist()" 215*1297St.nateldemoura@f5.comnxt_feature_name=NXT_HAVE_GETGROUPLIST 216*1297St.nateldemoura@f5.comnxt_feature_run= 217*1297St.nateldemoura@f5.comnxt_feature_incs= 218*1297St.nateldemoura@f5.comnxt_feature_libs= 219*1297St.nateldemoura@f5.comnxt_feature_test="#include <unistd.h> 220*1297St.nateldemoura@f5.com #include <grp.h> 221*1297St.nateldemoura@f5.com 222*1297St.nateldemoura@f5.com int main() { 223*1297St.nateldemoura@f5.com getgrouplist(\"root\", 0, NULL, NULL); 224*1297St.nateldemoura@f5.com return 0; 225*1297St.nateldemoura@f5.com }" 226*1297St.nateldemoura@f5.com. auto/feature 227