merged Sys.Web.Services 2.0 support in my branch:
[mono.git] / support / sys-sendfile.c
1 /*
2  * <sys/sendfile.h> wrapper functions.
3  *
4  * Authors:
5  *   Jonathan Pryor (jonpryor@vt.edu)
6  *
7  * Copyright (C) 2004 Jonathan Pryor
8  */
9
10 #include <sys/types.h>
11 #include <errno.h>
12
13 #include "map.h"
14 #include "mph.h"
15
16 #ifdef HAVE_SYS_SENDFILE_H
17 #include <sys/sendfile.h>
18 #endif /* ndef HAVE_SYS_SENDFILE_H */
19
20 G_BEGIN_DECLS
21
22 #ifdef HAVE_SENDFILE
23 mph_ssize_t
24 Mono_Posix_Syscall_sendfile (int out_fd, int in_fd, mph_off_t *offset, mph_size_t count)
25 {
26         off_t _offset;
27         ssize_t r;
28         mph_return_if_off_t_overflow (*offset);
29
30         _offset = *offset;
31
32         r = sendfile (out_fd, in_fd, &_offset, (size_t) count);
33
34         *offset = _offset;
35
36         return r;
37 }
38 #endif /* ndef HAVE_SENDFILE */
39
40 G_END_DECLS
41
42 /*
43  * vim: noexpandtab
44  */