1 2# Copyright (C) Igor Sysoev 3# Copyright (C) NGINX, Inc. 4 5 6NXT_SHM_PREFIX="/" 7 8# FreeBSD, Solaris, MacOSX 9 10nxt_feature="shm_open()" 11nxt_feature_name=NXT_HAVE_SHM_OPEN 12nxt_feature_run=yes 13nxt_feature_incs= 14nxt_feature_libs= 15nxt_feature_test="#include <sys/mman.h> 16 #include <fcntl.h> 17 #include <unistd.h> 18 #include <sys/stat.h> 19 #include <sys/types.h> 20 21 int main() { 22 int ret; 23 static char name[] = \"/unit.configure\"; 24 25 shm_unlink(name); 26 27 int fd = shm_open(name, O_CREAT | O_EXCL | O_RDWR, 28 S_IRUSR | S_IWUSR); 29 if (fd == -1) 30 return 1; 31 32 ret = (access(name, F_OK) == 0); 33 shm_unlink(name); 34 35 return ret; 36 }" 37. auto/feature 38 39 40if [ $nxt_found = no ]; then 41 42 # Linux and NetBSD 7.0 shm_open() are in librt. 43 44 nxt_feature="shm_open() in librt" 45 nxt_feature_libs="-lrt" 46 . auto/feature 47 48 if [ $nxt_found = yes ]; then 49 NXT_LIBRT=$nxt_feature_libs 50 fi 51fi 52 53 54if [ $nxt_found = no ]; then 55 56 # DragonFly has no separate namespace for shm_open(). 57 58 nxt_feature="shm_open() in /tmp directory" 59 nxt_feature_libs= 60 nxt_feature_test="#include <sys/mman.h> 61 #include <fcntl.h> 62 #include <sys/stat.h> 63 #include <sys/types.h> 64 65 int main() { 66 static char name[] = \"/tmp/unit.configure\"; 67 68 shm_unlink(name); 69 70 int fd = shm_open(name, O_CREAT | O_EXCL | O_RDWR, 71 S_IRUSR | S_IWUSR); 72 if (fd == -1) 73 return 1; 74 75 shm_unlink(name); 76 return 0; 77 }" 78 . auto/feature 79 80 if [ $nxt_found = yes ]; then 81 NXT_SHM_PREFIX="/tmp/" 82 fi 83fi 84 85nxt_shm_open_found=$nxt_found 86 87 88# Linux 89 90nxt_feature="memfd_create()" 91nxt_feature_name=NXT_HAVE_MEMFD_CREATE 92nxt_feature_run=yes 93nxt_feature_incs= 94nxt_feature_libs= 95nxt_feature_test="#include <linux/memfd.h> 96 #include <unistd.h> 97 #include <sys/syscall.h> 98 99 int main() { 100 static char name[] = \"/unit.configure\"; 101 102 int fd = syscall(SYS_memfd_create, name, MFD_CLOEXEC); 103 if (fd == -1) 104 return 1; 105 106 return 0; 107 }" 108. auto/feature 109 110 111if [ "$nxt_shm_open_found$nxt_found" = nono ]; then 112 $echo 113 $echo $0: error: no shared memory implementation found. 114 $echo 115 exit 1; 116fi 117