linux 6.1 KB

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