142Smax.romanov@nginx.com 242Smax.romanov@nginx.com# Copyright (C) Igor Sysoev 342Smax.romanov@nginx.com# Copyright (C) NGINX, Inc. 442Smax.romanov@nginx.com 542Smax.romanov@nginx.com 6461Sigor@sysoev.ruNXT_SHM_PREFIX="/" 7461Sigor@sysoev.ru 8334Spluknet@nginx.com# FreeBSD, Solaris, MacOSX 942Smax.romanov@nginx.com 1042Smax.romanov@nginx.comnxt_feature="shm_open()" 1142Smax.romanov@nginx.comnxt_feature_name=NXT_HAVE_SHM_OPEN 1242Smax.romanov@nginx.comnxt_feature_run=yes 1342Smax.romanov@nginx.comnxt_feature_incs= 1442Smax.romanov@nginx.comnxt_feature_libs= 1542Smax.romanov@nginx.comnxt_feature_test="#include <sys/mman.h> 1642Smax.romanov@nginx.com #include <fcntl.h> 17461Sigor@sysoev.ru #include <unistd.h> 1842Smax.romanov@nginx.com #include <sys/stat.h> 1942Smax.romanov@nginx.com #include <sys/types.h> 2042Smax.romanov@nginx.com 2142Smax.romanov@nginx.com int main() { 22461Sigor@sysoev.ru int ret; 23259Sigor@sysoev.ru static char name[] = \"/unit.configure\"; 2442Smax.romanov@nginx.com 2542Smax.romanov@nginx.com shm_unlink(name); 2642Smax.romanov@nginx.com 2742Smax.romanov@nginx.com int fd = shm_open(name, O_CREAT | O_EXCL | O_RDWR, 2842Smax.romanov@nginx.com S_IRUSR | S_IWUSR); 2942Smax.romanov@nginx.com if (fd == -1) 3042Smax.romanov@nginx.com return 1; 3142Smax.romanov@nginx.com 32461Sigor@sysoev.ru ret = (access(name, F_OK) == 0); 3342Smax.romanov@nginx.com shm_unlink(name); 34461Sigor@sysoev.ru 35461Sigor@sysoev.ru return ret; 3642Smax.romanov@nginx.com }" 3742Smax.romanov@nginx.com. auto/feature 3842Smax.romanov@nginx.com 3942Smax.romanov@nginx.com 40334Spluknet@nginx.comif [ $nxt_found = no ]; then 41334Spluknet@nginx.com 42334Spluknet@nginx.com # Linux and NetBSD 7.0 shm_open() are in librt. 43334Spluknet@nginx.com 44334Spluknet@nginx.com nxt_feature="shm_open() in librt" 45334Spluknet@nginx.com nxt_feature_libs="-lrt" 46334Spluknet@nginx.com . auto/feature 47334Spluknet@nginx.com 48334Spluknet@nginx.com if [ $nxt_found = yes ]; then 49334Spluknet@nginx.com NXT_LIBRT=$nxt_feature_libs 50334Spluknet@nginx.com fi 51334Spluknet@nginx.comfi 52334Spluknet@nginx.com 53334Spluknet@nginx.com 54461Sigor@sysoev.ruif [ $nxt_found = no ]; then 55461Sigor@sysoev.ru 56461Sigor@sysoev.ru # DragonFly has no separate namespace for shm_open(). 57461Sigor@sysoev.ru 58461Sigor@sysoev.ru nxt_feature="shm_open() in /tmp directory" 59461Sigor@sysoev.ru nxt_feature_libs= 60461Sigor@sysoev.ru nxt_feature_test="#include <sys/mman.h> 61461Sigor@sysoev.ru #include <fcntl.h> 62461Sigor@sysoev.ru #include <sys/stat.h> 63461Sigor@sysoev.ru #include <sys/types.h> 64461Sigor@sysoev.ru 65461Sigor@sysoev.ru int main() { 66461Sigor@sysoev.ru static char name[] = \"/tmp/unit.configure\"; 67461Sigor@sysoev.ru 68461Sigor@sysoev.ru shm_unlink(name); 69461Sigor@sysoev.ru 70461Sigor@sysoev.ru int fd = shm_open(name, O_CREAT | O_EXCL | O_RDWR, 71461Sigor@sysoev.ru S_IRUSR | S_IWUSR); 72461Sigor@sysoev.ru if (fd == -1) 73461Sigor@sysoev.ru return 1; 74461Sigor@sysoev.ru 75461Sigor@sysoev.ru shm_unlink(name); 76461Sigor@sysoev.ru return 0; 77461Sigor@sysoev.ru }" 78461Sigor@sysoev.ru . auto/feature 79461Sigor@sysoev.ru 80461Sigor@sysoev.ru if [ $nxt_found = yes ]; then 81461Sigor@sysoev.ru NXT_SHM_PREFIX="/tmp/" 82461Sigor@sysoev.ru fi 83461Sigor@sysoev.rufi 84461Sigor@sysoev.ru 85461Sigor@sysoev.runxt_shm_open_found=$nxt_found 86461Sigor@sysoev.ru 87461Sigor@sysoev.ru 88*566Spluknet@nginx.com# FreeBSD 8.0 89*566Spluknet@nginx.com 90*566Spluknet@nginx.comnxt_feature="shm_open(SHM_ANON)" 91*566Spluknet@nginx.comnxt_feature_name=NXT_HAVE_SHM_OPEN_ANON 92*566Spluknet@nginx.comnxt_feature_libs= 93*566Spluknet@nginx.comnxt_feature_test="#include <sys/mman.h> 94*566Spluknet@nginx.com #include <fcntl.h> 95*566Spluknet@nginx.com #include <sys/stat.h> 96*566Spluknet@nginx.com 97*566Spluknet@nginx.com int main() { 98*566Spluknet@nginx.com int fd = shm_open(SHM_ANON, O_RDWR, S_IRUSR | S_IWUSR); 99*566Spluknet@nginx.com if (fd == -1) 100*566Spluknet@nginx.com return 1; 101*566Spluknet@nginx.com 102*566Spluknet@nginx.com return 0; 103*566Spluknet@nginx.com }" 104*566Spluknet@nginx.com. auto/feature 105*566Spluknet@nginx.com 106*566Spluknet@nginx.comif [ "$nxt_shm_open_found" = no ]; then 107*566Spluknet@nginx.com nxt_shm_open_found=$nxt_found 108*566Spluknet@nginx.comfi 109*566Spluknet@nginx.com 110*566Spluknet@nginx.com 11142Smax.romanov@nginx.com# Linux 11242Smax.romanov@nginx.com 11342Smax.romanov@nginx.comnxt_feature="memfd_create()" 11442Smax.romanov@nginx.comnxt_feature_name=NXT_HAVE_MEMFD_CREATE 11542Smax.romanov@nginx.comnxt_feature_run=yes 11642Smax.romanov@nginx.comnxt_feature_incs= 11742Smax.romanov@nginx.comnxt_feature_libs= 11842Smax.romanov@nginx.comnxt_feature_test="#include <linux/memfd.h> 11942Smax.romanov@nginx.com #include <unistd.h> 12042Smax.romanov@nginx.com #include <sys/syscall.h> 12142Smax.romanov@nginx.com 12242Smax.romanov@nginx.com int main() { 123259Sigor@sysoev.ru static char name[] = \"/unit.configure\"; 12442Smax.romanov@nginx.com 12542Smax.romanov@nginx.com int fd = syscall(SYS_memfd_create, name, MFD_CLOEXEC); 12642Smax.romanov@nginx.com if (fd == -1) 12742Smax.romanov@nginx.com return 1; 12842Smax.romanov@nginx.com 12942Smax.romanov@nginx.com return 0; 13042Smax.romanov@nginx.com }" 13142Smax.romanov@nginx.com. auto/feature 13242Smax.romanov@nginx.com 133461Sigor@sysoev.ru 134461Sigor@sysoev.ruif [ "$nxt_shm_open_found$nxt_found" = nono ]; then 135461Sigor@sysoev.ru $echo 136461Sigor@sysoev.ru $echo $0: error: no shared memory implementation found. 137461Sigor@sysoev.ru $echo 138461Sigor@sysoev.ru exit 1; 139461Sigor@sysoev.rufi 140