1 2# Copyright (C) Igor Sysoev 3# Copyright (C) Nginx, Inc. 4 5 6have=NGX_LINUX . auto/have_headers 7 8CORE_INCS="$UNIX_INCS" 9CORE_DEPS="$UNIX_DEPS $LINUX_DEPS" 10CORE_SRCS="$UNIX_SRCS $LINUX_SRCS" 11 12ngx_spacer=' 13' 14 15cc_aux_flags="$CC_AUX_FLAGS" 16CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64" 17 18 19# Linux kernel version 20 21version=$((`uname -r \ 22 | sed -n -e 's/^\([0-9][0-9]*\)\.\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/ \ 23 \1*256*256+\2*256+\3/p' \ 24 -e 's/^\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1*256*256+\2*256/p'`)) 25 26version=${version:-0} 27 28 29# posix_fadvise64() had been implemented in 2.5.60 30 31if [ $version -lt 132412 ]; then 32 have=NGX_HAVE_POSIX_FADVISE . auto/nohave 33fi 34 35# epoll, EPOLLET version 36 37ngx_feature="epoll" 38ngx_feature_name="NGX_HAVE_EPOLL" 39ngx_feature_run=yes 40ngx_feature_incs="#include <sys/epoll.h>" 41ngx_feature_path= 42ngx_feature_libs= 43ngx_feature_test="int efd = 0; 44 struct epoll_event ee; 45 ee.events = EPOLLIN|EPOLLOUT|EPOLLET; 46 ee.data.ptr = NULL; 47 (void) ee; 48 efd = epoll_create(100); 49 if (efd == -1) return 1;" 50. auto/feature 51 52if [ $ngx_found = yes ]; then 53 have=NGX_HAVE_CLEAR_EVENT . auto/have 54 CORE_SRCS="$CORE_SRCS $EPOLL_SRCS" 55 EVENT_MODULES="$EVENT_MODULES $EPOLL_MODULE" 56 EVENT_FOUND=YES 57 58 59 # EPOLLRDHUP appeared in Linux 2.6.17, glibc 2.8 60 61 ngx_feature="EPOLLRDHUP" 62 ngx_feature_name="NGX_HAVE_EPOLLRDHUP" 63 ngx_feature_run=no 64 ngx_feature_incs="#include <sys/epoll.h>" 65 ngx_feature_path= 66 ngx_feature_libs= 67 ngx_feature_test="int efd = 0, fd = 0; 68 struct epoll_event ee; 69 ee.events = EPOLLIN|EPOLLRDHUP|EPOLLET; 70 ee.data.ptr = NULL; 71 epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ee)" 72 . auto/feature 73 74 75 # EPOLLEXCLUSIVE appeared in Linux 4.5, glibc 2.24 76 77 ngx_feature="EPOLLEXCLUSIVE" 78 ngx_feature_name="NGX_HAVE_EPOLLEXCLUSIVE" 79 ngx_feature_run=no 80 ngx_feature_incs="#include <sys/epoll.h>" 81 ngx_feature_path= 82 ngx_feature_libs= 83 ngx_feature_test="int efd = 0, fd = 0; 84 struct epoll_event ee; 85 ee.events = EPOLLIN|EPOLLEXCLUSIVE; 86 ee.data.ptr = NULL; 87 epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ee)" 88# . auto/feature 89fi 90 91 92# O_PATH and AT_EMPTY_PATH were introduced in 2.6.39, glibc 2.14 93 94ngx_feature="O_PATH" 95ngx_feature_name="NGX_HAVE_O_PATH" 96ngx_feature_run=no 97ngx_feature_incs="#include <sys/types.h> 98 #include <sys/stat.h> 99 #include <fcntl.h>" 100ngx_feature_path= 101ngx_feature_libs= 102ngx_feature_test="int fd; struct stat sb; 103 fd = openat(AT_FDCWD, \".\", O_PATH|O_DIRECTORY|O_NOFOLLOW); 104 if (fstatat(fd, \"\", &sb, AT_EMPTY_PATH) != 0) return 1" 105. auto/feature 106 107 108# sendfile() 109 110CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE" 111ngx_feature="sendfile()" 112ngx_feature_name="NGX_HAVE_SENDFILE" 113ngx_feature_run=yes 114ngx_feature_incs="#include <sys/sendfile.h> 115 #include <errno.h>" 116ngx_feature_path= 117ngx_feature_libs= 118ngx_feature_test="int s = 0, fd = 1; 119 ssize_t n; off_t off = 0; 120 n = sendfile(s, fd, &off, 1); 121 if (n == -1 && errno == ENOSYS) return 1" 122. auto/feature 123 124if [ $ngx_found = yes ]; then 125 CORE_SRCS="$CORE_SRCS $LINUX_SENDFILE_SRCS" 126fi 127 128 129# sendfile64() 130 131CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64" 132ngx_feature="sendfile64()" 133ngx_feature_name="NGX_HAVE_SENDFILE64" 134ngx_feature_run=yes 135ngx_feature_incs="#include <sys/sendfile.h> 136 #include <errno.h>" 137ngx_feature_path= 138ngx_feature_libs= 139ngx_feature_test="int s = 0, fd = 1; 140 ssize_t n; off_t off = 0; 141 n = sendfile(s, fd, &off, 1); 142 if (n == -1 && errno == ENOSYS) return 1" 143. auto/feature 144 145 146ngx_include="sys/prctl.h"; . auto/include 147 148# prctl(PR_SET_DUMPABLE) 149 150ngx_feature="prctl(PR_SET_DUMPABLE)" 151ngx_feature_name="NGX_HAVE_PR_SET_DUMPABLE" 152ngx_feature_run=yes 153ngx_feature_incs="#include <sys/prctl.h>" 154ngx_feature_path= 155ngx_feature_libs= 156ngx_feature_test="if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) return 1" 157. auto/feature 158 159 160# prctl(PR_SET_KEEPCAPS) 161 162ngx_feature="prctl(PR_SET_KEEPCAPS)" 163ngx_feature_name="NGX_HAVE_PR_SET_KEEPCAPS" 164ngx_feature_run=yes 165ngx_feature_incs="#include <sys/prctl.h>" 166ngx_feature_path= 167ngx_feature_libs= 168ngx_feature_test="if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) == -1) return 1" 169. auto/feature 170 171 172# capabilities 173 174ngx_feature="capabilities" 175ngx_feature_name="NGX_HAVE_CAPABILITIES" 176ngx_feature_run=no 177ngx_feature_incs="#include <linux/capability.h> 178 #include <sys/syscall.h>" 179ngx_feature_path= 180ngx_feature_libs= 181ngx_feature_test="struct __user_cap_data_struct data; 182 struct __user_cap_header_struct header; 183 184 header.version = _LINUX_CAPABILITY_VERSION_1; 185 data.effective = CAP_TO_MASK(CAP_NET_RAW); 186 data.permitted = 0; 187 188 (void) header; 189 (void) data; 190 (void) SYS_capset" 191. auto/feature 192 193 194# crypt_r() 195 196ngx_feature="crypt_r()" 197ngx_feature_name="NGX_HAVE_GNU_CRYPT_R" 198ngx_feature_run=no 199ngx_feature_incs="#include <crypt.h>" 200ngx_feature_path= 201ngx_feature_libs=-lcrypt 202ngx_feature_test="struct crypt_data cd; 203 crypt_r(\"key\", \"salt\", &cd);" 204. auto/feature 205 206 207ngx_include="sys/vfs.h"; . auto/include 208 209 210CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64" 211