linux 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. efd = epoll_create(100);
  33. if (efd == -1) return 1;"
  34. . auto/feature
  35. if [ $ngx_found = yes ]; then
  36. have=NGX_HAVE_CLEAR_EVENT . auto/have
  37. CORE_SRCS="$CORE_SRCS $EPOLL_SRCS"
  38. EVENT_MODULES="$EVENT_MODULES $EPOLL_MODULE"
  39. EVENT_FOUND=YES
  40. # EPOLLRDHUP appeared in Linux 2.6.17, glibc 2.8
  41. ngx_feature="EPOLLRDHUP"
  42. ngx_feature_name="NGX_HAVE_EPOLLRDHUP"
  43. ngx_feature_run=no
  44. ngx_feature_incs="#include <sys/epoll.h>"
  45. ngx_feature_path=
  46. ngx_feature_libs=
  47. ngx_feature_test="int efd = 0, fd = 0;
  48. struct epoll_event ee;
  49. ee.events = EPOLLIN|EPOLLRDHUP|EPOLLET;
  50. ee.data.ptr = NULL;
  51. epoll_ctl(efd, EPOLL_CTL_ADD, fd, &ee)"
  52. . auto/feature
  53. fi
  54. # O_PATH and AT_EMPTY_PATH were introduced in 2.6.39, glibc 2.14
  55. ngx_feature="O_PATH"
  56. ngx_feature_name="NGX_HAVE_O_PATH"
  57. ngx_feature_run=no
  58. ngx_feature_incs="#include <sys/types.h>
  59. #include <sys/stat.h>
  60. #include <fcntl.h>"
  61. ngx_feature_path=
  62. ngx_feature_libs=
  63. ngx_feature_test="int fd; struct stat sb;
  64. fd = openat(AT_FDCWD, \".\", O_PATH|O_DIRECTORY|O_NOFOLLOW);
  65. if (fstatat(fd, \"\", &sb, AT_EMPTY_PATH) != 0) return 1"
  66. . auto/feature
  67. # sendfile()
  68. CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE"
  69. ngx_feature="sendfile()"
  70. ngx_feature_name="NGX_HAVE_SENDFILE"
  71. ngx_feature_run=yes
  72. ngx_feature_incs="#include <sys/sendfile.h>
  73. #include <errno.h>"
  74. ngx_feature_path=
  75. ngx_feature_libs=
  76. ngx_feature_test="int s = 0, fd = 1;
  77. ssize_t n; off_t off = 0;
  78. n = sendfile(s, fd, &off, 1);
  79. if (n == -1 && errno == ENOSYS) return 1"
  80. . auto/feature
  81. if [ $ngx_found = yes ]; then
  82. CORE_SRCS="$CORE_SRCS $LINUX_SENDFILE_SRCS"
  83. fi
  84. # sendfile64()
  85. CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"
  86. ngx_feature="sendfile64()"
  87. ngx_feature_name="NGX_HAVE_SENDFILE64"
  88. ngx_feature_run=yes
  89. ngx_feature_incs="#include <sys/sendfile.h>
  90. #include <errno.h>"
  91. ngx_feature_path=
  92. ngx_feature_libs=
  93. ngx_feature_test="int s = 0, fd = 1;
  94. ssize_t n; off_t off = 0;
  95. n = sendfile(s, fd, &off, 1);
  96. if (n == -1 && errno == ENOSYS) return 1"
  97. . auto/feature
  98. ngx_include="sys/prctl.h"; . auto/include
  99. # prctl(PR_SET_DUMPABLE)
  100. ngx_feature="prctl(PR_SET_DUMPABLE)"
  101. ngx_feature_name="NGX_HAVE_PR_SET_DUMPABLE"
  102. ngx_feature_run=yes
  103. ngx_feature_incs="#include <sys/prctl.h>"
  104. ngx_feature_path=
  105. ngx_feature_libs=
  106. ngx_feature_test="if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) == -1) return 1"
  107. . auto/feature
  108. # sched_setaffinity()
  109. ngx_feature="sched_setaffinity()"
  110. ngx_feature_name="NGX_HAVE_SCHED_SETAFFINITY"
  111. ngx_feature_run=no
  112. ngx_feature_incs="#include <sched.h>"
  113. ngx_feature_path=
  114. ngx_feature_libs=
  115. ngx_feature_test="cpu_set_t mask;
  116. CPU_ZERO(&mask);
  117. sched_setaffinity(0, sizeof(cpu_set_t), &mask)"
  118. . auto/feature
  119. # crypt_r()
  120. ngx_feature="crypt_r()"
  121. ngx_feature_name="NGX_HAVE_GNU_CRYPT_R"
  122. ngx_feature_run=no
  123. ngx_feature_incs="#include <crypt.h>"
  124. ngx_feature_path=
  125. ngx_feature_libs=-lcrypt
  126. ngx_feature_test="struct crypt_data cd;
  127. crypt_r(\"key\", \"salt\", &cd);"
  128. . auto/feature
  129. ngx_include="sys/vfs.h"; . auto/include
  130. CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64"