source: project/release/3/sendfile/trunk/os-dep.h @ 10723

Last change on this file since 10723 was 10723, checked in by Kon Lovett, 13 years ago

Support for Darwin 9.0 (MacOS X 10.5), fixed wrong arg order in sendfile C impl, added errno to sendfile error, made sendfile error a composite conditionSupport for Darwin 9.0 (MacOS X 10.5), fixed wrong arg order in sendfile C impl, added errno to sendfile error, made sendfile error a composite condition.Support for Darwin 9.0 (MacOS X 10.5), fixed wrong arg order in sendfile C impl, added errno to sendfile error, made sendfile error a composite condition..

File size: 2.5 KB
Line 
1/* NetBSD hat kein sendfile() also mmaped oder read-write*/
2/* linux ab 2.4 haben sendfile fuer >= 2.6 sendfile funktioniert nur fuer socket */
3/* freebsd ab 3.0 haben sendfile */
4/* solaris ab 8.0 haben sendfilev */
5/* windows NT hat TransmitFile */
6/* MacOS 10.5 haben sendfile */
7
8#include <chicken.h>
9
10#ifdef MADV_SEQUENTIAL
11#define HAVE_MADVISE 1
12#else
13#define HAVE_MADVISE 0
14#endif
15
16#ifdef __linux
17
18 #include <sys/types.h>
19 #include <unistd.h>
20 #include <sys/sendfile.h>
21 #include <sys/mman.h>
22 #include <linux/version.h>
23 #include <fcntl.h>
24
25 double sendfile_implementation(int src,int dst,double offset,size_t to_send);
26
27 #define HAVE_SENDFILE 1
28 #define HAVE_MMAP 1
29 #define USE_LINUX_IMPL
30 #define _XOPEN_SOURCE 600
31 #if defined(POSIX_FADV_SEQUENTIAL) && defined(POSIX_FADV_NOREUSE)
32  #define HAVE_POSIX_FADVISE
33 #endif
34
35#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
36
37 #include <sys/socket.h>
38 #include <sys/types.h>
39 #include <sys/mman.h>
40
41 double sendfile_implementation(int src,int dst,double offset,size_t to_send);
42 #define USE_BSD_IMPL
43 #define HAVE_MMAP 1
44 #if (defined(__FreeBSD__) && (__FreeBSD__ >= 3)) || defined(__DragonFly__)
45  #define HAVE_SENDFILE 1
46  #include <sys/uio.h>
47 #else
48  #define HAVE_SENDFILE 0
49 #endif
50
51#elif (defined(__APPLE__) && defined(__MACH__))
52
53 #include <sys/types.h>
54 #include <sys/socket.h>
55 #include <sys/uio.h>
56 #include <sys/mman.h>
57
58 double sendfile_implementation(int src,int dst,double offset,size_t to_send);
59 #define HAVE_MMAP 1
60
61 /* Not foolproof but does stop compilation when < MacOS 10.5
62  * Should also state that the MIN_ALLOWED is 10.5 but that requires
63  * compiler option setting.
64  */
65 #include <AvailabilityMacros.h>
66 #if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_4
67   #define HAVE_SENDFILE 1
68   #define USE_DARWIN_IMPL
69 #else
70   #define HAVE_SENDFILE 0
71 #endif
72
73#elif defined(sun) || defined(__sun)
74
75 double sendfile_implementation(int src,int dst,double offset,size_t to_send);
76 #ifdef __SunOS_5_8
77   #define HAVE_SENDFILE 1
78   #define HAVE_MMAP 1
79   #define USE_SOLARIS_IMPL
80   #include <sys/sendfile.h>
81   #include <sys/mman.h>
82 #else
83   #define HAVE_SENDFILE 0
84 #endif
85
86#elif defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__)
87
88 #define MADV_SEQUENTIAL 0
89 #define HAVE_SENDFILE 0
90 #define HAVE_MMAP 0
91 double sendfile_implementation(int src,int dst,double offset,int to_send);
92
93#else
94
95 #define MADV_SEQUENTIAL 0
96 #define HAVE_SENDFILE 0
97 #define HAVE_MMAP 0
98 double sendfile_implementation(int src,int dst,double offset,size_t to_send);
99
100#endif
101
102
103
104
105
106
107
108
Note: See TracBrowser for help on using the repository browser.