linux 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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. fi
  68. # O_PATH and AT_EMPTY_PATH were introduced in 2.6.39, glibc 2.14
  69. ngx_feature="O_PATH"
  70. ngx_feature_name="NGX_HAVE_O_PATH"
  71. ngx_feature_run=no
  72. ngx_feature_incs="#include <sys/types.h>
  73. #include <sys/stat.h>
  74. #include <fcntl.h>"
  75. ngx_feature_path=
  76. ngx_feature_libs=
  77. ngx_feature_test="int fd; struct stat sb;
  78. fd = openat(AT_FDCWD, \".\", O_PATH|O_DIRECTORY|O_NOFOLLOW);
  79. if (fstatat(fd, \"\", &sb, AT_EMPTY_PATH) != 0) return 1"
  80. . auto/feature
  81. # sendfile()
  82. CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE"
  83. ngx_feature="sendfile()"
  84. ngx_feature_name="NGX_HAVE_SENDFILE"
  85. ngx_feature_run=yes
  86. ngx_feature_incs="#include <sys/sendfile.h>
  87. #include <errno.h>"
  88. ngx_feature_path=
  89. ngx_feature_libs=
  90. ngx_feature_test="int s = 0, fd = 1;
  91. ssize_t n; off_t off = 0;
  92. n = sendfile(s, fd, &off, 1);
  93. if (n == -1 && errno == ENOSYS) return 1"
  94. . auto/feature
  95. if [ $ngx_found = yes ]; then
  96. CORE_SRCS="$CORE_SRCS $LINUX_SENDFILE_SRCS"
  97. fi
  98. # sendfile64()
  99. CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
  100. ngx_feature="sendfile64()"
  101. ngx_feature_name="NGX_HAVE_SENDFILE64"
  102. ngx_feature_run=yes
  103. ngx_feature_incs="#include <sys/sendfile.h>
  104. #include <errno.h>"
  105. ngx_feature_path=
  106. ngx_feature_libs=
  107. ngx_feature_test="int s = 0, fd = 1;
  108. ssize_t n; off_t off = 0;
  109. n = sendfile(s, fd, &off, 1);
  110. if (n == -1 && errno == ENOSYS) return 1"
  111. . auto/feature
  112. ngx_include="sys/prctl.h"; . auto/include
  113. # prctl(PR_SET_DUMPABLE)
  114. ngx_feature="prctl(PR_SET_DUMPABLE)"
  115. ngx_feature_name="NGX_HAVE_PR_SET_DUMPABLE"
  116. ngx_feature_run=yes
  117. ngx_feature_incs="#include <sys/prctl.h>"
  118. ngx_feature_path=
  119. ngx_feature_libs=
  120. ngx_feature_test="if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) return 1"
  121. . auto/feature
  122. # prctl(PR_SET_KEEPCAPS)
  123. ngx_feature="prctl(PR_SET_KEEPCAPS)"
  124. ngx_feature_name="NGX_HAVE_PR_SET_KEEPCAPS"
  125. ngx_feature_run=yes
  126. ngx_feature_incs="#include <sys/prctl.h>"
  127. ngx_feature_path=
  128. ngx_feature_libs=
  129. ngx_feature_test="if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) == -1) return 1"
  130. . auto/feature
  131. # capabilities
  132. ngx_feature="capabilities"
  133. ngx_feature_name="NGX_HAVE_CAPABILITIES"
  134. ngx_feature_run=no
  135. ngx_feature_incs="#include <linux/capability.h>
  136. #include <sys/syscall.h>"
  137. ngx_feature_path=
  138. ngx_feature_libs=
  139. ngx_feature_test="struct __user_cap_data_struct data;
  140. struct __user_cap_header_struct header;
  141. header.version = _LINUX_CAPABILITY_VERSION_1;
  142. data.effective = CAP_TO_MASK(CAP_NET_RAW);
  143. data.permitted = 0;
  144. (void) SYS_capset"
  145. . auto/feature
  146. # crypt_r()
  147. ngx_feature="crypt_r()"
  148. ngx_feature_name="NGX_HAVE_GNU_CRYPT_R"
  149. ngx_feature_run=no
  150. ngx_feature_incs="#include <crypt.h>"
  151. ngx_feature_path=
  152. ngx_feature_libs=-lcrypt
  153. ngx_feature_test="struct crypt_data cd;
  154. crypt_r(\"key\", \"salt\", &cd);"
  155. . auto/feature
  156. ngx_include="sys/vfs.h"; . auto/include
  157. CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"