darwin revision e18a033b
1
2# Copyright (C) Igor Sysoev
3# Copyright (C) Nginx, Inc.
4
5
6have=NGX_DARWIN . auto/have_headers
7
8CORE_INCS="$UNIX_INCS"
9CORE_DEPS="$UNIX_DEPS $DARWIN_DEPS"
10CORE_SRCS="$UNIX_SRCS $DARWIN_SRCS"
11
12
13
14ngx_spacer='
15'
16
17MAIN_LINK=
18MODULE_LINK="-shared -Wl,-undefined,dynamic_lookup"
19
20# kqueue
21
22echo " + kqueue found"
23have=NGX_HAVE_KQUEUE . auto/have
24have=NGX_HAVE_CLEAR_EVENT . auto/have
25EVENT_MODULES="$EVENT_MODULES $KQUEUE_MODULE"
26CORE_SRCS="$CORE_SRCS $KQUEUE_SRCS"
27EVENT_FOUND=YES
28NGX_KQUEUE_CHECKED=YES
29
30ngx_feature="kqueue's EVFILT_TIMER"
31ngx_feature_name="NGX_HAVE_TIMER_EVENT"
32ngx_feature_run=yes
33ngx_feature_incs="#include <sys/event.h>
34                  #include <sys/time.h>"
35ngx_feature_path=
36ngx_feature_libs=
37ngx_feature_test="int      kq;
38                  struct kevent    kev;
39                  struct timespec  ts;
40
41                  if ((kq = kqueue()) == -1) return 1;
42
43                  kev.ident = 0;
44                  kev.filter = EVFILT_TIMER;
45                  kev.flags = EV_ADD|EV_ENABLE;
46                  kev.fflags = 0;
47                  kev.data = 1000;
48                  kev.udata = 0;
49
50                  ts.tv_sec = 0;
51                  ts.tv_nsec = 0;
52
53                  if (kevent(kq, &kev, 1, &kev, 1, &ts) == -1) return 1;
54
55                  if (kev.flags & EV_ERROR) return 1;"
56
57. auto/feature
58
59
60ngx_feature="Darwin 64-bit kqueue millisecond timeout bug"
61ngx_feature_name=NGX_DARWIN_KEVENT_BUG
62ngx_feature_run=bug
63ngx_feature_incs="#include <sys/event.h>
64                  #include <sys/time.h>"
65ngx_feature_path=
66ngx_feature_libs=
67ngx_feature_test="int  kq;
68                  struct kevent    kev;
69                  struct timespec  ts;
70                  struct timeval   tv, tv0;
71
72                  kq = kqueue();
73
74                  ts.tv_sec = 0;
75                  ts.tv_nsec = 999000000;
76
77                  gettimeofday(&tv, 0);
78                  kevent(kq, NULL, 0, &kev, 1, &ts);
79                  gettimeofday(&tv0, 0);
80                  timersub(&tv0, &tv, &tv);
81
82                  if (tv.tv_sec * 1000000 + tv.tv_usec < 900000) return 1;"
83
84. auto/feature
85
86
87# sendfile()
88
89CC_AUX_FLAGS="$CC_AUX_FLAGS"
90ngx_feature="sendfile()"
91ngx_feature_name="NGX_HAVE_SENDFILE"
92ngx_feature_run=yes
93ngx_feature_incs="#include <sys/types.h>
94                  #include <sys/socket.h>
95                  #include <sys/uio.h>
96                  #include <sys/errno.h>"
97ngx_feature_path=
98ngx_feature_libs=
99ngx_feature_test="int s = 0, fd = 1;
100                  off_t n; off_t off = 0;
101                  n = sendfile(s, fd, off, &n, NULL, 0);
102                  if (n == -1 && errno == ENOSYS) return 1"
103. auto/feature
104
105if [ $ngx_found = yes ]; then
106    CORE_SRCS="$CORE_SRCS $DARWIN_SENDFILE_SRCS"
107fi
108
109
110ngx_feature="atomic(3)"
111ngx_feature_name=NGX_DARWIN_ATOMIC
112ngx_feature_run=no
113ngx_feature_incs="#include <libkern/OSAtomic.h>"
114ngx_feature_path=
115ngx_feature_libs=
116ngx_feature_test="int32_t  lock = 0;
117                  if (!OSAtomicCompareAndSwap32Barrier(0, 1, &lock)) return 1"
118. auto/feature
119