unix 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028
  1. # Copyright (C) Igor Sysoev
  2. # Copyright (C) Nginx, Inc.
  3. NGX_USER=${NGX_USER:-nobody}
  4. if [ -z "$NGX_GROUP" ]; then
  5. if [ $NGX_USER = nobody ]; then
  6. if grep nobody /etc/group 2>&1 >/dev/null; then
  7. echo "checking for nobody group ... found"
  8. NGX_GROUP=nobody
  9. else
  10. echo "checking for nobody group ... not found"
  11. if grep nogroup /etc/group 2>&1 >/dev/null; then
  12. echo "checking for nogroup group ... found"
  13. NGX_GROUP=nogroup
  14. else
  15. echo "checking for nogroup group ... not found"
  16. NGX_GROUP=nobody
  17. fi
  18. fi
  19. else
  20. NGX_GROUP=$NGX_USER
  21. fi
  22. fi
  23. ngx_feature="poll()"
  24. ngx_feature_name=
  25. ngx_feature_run=no
  26. ngx_feature_incs="#include <poll.h>"
  27. ngx_feature_path=
  28. ngx_feature_libs=
  29. ngx_feature_test="int n; struct pollfd pl;
  30. pl.fd = 0;
  31. pl.events = 0;
  32. pl.revents = 0;
  33. n = poll(&pl, 1, 0);
  34. if (n == -1) return 1"
  35. . auto/feature
  36. if [ $ngx_found = no ]; then
  37. EVENT_POLL=NONE
  38. fi
  39. ngx_feature="/dev/poll"
  40. ngx_feature_name="NGX_HAVE_DEVPOLL"
  41. ngx_feature_run=no
  42. ngx_feature_incs="#include <sys/devpoll.h>"
  43. ngx_feature_path=
  44. ngx_feature_libs=
  45. ngx_feature_test="int n, dp; struct dvpoll dvp;
  46. dp = 0;
  47. dvp.dp_fds = NULL;
  48. dvp.dp_nfds = 0;
  49. dvp.dp_timeout = 0;
  50. n = ioctl(dp, DP_POLL, &dvp);
  51. if (n == -1) return 1"
  52. . auto/feature
  53. if [ $ngx_found = yes ]; then
  54. CORE_SRCS="$CORE_SRCS $DEVPOLL_SRCS"
  55. EVENT_MODULES="$EVENT_MODULES $DEVPOLL_MODULE"
  56. EVENT_FOUND=YES
  57. fi
  58. if test -z "$NGX_KQUEUE_CHECKED"; then
  59. ngx_feature="kqueue"
  60. ngx_feature_name="NGX_HAVE_KQUEUE"
  61. ngx_feature_run=no
  62. ngx_feature_incs="#include <sys/event.h>"
  63. ngx_feature_path=
  64. ngx_feature_libs=
  65. ngx_feature_test="(void) kqueue()"
  66. . auto/feature
  67. if [ $ngx_found = yes ]; then
  68. have=NGX_HAVE_CLEAR_EVENT . auto/have
  69. EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
  70. CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
  71. EVENT_FOUND=YES
  72. ngx_feature="kqueue's NOTE_LOWAT"
  73. ngx_feature_name="NGX_HAVE_LOWAT_EVENT"
  74. ngx_feature_run=no
  75. ngx_feature_incs="#include <sys/event.h>"
  76. ngx_feature_path=
  77. ngx_feature_libs=
  78. ngx_feature_test="struct kevent kev;
  79. kev.fflags = NOTE_LOWAT;
  80. (void) kev"
  81. . auto/feature
  82. ngx_feature="kqueue's EVFILT_TIMER"
  83. ngx_feature_name="NGX_HAVE_TIMER_EVENT"
  84. ngx_feature_run=yes
  85. ngx_feature_incs="#include <sys/event.h>
  86. #include <sys/time.h>"
  87. ngx_feature_path=
  88. ngx_feature_libs=
  89. ngx_feature_test="int kq;
  90. struct kevent kev;
  91. struct timespec ts;
  92. if ((kq = kqueue()) == -1) return 1;
  93. kev.ident = 0;
  94. kev.filter = EVFILT_TIMER;
  95. kev.flags = EV_ADD|EV_ENABLE;
  96. kev.fflags = 0;
  97. kev.data = 1000;
  98. kev.udata = 0;
  99. ts.tv_sec = 0;
  100. ts.tv_nsec = 0;
  101. if (kevent(kq, &kev, 1, &kev, 1, &ts) == -1) return 1;
  102. if (kev.flags & EV_ERROR) return 1;"
  103. . auto/feature
  104. fi
  105. fi
  106. if [ "$NGX_SYSTEM" = "NetBSD" ]; then
  107. # NetBSD 2.0 incompatibly defines kevent.udata as "intptr_t"
  108. cat << END >> $NGX_AUTO_CONFIG_H
  109. #define NGX_KQUEUE_UDATA_T
  110. END
  111. else
  112. cat << END >> $NGX_AUTO_CONFIG_H
  113. #define NGX_KQUEUE_UDATA_T (void *)
  114. END
  115. fi
  116. ngx_feature="crypt()"
  117. ngx_feature_name=
  118. ngx_feature_run=no
  119. ngx_feature_incs=
  120. ngx_feature_path=
  121. ngx_feature_libs=
  122. ngx_feature_test="crypt(\"test\", \"salt\");"
  123. . auto/feature
  124. if [ $ngx_found = no ]; then
  125. ngx_feature="crypt() in libcrypt"
  126. ngx_feature_name=
  127. ngx_feature_run=no
  128. ngx_feature_incs=
  129. ngx_feature_path=
  130. ngx_feature_libs=-lcrypt
  131. . auto/feature
  132. if [ $ngx_found = yes ]; then
  133. CRYPT_LIB="-lcrypt"
  134. fi
  135. fi
  136. ngx_feature="F_READAHEAD"
  137. ngx_feature_name="NGX_HAVE_F_READAHEAD"
  138. ngx_feature_run=no
  139. ngx_feature_incs="#include <fcntl.h>"
  140. ngx_feature_path=
  141. ngx_feature_libs=
  142. ngx_feature_test="fcntl(0, F_READAHEAD, 1);"
  143. . auto/feature
  144. ngx_feature="posix_fadvise()"
  145. ngx_feature_name="NGX_HAVE_POSIX_FADVISE"
  146. ngx_feature_run=no
  147. ngx_feature_incs="#include <fcntl.h>"
  148. ngx_feature_path=
  149. ngx_feature_libs=
  150. ngx_feature_test="posix_fadvise(0, 0, 0, POSIX_FADV_SEQUENTIAL);"
  151. . auto/feature
  152. ngx_feature="O_DIRECT"
  153. ngx_feature_name="NGX_HAVE_O_DIRECT"
  154. ngx_feature_run=no
  155. ngx_feature_incs="#include <fcntl.h>"
  156. ngx_feature_path=
  157. ngx_feature_libs=
  158. ngx_feature_test="fcntl(0, F_SETFL, O_DIRECT);"
  159. . auto/feature
  160. if [ $ngx_found = yes -a "$NGX_SYSTEM" = "Linux" ]; then
  161. have=NGX_HAVE_ALIGNED_DIRECTIO . auto/have
  162. fi
  163. ngx_feature="F_NOCACHE"
  164. ngx_feature_name="NGX_HAVE_F_NOCACHE"
  165. ngx_feature_run=no
  166. ngx_feature_incs="#include <fcntl.h>"
  167. ngx_feature_path=
  168. ngx_feature_libs=
  169. ngx_feature_test="fcntl(0, F_NOCACHE, 1);"
  170. . auto/feature
  171. ngx_feature="directio()"
  172. ngx_feature_name="NGX_HAVE_DIRECTIO"
  173. ngx_feature_run=no
  174. ngx_feature_incs="#include <sys/types.h>
  175. #include <sys/fcntl.h>"
  176. ngx_feature_path=
  177. ngx_feature_libs=
  178. ngx_feature_test="directio(0, DIRECTIO_ON);"
  179. . auto/feature
  180. ngx_feature="statfs()"
  181. ngx_feature_name="NGX_HAVE_STATFS"
  182. ngx_feature_run=no
  183. ngx_feature_incs="$NGX_INCLUDE_SYS_PARAM_H
  184. $NGX_INCLUDE_SYS_MOUNT_H
  185. $NGX_INCLUDE_SYS_VFS_H"
  186. ngx_feature_path=
  187. ngx_feature_libs=
  188. ngx_feature_test="struct statfs fs;
  189. statfs(\".\", &fs);"
  190. . auto/feature
  191. ngx_feature="statvfs()"
  192. ngx_feature_name="NGX_HAVE_STATVFS"
  193. ngx_feature_run=no
  194. ngx_feature_incs="#include <sys/types.h>
  195. #include <sys/statvfs.h>"
  196. ngx_feature_path=
  197. ngx_feature_libs=
  198. ngx_feature_test="struct statvfs fs;
  199. statvfs(\".\", &fs);"
  200. . auto/feature
  201. ngx_feature="dlopen()"
  202. ngx_feature_name="NGX_HAVE_DLOPEN"
  203. ngx_feature_run=no
  204. ngx_feature_incs="#include <dlfcn.h>"
  205. ngx_feature_path=
  206. ngx_feature_libs=
  207. ngx_feature_test="dlopen(NULL, RTLD_NOW | RTLD_GLOBAL); dlsym(NULL, \"\")"
  208. . auto/feature
  209. if [ $ngx_found = no ]; then
  210. ngx_feature="dlopen() in libdl"
  211. ngx_feature_libs="-ldl"
  212. . auto/feature
  213. if [ $ngx_found = yes ]; then
  214. CORE_LIBS="$CORE_LIBS -ldl"
  215. NGX_LIBDL="-ldl"
  216. fi
  217. fi
  218. ngx_feature="sched_yield()"
  219. ngx_feature_name="NGX_HAVE_SCHED_YIELD"
  220. ngx_feature_run=no
  221. ngx_feature_incs="#include <sched.h>"
  222. ngx_feature_path=
  223. ngx_feature_libs=
  224. ngx_feature_test="sched_yield()"
  225. . auto/feature
  226. if [ $ngx_found = no ]; then
  227. ngx_feature="sched_yield() in librt"
  228. ngx_feature_libs="-lrt"
  229. . auto/feature
  230. if [ $ngx_found = yes ]; then
  231. CORE_LIBS="$CORE_LIBS -lrt"
  232. fi
  233. fi
  234. ngx_feature="sched_setaffinity()"
  235. ngx_feature_name="NGX_HAVE_SCHED_SETAFFINITY"
  236. ngx_feature_run=no
  237. ngx_feature_incs="#include <sched.h>"
  238. ngx_feature_path=
  239. ngx_feature_libs=
  240. ngx_feature_test="cpu_set_t mask;
  241. CPU_ZERO(&mask);
  242. sched_setaffinity(0, sizeof(cpu_set_t), &mask)"
  243. . auto/feature
  244. ngx_feature="SO_SETFIB"
  245. ngx_feature_name="NGX_HAVE_SETFIB"
  246. ngx_feature_run=no
  247. ngx_feature_incs="#include <sys/socket.h>"
  248. ngx_feature_path=
  249. ngx_feature_libs=
  250. ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_SETFIB, NULL, 0)"
  251. . auto/feature
  252. ngx_feature="SO_REUSEPORT"
  253. ngx_feature_name="NGX_HAVE_REUSEPORT"
  254. ngx_feature_run=no
  255. ngx_feature_incs="#include <sys/socket.h>"
  256. ngx_feature_path=
  257. ngx_feature_libs=
  258. ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_REUSEPORT, NULL, 0)"
  259. . auto/feature
  260. ngx_feature="SO_ACCEPTFILTER"
  261. ngx_feature_name="NGX_HAVE_DEFERRED_ACCEPT"
  262. ngx_feature_run=no
  263. ngx_feature_incs="#include <sys/socket.h>"
  264. ngx_feature_path=
  265. ngx_feature_libs=
  266. ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_ACCEPTFILTER, NULL, 0)"
  267. . auto/feature
  268. # OpenBSD bind to any address for transparent proxying
  269. ngx_feature="SO_BINDANY"
  270. ngx_feature_name="NGX_HAVE_TRANSPARENT_PROXY"
  271. ngx_feature_run=no
  272. ngx_feature_incs="#include <sys/socket.h>"
  273. ngx_feature_path=
  274. ngx_feature_libs=
  275. ngx_feature_test="setsockopt(0, SOL_SOCKET, SO_BINDANY, NULL, 0)"
  276. . auto/feature
  277. # Linux transparent proxying
  278. ngx_feature="IP_TRANSPARENT"
  279. ngx_feature_name="NGX_HAVE_TRANSPARENT_PROXY"
  280. ngx_feature_run=no
  281. ngx_feature_incs="#include <sys/socket.h>
  282. #include <netinet/in.h>"
  283. ngx_feature_path=
  284. ngx_feature_libs=
  285. ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_TRANSPARENT, NULL, 0)"
  286. . auto/feature
  287. # FreeBSD bind to any address for transparent proxying
  288. ngx_feature="IP_BINDANY"
  289. ngx_feature_name="NGX_HAVE_TRANSPARENT_PROXY"
  290. ngx_feature_run=no
  291. ngx_feature_incs="#include <sys/socket.h>
  292. #include <netinet/in.h>"
  293. ngx_feature_path=
  294. ngx_feature_libs=
  295. ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_BINDANY, NULL, 0)"
  296. . auto/feature
  297. # Linux IP_BIND_ADDRESS_NO_PORT
  298. ngx_feature="IP_BIND_ADDRESS_NO_PORT"
  299. ngx_feature_name="NGX_HAVE_IP_BIND_ADDRESS_NO_PORT"
  300. ngx_feature_run=no
  301. ngx_feature_incs="#include <sys/socket.h>
  302. #include <netinet/in.h>"
  303. ngx_feature_path=
  304. ngx_feature_libs=
  305. ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_BIND_ADDRESS_NO_PORT, NULL, 0)"
  306. . auto/feature
  307. # BSD way to get IPv4 datagram destination address
  308. ngx_feature="IP_RECVDSTADDR"
  309. ngx_feature_name="NGX_HAVE_IP_RECVDSTADDR"
  310. ngx_feature_run=no
  311. ngx_feature_incs="#include <sys/socket.h>
  312. #include <netinet/in.h>"
  313. ngx_feature_path=
  314. ngx_feature_libs=
  315. ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_RECVDSTADDR, NULL, 0)"
  316. . auto/feature
  317. # BSD way to set IPv4 datagram source address
  318. ngx_feature="IP_SENDSRCADDR"
  319. ngx_feature_name="NGX_HAVE_IP_SENDSRCADDR"
  320. ngx_feature_run=no
  321. ngx_feature_incs="#include <sys/socket.h>
  322. #include <netinet/in.h>"
  323. ngx_feature_path=
  324. ngx_feature_libs=
  325. ngx_feature_test="setsockopt(0, IPPROTO_IP, IP_SENDSRCADDR, NULL, 0)"
  326. . auto/feature
  327. # Linux way to get IPv4 datagram destination address
  328. ngx_feature="IP_PKTINFO"
  329. ngx_feature_name="NGX_HAVE_IP_PKTINFO"
  330. ngx_feature_run=no
  331. ngx_feature_incs="#include <sys/socket.h>
  332. #include <netinet/in.h>"
  333. ngx_feature_path=
  334. ngx_feature_libs=
  335. ngx_feature_test="struct in_pktinfo pkt;
  336. pkt.ipi_spec_dst.s_addr = INADDR_ANY;
  337. (void) pkt;
  338. setsockopt(0, IPPROTO_IP, IP_PKTINFO, NULL, 0)"
  339. . auto/feature
  340. # RFC 3542 way to get IPv6 datagram destination address
  341. ngx_feature="IPV6_RECVPKTINFO"
  342. ngx_feature_name="NGX_HAVE_IPV6_RECVPKTINFO"
  343. ngx_feature_run=no
  344. ngx_feature_incs="#include <sys/socket.h>
  345. #include <netinet/in.h>"
  346. ngx_feature_path=
  347. ngx_feature_libs=
  348. ngx_feature_test="setsockopt(0, IPPROTO_IPV6, IPV6_RECVPKTINFO, NULL, 0)"
  349. . auto/feature
  350. ngx_feature="TCP_DEFER_ACCEPT"
  351. ngx_feature_name="NGX_HAVE_DEFERRED_ACCEPT"
  352. ngx_feature_run=no
  353. ngx_feature_incs="#include <sys/socket.h>
  354. #include <netinet/in.h>
  355. #include <netinet/tcp.h>"
  356. ngx_feature_path=
  357. ngx_feature_libs=
  358. ngx_feature_test="setsockopt(0, IPPROTO_TCP, TCP_DEFER_ACCEPT, NULL, 0)"
  359. . auto/feature
  360. ngx_feature="TCP_KEEPIDLE"
  361. ngx_feature_name="NGX_HAVE_KEEPALIVE_TUNABLE"
  362. ngx_feature_run=no
  363. ngx_feature_incs="#include <sys/socket.h>
  364. #include <netinet/in.h>
  365. #include <netinet/tcp.h>"
  366. ngx_feature_path=
  367. ngx_feature_libs=
  368. ngx_feature_test="setsockopt(0, IPPROTO_TCP, TCP_KEEPIDLE, NULL, 0);
  369. setsockopt(0, IPPROTO_TCP, TCP_KEEPINTVL, NULL, 0);
  370. setsockopt(0, IPPROTO_TCP, TCP_KEEPCNT, NULL, 0)"
  371. . auto/feature
  372. ngx_feature="TCP_FASTOPEN"
  373. ngx_feature_name="NGX_HAVE_TCP_FASTOPEN"
  374. ngx_feature_run=no
  375. ngx_feature_incs="#include <sys/socket.h>
  376. #include <netinet/in.h>
  377. #include <netinet/tcp.h>"
  378. ngx_feature_path=
  379. ngx_feature_libs=
  380. ngx_feature_test="setsockopt(0, IPPROTO_TCP, TCP_FASTOPEN, NULL, 0)"
  381. . auto/feature
  382. ngx_feature="TCP_INFO"
  383. ngx_feature_name="NGX_HAVE_TCP_INFO"
  384. ngx_feature_run=no
  385. ngx_feature_incs="#include <sys/socket.h>
  386. #include <netinet/in.h>
  387. #include <netinet/tcp.h>"
  388. ngx_feature_path=
  389. ngx_feature_libs=
  390. ngx_feature_test="socklen_t optlen = sizeof(struct tcp_info);
  391. struct tcp_info ti;
  392. ti.tcpi_rtt = 0;
  393. ti.tcpi_rttvar = 0;
  394. ti.tcpi_snd_cwnd = 0;
  395. ti.tcpi_rcv_space = 0;
  396. getsockopt(0, IPPROTO_TCP, TCP_INFO, &ti, &optlen)"
  397. . auto/feature
  398. ngx_feature="accept4()"
  399. ngx_feature_name="NGX_HAVE_ACCEPT4"
  400. ngx_feature_run=no
  401. ngx_feature_incs="#include <sys/socket.h>"
  402. ngx_feature_path=
  403. ngx_feature_libs=
  404. ngx_feature_test="accept4(0, NULL, NULL, SOCK_NONBLOCK)"
  405. . auto/feature
  406. if [ $NGX_FILE_AIO = YES ]; then
  407. ngx_feature="kqueue AIO support"
  408. ngx_feature_name="NGX_HAVE_FILE_AIO"
  409. ngx_feature_run=no
  410. ngx_feature_incs="#include <aio.h>"
  411. ngx_feature_path=
  412. ngx_feature_libs=
  413. ngx_feature_test="struct aiocb iocb;
  414. iocb.aio_sigevent.sigev_notify = SIGEV_KEVENT;
  415. (void) aio_read(&iocb)"
  416. . auto/feature
  417. if [ $ngx_found = yes ]; then
  418. CORE_SRCS="$CORE_SRCS $FILE_AIO_SRCS"
  419. fi
  420. if [ $ngx_found = no ]; then
  421. ngx_feature="Linux AIO support"
  422. ngx_feature_name="NGX_HAVE_FILE_AIO"
  423. ngx_feature_run=no
  424. ngx_feature_incs="#include <linux/aio_abi.h>
  425. #include <sys/eventfd.h>"
  426. ngx_feature_path=
  427. ngx_feature_libs=
  428. ngx_feature_test="struct iocb iocb;
  429. iocb.aio_lio_opcode = IOCB_CMD_PREAD;
  430. iocb.aio_flags = IOCB_FLAG_RESFD;
  431. iocb.aio_resfd = -1;
  432. (void) iocb;
  433. (void) eventfd(0, 0)"
  434. . auto/feature
  435. if [ $ngx_found = yes ]; then
  436. have=NGX_HAVE_EVENTFD . auto/have
  437. have=NGX_HAVE_SYS_EVENTFD_H . auto/have
  438. CORE_SRCS="$CORE_SRCS $LINUX_AIO_SRCS"
  439. fi
  440. fi
  441. if [ $ngx_found = no ]; then
  442. ngx_feature="Linux AIO support (SYS_eventfd)"
  443. ngx_feature_incs="#include <linux/aio_abi.h>
  444. #include <sys/syscall.h>"
  445. ngx_feature_test="struct iocb iocb;
  446. iocb.aio_lio_opcode = IOCB_CMD_PREAD;
  447. iocb.aio_flags = IOCB_FLAG_RESFD;
  448. iocb.aio_resfd = -1;
  449. (void) iocb;
  450. (void) SYS_eventfd"
  451. . auto/feature
  452. if [ $ngx_found = yes ]; then
  453. have=NGX_HAVE_EVENTFD . auto/have
  454. CORE_SRCS="$CORE_SRCS $LINUX_AIO_SRCS"
  455. fi
  456. fi
  457. if [ $ngx_found = no ]; then
  458. cat << END
  459. $0: no supported file AIO was found
  460. Currently file AIO is supported on FreeBSD 4.3+ and Linux 2.6.22+ only
  461. END
  462. exit 1
  463. fi
  464. else
  465. ngx_feature="eventfd()"
  466. ngx_feature_name="NGX_HAVE_EVENTFD"
  467. ngx_feature_run=no
  468. ngx_feature_incs="#include <sys/eventfd.h>"
  469. ngx_feature_path=
  470. ngx_feature_libs=
  471. ngx_feature_test="(void) eventfd(0, 0)"
  472. . auto/feature
  473. if [ $ngx_found = yes ]; then
  474. have=NGX_HAVE_SYS_EVENTFD_H . auto/have
  475. fi
  476. if [ $ngx_found = no ]; then
  477. ngx_feature="eventfd() (SYS_eventfd)"
  478. ngx_feature_incs="#include <sys/syscall.h>"
  479. ngx_feature_test="(void) SYS_eventfd"
  480. . auto/feature
  481. fi
  482. fi
  483. have=NGX_HAVE_UNIX_DOMAIN . auto/have
  484. ngx_feature_libs=
  485. # C types
  486. ngx_type="int"; . auto/types/sizeof
  487. ngx_type="long"; . auto/types/sizeof
  488. ngx_type="long long"; . auto/types/sizeof
  489. ngx_type="void *"; . auto/types/sizeof; ngx_ptr_size=$ngx_size
  490. ngx_param=NGX_PTR_SIZE; ngx_value=$ngx_size; . auto/types/value
  491. # POSIX types
  492. NGX_INCLUDE_AUTO_CONFIG_H="#include \"ngx_auto_config.h\""
  493. ngx_type="uint32_t"; ngx_types="u_int32_t"; . auto/types/typedef
  494. ngx_type="uint64_t"; ngx_types="u_int64_t"; . auto/types/typedef
  495. ngx_type="sig_atomic_t"; ngx_types="int"; . auto/types/typedef
  496. . auto/types/sizeof
  497. ngx_param=NGX_SIG_ATOMIC_T_SIZE; ngx_value=$ngx_size; . auto/types/value
  498. ngx_type="socklen_t"; ngx_types="int"; . auto/types/typedef
  499. ngx_type="in_addr_t"; ngx_types="uint32_t u_int32_t"; . auto/types/typedef
  500. ngx_type="in_port_t"; ngx_types="u_short"; . auto/types/typedef
  501. ngx_type="rlim_t"; ngx_types="int"; . auto/types/typedef
  502. . auto/types/uintptr_t
  503. . auto/endianness
  504. ngx_type="size_t"; . auto/types/sizeof
  505. ngx_param=NGX_MAX_SIZE_T_VALUE; ngx_value=$ngx_max_value; . auto/types/value
  506. ngx_param=NGX_SIZE_T_LEN; ngx_value=$ngx_max_len; . auto/types/value
  507. ngx_type="off_t"; . auto/types/sizeof
  508. ngx_param=NGX_MAX_OFF_T_VALUE; ngx_value=$ngx_max_value; . auto/types/value
  509. ngx_param=NGX_OFF_T_LEN; ngx_value=$ngx_max_len; . auto/types/value
  510. ngx_type="time_t"; . auto/types/sizeof
  511. ngx_param=NGX_TIME_T_SIZE; ngx_value=$ngx_size; . auto/types/value
  512. ngx_param=NGX_TIME_T_LEN; ngx_value=$ngx_max_len; . auto/types/value
  513. ngx_param=NGX_MAX_TIME_T_VALUE; ngx_value=$ngx_max_value; . auto/types/value
  514. # syscalls, libc calls and some features
  515. ngx_feature="AF_INET6"
  516. ngx_feature_name="NGX_HAVE_INET6"
  517. ngx_feature_run=no
  518. ngx_feature_incs="#include <sys/socket.h>
  519. #include <netinet/in.h>
  520. #include <arpa/inet.h>"
  521. ngx_feature_path=
  522. ngx_feature_libs=
  523. ngx_feature_test="struct sockaddr_in6 sin6;
  524. sin6.sin6_family = AF_INET6;
  525. (void) sin6"
  526. . auto/feature
  527. ngx_feature="setproctitle()"
  528. ngx_feature_name="NGX_HAVE_SETPROCTITLE"
  529. ngx_feature_run=no
  530. ngx_feature_incs="#include <stdlib.h>"
  531. ngx_feature_path=
  532. ngx_feature_libs=$NGX_SETPROCTITLE_LIB
  533. ngx_feature_test="setproctitle(\"test\");"
  534. . auto/feature
  535. ngx_feature="pread()"
  536. ngx_feature_name="NGX_HAVE_PREAD"
  537. ngx_feature_run=no
  538. ngx_feature_incs=
  539. ngx_feature_path=
  540. ngx_feature_libs=
  541. ngx_feature_test="char buf[1]; ssize_t n; n = pread(0, buf, 1, 0);
  542. if (n == -1) return 1"
  543. . auto/feature
  544. ngx_feature="pwrite()"
  545. ngx_feature_name="NGX_HAVE_PWRITE"
  546. ngx_feature_run=no
  547. ngx_feature_incs=
  548. ngx_feature_path=
  549. ngx_feature_libs=
  550. ngx_feature_test="char buf[1]; ssize_t n; n = pwrite(1, buf, 1, 0);
  551. if (n == -1) return 1"
  552. . auto/feature
  553. # pwritev() was introduced in FreeBSD 6 and Linux 2.6.30, glibc 2.10
  554. ngx_feature="pwritev()"
  555. ngx_feature_name="NGX_HAVE_PWRITEV"
  556. ngx_feature_run=no
  557. ngx_feature_incs='#include <sys/uio.h>'
  558. ngx_feature_path=
  559. ngx_feature_libs=
  560. ngx_feature_test="char buf[1]; struct iovec vec[1]; ssize_t n;
  561. vec[0].iov_base = buf;
  562. vec[0].iov_len = 1;
  563. n = pwritev(1, vec, 1, 0);
  564. if (n == -1) return 1"
  565. . auto/feature
  566. ngx_feature="sys_nerr"
  567. ngx_feature_name="NGX_SYS_NERR"
  568. ngx_feature_run=value
  569. ngx_feature_incs='#include <errno.h>
  570. #include <stdio.h>'
  571. ngx_feature_path=
  572. ngx_feature_libs=
  573. ngx_feature_test='printf("%d", sys_nerr);'
  574. . auto/feature
  575. if [ $ngx_found = no ]; then
  576. # Cygiwn defines _sys_nerr
  577. ngx_feature="_sys_nerr"
  578. ngx_feature_name="NGX_SYS_NERR"
  579. ngx_feature_run=value
  580. ngx_feature_incs='#include <errno.h>
  581. #include <stdio.h>'
  582. ngx_feature_path=
  583. ngx_feature_libs=
  584. ngx_feature_test='printf("%d", _sys_nerr);'
  585. . auto/feature
  586. fi
  587. if [ $ngx_found = no ]; then
  588. # Solaris has no sys_nerr
  589. ngx_feature='maximum errno'
  590. ngx_feature_name=NGX_SYS_NERR
  591. ngx_feature_run=value
  592. ngx_feature_incs='#include <errno.h>
  593. #include <string.h>
  594. #include <stdio.h>'
  595. ngx_feature_path=
  596. ngx_feature_libs=
  597. ngx_feature_test='int n;
  598. char *p;
  599. for (n = 1; n < 1000; n++) {
  600. errno = 0;
  601. p = strerror(n);
  602. if (errno == EINVAL
  603. || p == NULL
  604. || strncmp(p, "Unknown error", 13) == 0)
  605. {
  606. break;
  607. }
  608. }
  609. printf("%d", n);'
  610. . auto/feature
  611. fi
  612. ngx_feature="localtime_r()"
  613. ngx_feature_name="NGX_HAVE_LOCALTIME_R"
  614. ngx_feature_run=no
  615. ngx_feature_incs="#include <time.h>"
  616. ngx_feature_path=
  617. ngx_feature_libs=
  618. ngx_feature_test="struct tm t; time_t c=0; localtime_r(&c, &t)"
  619. . auto/feature
  620. ngx_feature="clock_gettime(CLOCK_MONOTONIC)"
  621. ngx_feature_name="NGX_HAVE_CLOCK_MONOTONIC"
  622. ngx_feature_run=no
  623. ngx_feature_incs="#include <time.h>"
  624. ngx_feature_path=
  625. ngx_feature_libs=
  626. ngx_feature_test="struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts)"
  627. . auto/feature
  628. if [ $ngx_found = no ]; then
  629. # Linux before glibc 2.17, notably CentOS 6
  630. ngx_feature="clock_gettime(CLOCK_MONOTONIC) in librt"
  631. ngx_feature_libs="-lrt"
  632. . auto/feature
  633. if [ $ngx_found = yes ]; then
  634. CORE_LIBS="$CORE_LIBS -lrt"
  635. fi
  636. fi
  637. ngx_feature="posix_memalign()"
  638. ngx_feature_name="NGX_HAVE_POSIX_MEMALIGN"
  639. ngx_feature_run=no
  640. ngx_feature_incs="#include <stdlib.h>"
  641. ngx_feature_path=
  642. ngx_feature_libs=
  643. ngx_feature_test="void *p; int n; n = posix_memalign(&p, 4096, 4096);
  644. if (n != 0) return 1"
  645. . auto/feature
  646. ngx_feature="memalign()"
  647. ngx_feature_name="NGX_HAVE_MEMALIGN"
  648. ngx_feature_run=no
  649. ngx_feature_incs="#include <stdlib.h>
  650. #include <malloc.h>"
  651. ngx_feature_path=
  652. ngx_feature_libs=
  653. ngx_feature_test="void *p; p = memalign(4096, 4096);
  654. if (p == NULL) return 1"
  655. . auto/feature
  656. ngx_feature="mmap(MAP_ANON|MAP_SHARED)"
  657. ngx_feature_name="NGX_HAVE_MAP_ANON"
  658. ngx_feature_run=yes
  659. ngx_feature_incs="#include <sys/mman.h>"
  660. ngx_feature_path=
  661. ngx_feature_libs=
  662. ngx_feature_test="void *p;
  663. p = mmap(NULL, 4096, PROT_READ|PROT_WRITE,
  664. MAP_ANON|MAP_SHARED, -1, 0);
  665. if (p == MAP_FAILED) return 1;"
  666. . auto/feature
  667. ngx_feature='mmap("/dev/zero", MAP_SHARED)'
  668. ngx_feature_name="NGX_HAVE_MAP_DEVZERO"
  669. ngx_feature_run=yes
  670. ngx_feature_incs="#include <sys/mman.h>
  671. #include <sys/stat.h>
  672. #include <fcntl.h>"
  673. ngx_feature_path=
  674. ngx_feature_libs=
  675. ngx_feature_test='void *p; int fd;
  676. fd = open("/dev/zero", O_RDWR);
  677. p = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
  678. if (p == MAP_FAILED) return 1;'
  679. . auto/feature
  680. ngx_feature="System V shared memory"
  681. ngx_feature_name="NGX_HAVE_SYSVSHM"
  682. ngx_feature_run=yes
  683. ngx_feature_incs="#include <sys/ipc.h>
  684. #include <sys/shm.h>"
  685. ngx_feature_path=
  686. ngx_feature_libs=
  687. ngx_feature_test="int id;
  688. id = shmget(IPC_PRIVATE, 4096, (SHM_R|SHM_W|IPC_CREAT));
  689. if (id == -1) return 1;
  690. shmctl(id, IPC_RMID, NULL);"
  691. . auto/feature
  692. ngx_feature="POSIX semaphores"
  693. ngx_feature_name="NGX_HAVE_POSIX_SEM"
  694. ngx_feature_run=yes
  695. ngx_feature_incs="#include <semaphore.h>"
  696. ngx_feature_path=
  697. ngx_feature_libs=
  698. ngx_feature_test="sem_t sem;
  699. if (sem_init(&sem, 1, 0) == -1) return 1;
  700. sem_destroy(&sem);"
  701. . auto/feature
  702. if [ $ngx_found = no ]; then
  703. # Linux has POSIX semaphores in libpthread
  704. ngx_feature="POSIX semaphores in libpthread"
  705. ngx_feature_libs=-lpthread
  706. . auto/feature
  707. if [ $ngx_found = yes ]; then
  708. CORE_LIBS="$CORE_LIBS -lpthread"
  709. NGX_LIBPTHREAD="-lpthread"
  710. fi
  711. fi
  712. if [ $ngx_found = no ]; then
  713. # Solaris has POSIX semaphores in librt
  714. ngx_feature="POSIX semaphores in librt"
  715. ngx_feature_libs=-lrt
  716. . auto/feature
  717. if [ $ngx_found = yes ]; then
  718. CORE_LIBS="$CORE_LIBS -lrt"
  719. fi
  720. fi
  721. ngx_feature="struct msghdr.msg_control"
  722. ngx_feature_name="NGX_HAVE_MSGHDR_MSG_CONTROL"
  723. ngx_feature_run=no
  724. ngx_feature_incs="#include <sys/socket.h>
  725. #include <stdio.h>"
  726. ngx_feature_path=
  727. ngx_feature_libs=
  728. ngx_feature_test="struct msghdr msg;
  729. printf(\"%d\", (int) sizeof(msg.msg_control))"
  730. . auto/feature
  731. ngx_feature="ioctl(FIONBIO)"
  732. ngx_feature_name="NGX_HAVE_FIONBIO"
  733. ngx_feature_run=no
  734. ngx_feature_incs="#include <sys/ioctl.h>
  735. #include <stdio.h>
  736. $NGX_INCLUDE_SYS_FILIO_H"
  737. ngx_feature_path=
  738. ngx_feature_libs=
  739. ngx_feature_test="int i = FIONBIO; printf(\"%d\", i)"
  740. . auto/feature
  741. ngx_feature="struct tm.tm_gmtoff"
  742. ngx_feature_name="NGX_HAVE_GMTOFF"
  743. ngx_feature_run=no
  744. ngx_feature_incs="#include <time.h>
  745. #include <stdio.h>"
  746. ngx_feature_path=
  747. ngx_feature_libs=
  748. ngx_feature_test="struct tm tm; tm.tm_gmtoff = 0;
  749. printf(\"%d\", (int) tm.tm_gmtoff)"
  750. . auto/feature
  751. ngx_feature="struct dirent.d_namlen"
  752. ngx_feature_name="NGX_HAVE_D_NAMLEN"
  753. ngx_feature_run=no
  754. ngx_feature_incs="#include <dirent.h>
  755. #include <stdio.h>"
  756. ngx_feature_path=
  757. ngx_feature_libs=
  758. ngx_feature_test="struct dirent dir; dir.d_namlen = 0;
  759. printf(\"%d\", (int) dir.d_namlen)"
  760. . auto/feature
  761. ngx_feature="struct dirent.d_type"
  762. ngx_feature_name="NGX_HAVE_D_TYPE"
  763. ngx_feature_run=no
  764. ngx_feature_incs="#include <dirent.h>
  765. #include <stdio.h>"
  766. ngx_feature_path=
  767. ngx_feature_libs=
  768. ngx_feature_test="struct dirent dir; dir.d_type = DT_REG;
  769. printf(\"%d\", (int) dir.d_type)"
  770. . auto/feature
  771. ngx_feature="sysconf(_SC_NPROCESSORS_ONLN)"
  772. ngx_feature_name="NGX_HAVE_SC_NPROCESSORS_ONLN"
  773. ngx_feature_run=no
  774. ngx_feature_incs=
  775. ngx_feature_path=
  776. ngx_feature_libs=
  777. ngx_feature_test="sysconf(_SC_NPROCESSORS_ONLN)"
  778. . auto/feature
  779. ngx_feature="sysconf(_SC_LEVEL1_DCACHE_LINESIZE)"
  780. ngx_feature_name="NGX_HAVE_LEVEL1_DCACHE_LINESIZE"
  781. ngx_feature_run=no
  782. ngx_feature_incs=
  783. ngx_feature_path=
  784. ngx_feature_libs=
  785. ngx_feature_test="sysconf(_SC_LEVEL1_DCACHE_LINESIZE)"
  786. . auto/feature
  787. ngx_feature="openat(), fstatat()"
  788. ngx_feature_name="NGX_HAVE_OPENAT"
  789. ngx_feature_run=no
  790. ngx_feature_incs="#include <sys/types.h>
  791. #include <sys/stat.h>
  792. #include <fcntl.h>"
  793. ngx_feature_path=
  794. ngx_feature_libs=
  795. ngx_feature_test="struct stat sb;
  796. openat(AT_FDCWD, \".\", O_RDONLY|O_NOFOLLOW);
  797. fstatat(AT_FDCWD, \".\", &sb, AT_SYMLINK_NOFOLLOW);"
  798. . auto/feature
  799. ngx_feature="getaddrinfo()"
  800. ngx_feature_name="NGX_HAVE_GETADDRINFO"
  801. ngx_feature_run=no
  802. ngx_feature_incs="#include <sys/types.h>
  803. #include <sys/socket.h>
  804. #include <netdb.h>"
  805. ngx_feature_path=
  806. ngx_feature_libs=
  807. ngx_feature_test='struct addrinfo *res;
  808. if (getaddrinfo("localhost", NULL, NULL, &res) != 0) return 1;
  809. freeaddrinfo(res)'
  810. . auto/feature