unix (676:24e245cc1d4e) unix (732:ab017ff0ee67)
1
2# Copyright (C) Igor Sysoev
3# Copyright (C) NGINX, Inc.
4
5
1
2# Copyright (C) Igor Sysoev
3# Copyright (C) NGINX, Inc.
4
5
6# getrandom().
6# Linux 3.17 with glibc 2.25, FreeBSD 12, Solaris 11.3.
7
8nxt_feature="getrandom()"
9nxt_feature_name=NXT_HAVE_GETRANDOM
10nxt_feature_run=yes
11nxt_feature_incs=
12nxt_feature_libs=
13nxt_feature_test="#include <unistd.h>
14 #include <sys/random.h>
15
16 int main() {
17 char buf[4];
18
19 if (getrandom(buf, 4, 0) < 0) {
20 return 1;
21 }
22
23 return 0;
24 }"
25. auto/feature
26
27
28if [ $nxt_found = no ]; then
29
30 # Linux 3.17 SYS_getrandom.
31
32 nxt_feature="SYS_getrandom in Linux"
33 nxt_feature_name=NXT_HAVE_LINUX_SYS_GETRANDOM
34 nxt_feature_test="#include <unistd.h>
35 #include <sys/syscall.h>
36 #include <linux/random.h>
37
38 int main() {
39 char buf[4];
40
41 if (syscall(SYS_getrandom, buf, 4, 0) < 0) {
42 return 1;
43 }
44
45 return 0;
46 }"
47 . auto/feature
48fi
49
50
51nxt_feature="ucontext"
52nxt_feature_name=NXT_HAVE_UCONTEXT
53nxt_feature_run=
54nxt_feature_incs=
55nxt_feature_libs=
56nxt_feature_test="#include <stdlib.h>
57 #include <ucontext.h>
58
59 int main() {
60 ucontext_t uc;
61
62 if (getcontext(&uc) == 0) {
63 makecontext(&uc, NULL, 0);
64 setcontext(&uc);
65 }
66
67 return 0;
68 }"
69. auto/feature
70
71
72if [ $nxt_found = no ]; then
73
74 # MacOSX 10.6 (Snow Leopard) has deprecated ucontext
75 # and requires _XOPEN_SOURCE to be defined.
76
77 nxt_feature="_XOPEN_SOURCE ucontext"
78 nxt_feature_name=NXT_HAVE_UCONTEXT
79 nxt_feature_run=
80 nxt_feature_incs=
81 nxt_feature_libs=
82 nxt_feature_test="#define _XOPEN_SOURCE
83 #include <stdlib.h>
84 #include <ucontext.h>
85
86 int main() {
87 ucontext_t uc;
88
89 if (getcontext(&uc) == 0) {
90 makecontext(&uc, NULL, 0);
91 setcontext(&uc);
92 }
93
94 return 0;
95 }"
96 . auto/feature
97fi
98
99
100# FreeBSD dlopen() is in libc.
101# MacOSX libdl.dylib is a symlink to libSystem.dylib.
102# GCC5 AddressSanitizer intercepts dlopen() and dlclose() but not dlsym()
103# so all dynamic linker functions should be tested.
104
105NXT_LIBDL=
106
107nxt_feature="dlopen()"
108nxt_feature_name=NXT_HAVE_DLOPEN
109nxt_feature_run=
110nxt_feature_incs=
111nxt_feature_libs=
112nxt_feature_test="#include <stdlib.h>
113 #include <dlfcn.h>
114
115 int main() {
116 void *h = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL);
117 dlsym(h, \"\");
118 dlclose(h);
119 return 0;
120 }"
121. auto/feature
122
123if [ $nxt_found = no ]; then
124
125 # Linux and Solaris prior to 10 require libdl.
126 # Solaris 10 libdl.so.1 is a filter to /usr/lib/ld.so.1.
127
128 nxt_feature="dlopen() in libdl"
129 nxt_feature_libs="-ldl"
130 . auto/feature
131
132 if [ $nxt_found = yes ]; then
133 NXT_LIBDL="-ldl"
134 fi
135fi
136
137
138nxt_feature="posix_spawn()"
139nxt_feature_name=NXT_HAVE_POSIX_SPAWN
140nxt_feature_run=
141nxt_feature_incs=
142nxt_feature_libs=
143nxt_feature_test="#include <spawn.h>
144 #include <unistd.h>
145
146 int main() {
147 (void) posix_spawn(NULL, NULL, NULL, NULL, NULL, NULL);
148 return 0;
149 }"
150. auto/feature
151
152
153# NetBSD 1.0, OpenBSD 1.0, FreeBSD 2.2 setproctitle().
154
155nxt_feature="setproctitle()"
156nxt_feature_name=NXT_HAVE_SETPROCTITLE
157nxt_feature_run=
158nxt_feature_incs=
159nxt_feature_libs=
160nxt_feature_test="#include <stdlib.h>
161 #include <unistd.h>
162
163 int main() {
164 setproctitle(\"%s\", \"title\");
165 return 0;
166 }"
167. auto/feature
7
8nxt_feature="getrandom()"
9nxt_feature_name=NXT_HAVE_GETRANDOM
10nxt_feature_run=yes
11nxt_feature_incs=
12nxt_feature_libs=
13nxt_feature_test="#include <unistd.h>
14 #include <sys/random.h>
15
16 int main() {
17 char buf[4];
18
19 if (getrandom(buf, 4, 0) < 0) {
20 return 1;
21 }
22
23 return 0;
24 }"
25. auto/feature
26
27
28if [ $nxt_found = no ]; then
29
30 # Linux 3.17 SYS_getrandom.
31
32 nxt_feature="SYS_getrandom in Linux"
33 nxt_feature_name=NXT_HAVE_LINUX_SYS_GETRANDOM
34 nxt_feature_test="#include <unistd.h>
35 #include <sys/syscall.h>
36 #include <linux/random.h>
37
38 int main() {
39 char buf[4];
40
41 if (syscall(SYS_getrandom, buf, 4, 0) < 0) {
42 return 1;
43 }
44
45 return 0;
46 }"
47 . auto/feature
48fi
49
50
51nxt_feature="ucontext"
52nxt_feature_name=NXT_HAVE_UCONTEXT
53nxt_feature_run=
54nxt_feature_incs=
55nxt_feature_libs=
56nxt_feature_test="#include <stdlib.h>
57 #include <ucontext.h>
58
59 int main() {
60 ucontext_t uc;
61
62 if (getcontext(&uc) == 0) {
63 makecontext(&uc, NULL, 0);
64 setcontext(&uc);
65 }
66
67 return 0;
68 }"
69. auto/feature
70
71
72if [ $nxt_found = no ]; then
73
74 # MacOSX 10.6 (Snow Leopard) has deprecated ucontext
75 # and requires _XOPEN_SOURCE to be defined.
76
77 nxt_feature="_XOPEN_SOURCE ucontext"
78 nxt_feature_name=NXT_HAVE_UCONTEXT
79 nxt_feature_run=
80 nxt_feature_incs=
81 nxt_feature_libs=
82 nxt_feature_test="#define _XOPEN_SOURCE
83 #include <stdlib.h>
84 #include <ucontext.h>
85
86 int main() {
87 ucontext_t uc;
88
89 if (getcontext(&uc) == 0) {
90 makecontext(&uc, NULL, 0);
91 setcontext(&uc);
92 }
93
94 return 0;
95 }"
96 . auto/feature
97fi
98
99
100# FreeBSD dlopen() is in libc.
101# MacOSX libdl.dylib is a symlink to libSystem.dylib.
102# GCC5 AddressSanitizer intercepts dlopen() and dlclose() but not dlsym()
103# so all dynamic linker functions should be tested.
104
105NXT_LIBDL=
106
107nxt_feature="dlopen()"
108nxt_feature_name=NXT_HAVE_DLOPEN
109nxt_feature_run=
110nxt_feature_incs=
111nxt_feature_libs=
112nxt_feature_test="#include <stdlib.h>
113 #include <dlfcn.h>
114
115 int main() {
116 void *h = dlopen(NULL, RTLD_NOW | RTLD_GLOBAL);
117 dlsym(h, \"\");
118 dlclose(h);
119 return 0;
120 }"
121. auto/feature
122
123if [ $nxt_found = no ]; then
124
125 # Linux and Solaris prior to 10 require libdl.
126 # Solaris 10 libdl.so.1 is a filter to /usr/lib/ld.so.1.
127
128 nxt_feature="dlopen() in libdl"
129 nxt_feature_libs="-ldl"
130 . auto/feature
131
132 if [ $nxt_found = yes ]; then
133 NXT_LIBDL="-ldl"
134 fi
135fi
136
137
138nxt_feature="posix_spawn()"
139nxt_feature_name=NXT_HAVE_POSIX_SPAWN
140nxt_feature_run=
141nxt_feature_incs=
142nxt_feature_libs=
143nxt_feature_test="#include <spawn.h>
144 #include <unistd.h>
145
146 int main() {
147 (void) posix_spawn(NULL, NULL, NULL, NULL, NULL, NULL);
148 return 0;
149 }"
150. auto/feature
151
152
153# NetBSD 1.0, OpenBSD 1.0, FreeBSD 2.2 setproctitle().
154
155nxt_feature="setproctitle()"
156nxt_feature_name=NXT_HAVE_SETPROCTITLE
157nxt_feature_run=
158nxt_feature_incs=
159nxt_feature_libs=
160nxt_feature_test="#include <stdlib.h>
161 #include <unistd.h>
162
163 int main() {
164 setproctitle(\"%s\", \"title\");
165 return 0;
166 }"
167. auto/feature