xref: /unit/auto/sendfile (revision 0:a63ceefd6ab0)
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() {
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() {
47                          off_t  sent;
48
49                          sendfile(-1, -1, 0, 0, NULL, &sent, SF_NODISKIO);
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
60NXT_LIBSENDFILE=
61
62if [ $nxt_found = no ]; then
63
64    # Solaris 8 sendfilev().
65
66    nxt_feature="Solaris sendfilev()"
67    nxt_feature_name=NXT_HAVE_SOLARIS_SENDFILEV
68    nxt_feature_libs="-lsendfile"
69    nxt_feature_test="#include <sys/sendfile.h>
70
71                      int main() {
72                          size_t              sent;
73                          struct sendfilevec  vec;
74
75                          sendfilev(-1, &vec, 0, &sent);
76                          return 0;
77                      }"
78    . auto/feature
79
80    if [ $nxt_found = yes ]; then
81        NXT_HAVE_SOLARIS_SENDFILEV=YES
82        NXT_LIBSENDFILE=$nxt_feature_libs
83    fi
84fi
85
86
87if [ $nxt_found = no ]; then
88
89    # MacOSX sendfile().
90
91    nxt_feature="MacOSX sendfile()"
92    nxt_feature_name=NXT_HAVE_MACOSX_SENDFILE
93    nxt_feature_libs=
94    nxt_feature_test="#include <sys/types.h>
95                      #include <sys/socket.h>
96                      #include <sys/uio.h>
97                      #include <stdlib.h>
98
99                      int main() {
100                          off_t  sent;
101
102                          sendfile(-1, -1, 0, &sent, NULL, 0);
103                          return 0;
104                      }"
105    . auto/feature
106
107    if [ $nxt_found = yes ]; then
108        NXT_HAVE_MACOSX_SENDFILE=YES
109    fi
110fi
111
112
113if [ $nxt_found = no ]; then
114
115    # AIX send_file().
116
117    nxt_feature="AIX send_file()"
118    nxt_feature_name=NXT_HAVE_AIX_SEND_FILE
119    nxt_feature_test="#include <sys/socket.h>
120
121                      int main() {
122                          int              s;
123                          struct sf_parms  sf_iobuf;
124
125                          send_file(&s, &sf_iobuf, 0);
126                          return 0;
127                      }"
128    . auto/feature
129
130    if [ $nxt_found = yes ]; then
131        NXT_HAVE_AIX_SEND_FILE=YES
132    fi
133fi
134
135
136if [ $nxt_found = no ]; then
137
138    # HP-UX sendfile().
139
140    nxt_feature="HP-UX sendfile()"
141    nxt_feature_name=NXT_HAVE_HPUX_SENDFILE
142    nxt_feature_libs=
143    nxt_feature_test="#include <sys/socket.h>
144                      #include <stdlib.h>
145
146                      sbsize_t sendfile(int s, int fd, off_t offset,
147                          bsize_t nbytes, const struct iovec *hdtrl, int flags);
148
149                      int main() {
150                          sendfile(-1, -1, 0, 0, NULL, 0);
151                          return 0;
152                      }"
153    . auto/feature
154
155    if [ $nxt_found = yes ]; then
156        NXT_HAVE_HPUX_SENDFILE=YES
157    fi
158fi
159