xref: /unit/auto/sockets (revision 0:a63ceefd6ab0)
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
161
162nxt_feature="sys/filio.h"
163nxt_feature_name=NXT_HAVE_SYS_FILIO_H
164nxt_feature_run=
165nxt_feature_incs=
166nxt_feature_libs=
167nxt_feature_test="#include <sys/filio.h>
168
169                  int main() {
170                      return 0;
171                  }"
172. auto/feature
173
174if [ $nxt_found = yes ]; then
175    NXT_SYS_FILIO_H="#include <sys/filio.h>"
176else
177    NXT_SYS_FILIO_H=
178fi
179
180
181nxt_feature="ioctl(FIONBIO)"
182nxt_feature_name=NXT_HAVE_FIONBIO
183nxt_feature_run=
184nxt_feature_incs=
185nxt_feature_libs=
186nxt_feature_test="#include <unistd.h>
187                  #include <sys/socket.h>
188                  $NXT_SYS_FILIO_H
189                  #include <sys/ioctl.h>
190
191                  int main() {
192                      int  nb;
193
194                      nb = 0;
195                      ioctl(-1, FIONBIO, &nb);
196                      return 0;
197                  }"
198. auto/feature
199
200
201# socket(SOCK_NONBLOCK), Linux 2.6.27/glibc 2.10, NetBSD 6.0, FreeBSD 9.2.
202
203nxt_feature="socket(SOCK_NONBLOCK)"
204nxt_feature_name=NXT_HAVE_SOCK_NONBLOCK
205nxt_feature_run=
206nxt_feature_incs=
207nxt_feature_libs=
208nxt_feature_test="#define _GNU_SOURCE
209                  #include <sys/socket.h>
210
211                  int main() {
212                      socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0);
213                      return 0;
214                  }"
215. auto/feature
216
217
218# accept4(), Linux 2.6.28/glibc 2.10, NetBSD 6.0, FreeBSD 9.2.
219
220nxt_feature="accept4()"
221nxt_feature_name=NXT_HAVE_ACCEPT4
222nxt_feature_run=
223nxt_feature_incs=
224nxt_feature_libs=
225nxt_feature_test="#define _GNU_SOURCE
226                  #include <stdlib.h>
227                  #include <sys/socket.h>
228
229                  int main() {
230                      accept4(0, NULL, NULL, SOCK_NONBLOCK);
231                      return 0;
232                  }"
233. auto/feature
234