summaryrefslogtreecommitdiffhomepage
path: root/auto/sendfile
blob: abbda6c7c0f79b7d8f8353efb8b1509608395622 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164

# Copyright (C) Igor Sysoev
# Copyright (C) NGINX, Inc.


NXT_HAVE_LINUX_SENDFILE=NO
NXT_HAVE_FREEBSD_SENDFILE=NO
NXT_HAVE_MACOSX_SENDFILE=NO
NXT_HAVE_SOLARIS_SENDFILEV=NO
NXT_HAVE_AIX_SEND_FILE=NO
NXT_HAVE_HPUX_SENDFILE=NO


# Linux sendfile().

nxt_feature="Linux sendfile()"
nxt_feature_name=NXT_HAVE_LINUX_SENDFILE
nxt_feature_test="#include <sys/sendfile.h>

                  int main(void) {
                      off_t  offset;

                      sendfile(-1, -1, &offset, 0);
                      return 0;
                  }"
. auto/feature

if [ $nxt_found = yes ]; then
    NXT_HAVE_LINUX_SENDFILE=YES
fi


if [ $nxt_found = no ]; then
    # FreeBSD sendfile().

    nxt_feature="FreeBSD sendfile()"
    nxt_feature_name=NXT_HAVE_FREEBSD_SENDFILE
    nxt_feature_run=
    nxt_feature_incs=
    nxt_feature_libs=
    nxt_feature_test="#include <sys/types.h>
                      #include <sys/socket.h>
                      #include <sys/uio.h>
                      #include <stdlib.h>

                      int main(void) {
                          off_t  sent;

                          sendfile(-1, -1, 0, 0, NULL, &sent, 0);
                          return 0;
                      }"
    . auto/feature

    if [ $nxt_found = yes ]; then
        NXT_HAVE_FREEBSD_SENDFILE=YES
    fi
fi


if [ $nxt_found = no ]; then

    # MacOSX sendfile().

    nxt_feature="MacOSX sendfile()"
    nxt_feature_name=NXT_HAVE_MACOSX_SENDFILE
    nxt_feature_libs=
    nxt_feature_test="#include <sys/types.h>
                      #include <sys/socket.h>
                      #include <sys/uio.h>
                      #include <stdlib.h>

                      int main(void) {
                          off_t  sent;

                          sendfile(-1, -1, 0, &sent, NULL, 0);
                          return 0;
                      }"
    . auto/feature

    if [ $nxt_found = yes ]; then
        NXT_HAVE_MACOSX_SENDFILE=YES
    fi
fi


if [ $nxt_found = no ]; then
    # No supported sendfile() found.  Using our replacement.
    nxt_found=yes
fi


NXT_LIBSENDFILE=

if [ $nxt_found = no ]; then

    # Solaris 8 sendfilev().

    nxt_feature="Solaris sendfilev()"
    nxt_feature_name=NXT_HAVE_SOLARIS_SENDFILEV
    nxt_feature_libs="-lsendfile"
    nxt_feature_test="#include <sys/sendfile.h>

                      int main(void) {
                          size_t              sent;
                          struct sendfilevec  vec;

                          sendfilev(-1, &vec, 0, &sent);
                          return 0;
                      }"
    . auto/feature

    if [ $nxt_found = yes ]; then
        NXT_HAVE_SOLARIS_SENDFILEV=YES
        NXT_LIBSENDFILE=$nxt_feature_libs
    fi
fi


if [ $nxt_found = no ]; then

    # AIX send_file().

    nxt_feature="AIX send_file()"
    nxt_feature_name=NXT_HAVE_AIX_SEND_FILE
    nxt_feature_test="#include <sys/socket.h>

                      int main(void) {
                          int              s;
                          struct sf_parms  sf_iobuf;

                          send_file(&s, &sf_iobuf, 0);
                          return 0;
                      }"
    . auto/feature

    if [ $nxt_found = yes ]; then
        NXT_HAVE_AIX_SEND_FILE=YES
    fi
fi


if [ $nxt_found = no ]; then

    # HP-UX sendfile().

    nxt_feature="HP-UX sendfile()"
    nxt_feature_name=NXT_HAVE_HPUX_SENDFILE
    nxt_feature_libs=
    nxt_feature_test="#include <sys/socket.h>
                      #include <stdlib.h>

                      sbsize_t sendfile(int s, int fd, off_t offset,
                          bsize_t nbytes, const struct iovec *hdtrl, int flags);

                      int main(void) {
                          sendfile(-1, -1, 0, 0, NULL, 0);
                          return 0;
                      }"
    . auto/feature

    if [ $nxt_found = yes ]; then
        NXT_HAVE_HPUX_SENDFILE=YES
    fi
fi