1 // $Id: OS_NS_sys_sendfile.cpp 80826 2008-03-04 14:51:23Z wotte $
3 #include "ace/OS_NS_sys_sendfile.h"
4 #include "ace/OS_NS_sys_mman.h"
6 #if defined (ACE_WIN32) || defined (HPUX)
7 # include "ace/OS_NS_sys_socket.h"
9 # include "ace/OS_NS_unistd.h"
10 #endif /* ACE_WIN32 || HPUX */
12 #ifndef ACE_HAS_INLINED_OSCALLS
13 # include "ace/OS_NS_sys_sendfile.inl"
14 #endif /* ACE_HAS_INLINED_OSCALLS */
16 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
18 #ifndef ACE_HAS_SENDFILE
20 ACE_OS::sendfile_emulation (ACE_HANDLE out_fd
,
25 // @@ Is it possible to inline a call to ::TransmitFile() on
26 // MS Windows instead of emulating here?
28 // @@ We may want set up a signal lease (or oplock) if supported by
29 // the platform so that we don't get a bus error if the mmap()ed
32 ACE_OS::mmap (0, count
, PROT_READ
, MAP_SHARED
, in_fd
, *offset
);
34 if (buf
== MAP_FAILED
)
37 #if defined (ACE_WIN32) || defined (HPUX)
39 ACE_OS::send (out_fd
, static_cast<const char *> (buf
), count
);
41 ssize_t
const r
= ACE_OS::write (out_fd
, buf
, count
);
42 #endif /* ACE_WIN32 */
44 (void) ACE_OS::munmap (buf
, count
);
47 *offset
+= static_cast<off_t
> (r
);
51 #endif /* !ACE_HAS_SENDFILE */
53 ACE_END_VERSIONED_NAMESPACE_DECL