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