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