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

Last change on this file since 12189 was 12189, checked in by certainty, 12 years ago

added conditional to detect cygwin and disable madvise in this case.

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