xref: /unit/auto/sockets (revision 1996:35873fa78fed)
1
2# Copyright (C) Igor Sysoev
3# Copyright (C) NGINX, Inc.
4
5
6if [ $NXT_INET6 = YES ]; then
7
8    nxt_feature="AF_INET6"
9    nxt_feature_name=NXT_INET6
10    nxt_feature_run=
11    nxt_feature_incs=
12    nxt_feature_libs=
13    nxt_feature_test="#include <stdio.h>
14                      #include <sys/socket.h>
15                      #include <sys/types.h>
16                      #include <netinet/in.h>
17
18                      int main() {
19                          struct sockaddr_in6  sin6;
20
21                          sin6.sin6_family = AF_INET6;
22                          printf(\"%d\", sin6.sin6_family);
23                          return 0;
24                      }"
25    . auto/feature
26fi
27
28
29# FreeBSD, MacOSX, NetBSD, OpenBSD.
30
31nxt_feature="sockaddr.sa_len"
32nxt_feature_name=NXT_SOCKADDR_SA_LEN
33nxt_feature_run=
34nxt_feature_incs=
35nxt_feature_libs=
36nxt_feature_test="#include <stdio.h>
37                  #include <sys/socket.h>
38
39                  int main() {
40                      struct sockaddr  sa;
41
42                      sa.sa_len = 0;
43                      printf(\"%d\", sa.sa_len);
44                      return 0;
45                  }"
46. auto/feature
47
48
49nxt_feature="struct sockaddr size"
50nxt_feature_name=NXT_HAVE_SOCKADDR
51nxt_feature_run=value
52nxt_feature_incs=
53nxt_feature_libs=
54nxt_feature_test="#include <stdio.h>
55                  #include <sys/socket.h>
56
57                  int main() {
58                      printf(\"%d\", (int) sizeof(struct sockaddr));
59                      return 0;
60                  }"
61. auto/feature
62
63
64nxt_feature="struct sockaddr_in size"
65nxt_feature_name=NXT_HAVE_SOCKADDR_IN
66nxt_feature_run=value
67nxt_feature_incs=
68nxt_feature_libs=
69nxt_feature_test="#include <stdio.h>
70                  #include <sys/types.h>
71                  #include <netinet/in.h>
72
73                  int main() {
74                      printf(\"%d\", (int) sizeof(struct sockaddr_in));
75                      return 0;
76                  }"
77. auto/feature
78
79
80nxt_feature="struct sockaddr_in6 size"
81nxt_feature_name=NXT_HAVE_SOCKADDR_IN6
82nxt_feature_run=value
83nxt_feature_incs=
84nxt_feature_libs=
85nxt_feature_test="#include <stdio.h>
86                  #include <sys/types.h>
87                  #include <netinet/in.h>
88
89                  int main() {
90                      printf(\"%d\", (int) sizeof(struct sockaddr_in6));
91                      return 0;
92                  }"
93. auto/feature
94
95
96nxt_feature="struct sockaddr_un size"
97nxt_feature_name=NXT_HAVE_SOCKADDR_UN
98nxt_feature_run=value
99nxt_feature_incs=
100nxt_feature_libs=
101nxt_feature_test="#include <stdio.h>
102                  #include <sys/types.h>
103                  #include <sys/un.h>
104
105                  int main() {
106                      printf(\"%d\", (int) sizeof(struct sockaddr_un));
107                      return 0;
108                  }"
109. auto/feature
110
111
112nxt_feature="struct sockaddr_storage size"
113nxt_feature_name=NXT_HAVE_SOCKADDR_STORAGE
114nxt_feature_run=value
115nxt_feature_incs=
116nxt_feature_libs=
117nxt_feature_test="#include <stdio.h>
118                  #include <sys/socket.h>
119
120                  int main() {
121                      printf(\"%d\", (int) sizeof(struct sockaddr_storage));
122                      return 0;
123                  }"
124. auto/feature
125
126
127nxt_feature="socketpair(AF_UNIX, SOCK_SEQPACKET)"
128nxt_feature_name=NXT_HAVE_AF_UNIX_SOCK_SEQPACKET
129nxt_feature_run=yes
130nxt_feature_incs=
131nxt_feature_libs=
132nxt_feature_test="#include <stdio.h>
133                  #include <sys/socket.h>
134
135                  int main() {
136                      int  pair[2];
137
138                      if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, pair) != 0)
139                          return 1;
140                      return 0;
141                  }"
142. auto/feature
143
144
145nxt_feature="struct msghdr.msg_control"
146nxt_feature_name=NXT_HAVE_MSGHDR_MSG_CONTROL
147nxt_feature_run=
148nxt_feature_incs=
149nxt_feature_libs=
150nxt_feature_test="#include <stdio.h>
151                  #include <sys/socket.h>
152
153                  int main() {
154                      struct  msghdr  msg;
155
156                      printf(\"%d\", (int) sizeof(msg.msg_control));
157                      return 0;
158                  }"
159. auto/feature
160
161if [ $nxt_found = no ]; then
162    $echo
163    $echo $0: error: no msghdr.msg_control struct member.
164    $echo
165    exit 1;
166fi
167
168
169nxt_feature="sockopt SO_PASSCRED"
170nxt_feature_name=NXT_HAVE_SOCKOPT_SO_PASSCRED
171nxt_feature_run=
172nxt_feature_incs=
173nxt_feature_libs=
174nxt_feature_test="#define _GNU_SOURCE
175                  #include <sys/socket.h>
176
177                  int main() {
178                      return SO_PASSCRED == 0;
179                  }"
180. auto/feature
181
182
183if [ $nxt_found = yes ]; then
184    nxt_feature="struct ucred"
185    nxt_feature_name=NXT_HAVE_UCRED
186    nxt_feature_run=
187    nxt_feature_incs=
188    nxt_feature_libs=
189    nxt_feature_test="#define _GNU_SOURCE
190                      #include <sys/socket.h>
191                      #include <sys/un.h>
192
193                      int main() {
194                          return sizeof(struct ucred);
195                      }"
196    . auto/feature
197fi
198
199
200nxt_feature="struct cmsgcred"
201nxt_feature_name=NXT_HAVE_MSGHDR_CMSGCRED
202nxt_feature_run=
203nxt_feature_incs=
204nxt_feature_libs=
205nxt_feature_test="#define _GNU_SOURCE
206                  #include <sys/socket.h>
207
208                  int main() {
209                      return sizeof(struct cmsgcred);
210                  }"
211. auto/feature
212
213
214nxt_feature="sys/filio.h"
215nxt_feature_name=NXT_HAVE_SYS_FILIO_H
216nxt_feature_run=
217nxt_feature_incs=
218nxt_feature_libs=
219nxt_feature_test="#include <sys/filio.h>
220
221                  int main() {
222                      return 0;
223                  }"
224. auto/feature
225
226if [ $nxt_found = yes ]; then
227    NXT_SYS_FILIO_H="#include <sys/filio.h>"
228else
229    NXT_SYS_FILIO_H=
230fi
231
232
233nxt_feature="ioctl(FIONBIO)"
234nxt_feature_name=NXT_HAVE_FIONBIO
235nxt_feature_run=
236nxt_feature_incs=
237nxt_feature_libs=
238nxt_feature_test="#include <unistd.h>
239                  #include <sys/socket.h>
240                  $NXT_SYS_FILIO_H
241                  #include <sys/ioctl.h>
242
243                  int main() {
244                      int  nb;
245
246                      nb = 0;
247                      ioctl(-1, FIONBIO, &nb);
248                      return 0;
249                  }"
250. auto/feature
251
252
253# socket(SOCK_NONBLOCK), Linux 2.6.27/glibc 2.10, NetBSD 6.0, FreeBSD 9.2.
254
255nxt_feature="socket(SOCK_NONBLOCK)"
256nxt_feature_name=NXT_HAVE_SOCK_NONBLOCK
257nxt_feature_run=
258nxt_feature_incs=
259nxt_feature_libs=
260nxt_feature_test="#define _GNU_SOURCE
261                  #include <sys/socket.h>
262
263                  int main() {
264                      socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
265                      return 0;
266                  }"
267. auto/feature
268
269
270# accept4(), Linux 2.6.28/glibc 2.10, NetBSD 6.0, FreeBSD 9.2.
271
272nxt_feature="accept4()"
273nxt_feature_name=NXT_HAVE_ACCEPT4
274nxt_feature_run=
275nxt_feature_incs=
276nxt_feature_libs=
277nxt_feature_test="#define _GNU_SOURCE
278                  #include <stdlib.h>
279                  #include <sys/socket.h>
280
281                  int main() {
282                      accept4(0, NULL, NULL, SOCK_NONBLOCK);
283                      return 0;
284                  }"
285. auto/feature
286