source: project/release/4/sendfile/trunk/os-dep.h @ 20451

Last change on this file since 20451 was 20451, checked in by sjamaan, 9 years ago

Fix missing HAVE_MMAP 0 definition bug in fallback clause for Solaris. This does not fix the other bug that causes it to switch to that clause in the first place (because newer Solarises do have sendfile and mmap)

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