xref: /unit/auto/sendfile (revision 2228:f403dc1e3ec1)
1
2# Copyright (C) Igor Sysoev
3# Copyright (C) NGINX, Inc.
4
5
6NXT_HAVE_LINUX_SENDFILE=NO
7NXT_HAVE_FREEBSD_SENDFILE=NO
8NXT_HAVE_MACOSX_SENDFILE=NO
9NXT_HAVE_SOLARIS_SENDFILEV=NO
10NXT_HAVE_AIX_SEND_FILE=NO
11NXT_HAVE_HPUX_SENDFILE=NO
12
13
14# Linux sendfile().
15
16nxt_feature="Linux sendfile()"
17nxt_feature_name=NXT_HAVE_LINUX_SENDFILE
18nxt_feature_test="#include <sys/sendfile.h>
19
20                  int main(void) {
21                      off_t  offset;
22
23                      sendfile(-1, -1, &offset, 0);
24                      return 0;
25                  }"
26. auto/feature
27
28if [ $nxt_found = yes ]; then
29    NXT_HAVE_LINUX_SENDFILE=YES
30fi
31
32
33if [ $nxt_found = no ]; then
34    # FreeBSD sendfile().
35
36    nxt_feature="FreeBSD sendfile()"
37    nxt_feature_name=NXT_HAVE_FREEBSD_SENDFILE
38    nxt_feature_run=
39    nxt_feature_incs=
40    nxt_feature_libs=
41    nxt_feature_test="#include <sys/types.h>
42                      #include <sys/socket.h>
43                      #include <sys/uio.h>
44                      #include <stdlib.h>
45
46                      int main(void) {
47                          off_t  sent;
48
49                          sendfile(-1, -1, 0, 0, NULL, &sent, 0);
50                          return 0;
51                      }"
52    . auto/feature
53
54    if [ $nxt_found = yes ]; then
55        NXT_HAVE_FREEBSD_SENDFILE=YES
56    fi
57fi
58
59
60if [ $nxt_found = no ]; then
61
62    # MacOSX sendfile().
63
64    nxt_feature="MacOSX sendfile()"
65    nxt_feature_name=NXT_HAVE_MACOSX_SENDFILE
66    nxt_feature_libs=
67    nxt_feature_test="#include <sys/types.h>
68                      #include <sys/socket.h>
69                      #include <sys/uio.h>
70                      #include <stdlib.h>
71
72                      int main(void) {
73                          off_t  sent;
74
75                          sendfile(-1, -1, 0, &sent, NULL, 0);
76                          return 0;
77                      }"
78    . auto/feature
79
80    if [ $nxt_found = yes ]; then
81        NXT_HAVE_MACOSX_SENDFILE=YES
82    fi
83fi
84
85
86if [ $nxt_found = no ]; then
87    # No supported sendfile() found.  Using our replacement.
88    nxt_found=yes
89fi
90
91
92NXT_LIBSENDFILE=
93
94if [ $nxt_found = no ]; then
95
96    # Solaris 8 sendfilev().
97
98    nxt_feature="Solaris sendfilev()"
99    nxt_feature_name=NXT_HAVE_SOLARIS_SENDFILEV
100    nxt_feature_libs="-lsendfile"
101    nxt_feature_test="#include <sys/sendfile.h>
102
103                      int main(void) {
104                          size_t              sent;
105                          struct sendfilevec  vec;
106
107                          sendfilev(-1, &vec, 0, &sent);
108                          return 0;
109                      }"
110    . auto/feature
111
112    if [ $nxt_found = yes ]; then
113        NXT_HAVE_SOLARIS_SENDFILEV=YES
114        NXT_LIBSENDFILE=$nxt_feature_libs
115    fi
116fi
117
118
119if [ $nxt_found = no ]; then
120
121    # AIX send_file().
122
123    nxt_feature="AIX send_file()"
124    nxt_feature_name=NXT_HAVE_AIX_SEND_FILE
125    nxt_feature_test="#include <sys/socket.h>
126
127                      int main(void) {
128                          int              s;
129                          struct sf_parms  sf_iobuf;
130
131                          send_file(&s, &sf_iobuf, 0);
132                          return 0;
133                      }"
134    . auto/feature
135
136    if [ $nxt_found = yes ]; then
137        NXT_HAVE_AIX_SEND_FILE=YES
138    fi
139fi
140
141
142if [ $nxt_found = no ]; then
143
144    # HP-UX sendfile().
145
146    nxt_feature="HP-UX sendfile()"
147    nxt_feature_name=NXT_HAVE_HPUX_SENDFILE
148    nxt_feature_libs=
149    nxt_feature_test="#include <sys/socket.h>
150                      #include <stdlib.h>
151
152                      sbsize_t sendfile(int s, int fd, off_t offset,
153                          bsize_t nbytes, const struct iovec *hdtrl, int flags);
154
155                      int main(void) {
156                          sendfile(-1, -1, 0, 0, NULL, 0);
157                          return 0;
158                      }"
159    . auto/feature
160
161    if [ $nxt_found = yes ]; then
162        NXT_HAVE_HPUX_SENDFILE=YES
163    fi
164fi
165