Prepare Mono for Android NDK with unified headers (#5680)
[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 <config.h>
11
12 #include <sys/types.h>
13 #include <errno.h>
14
15 #include "mono/utils/mono-compiler.h"
16 #include "map.h"
17 #include "mph.h"
18
19 #ifdef HAVE_SYS_SENDFILE_H
20 #include <sys/sendfile.h>
21 #endif /* ndef HAVE_SYS_SENDFILE_H */
22
23 G_BEGIN_DECLS
24
25 #ifdef HAVE_SENDFILE
26 mph_ssize_t
27 Mono_Posix_Syscall_sendfile (int out_fd, int in_fd, mph_off_t *offset, mph_size_t count)
28 {
29         off_t _offset;
30         ssize_t r;
31         mph_return_if_off_t_overflow (*offset);
32
33         _offset = *offset;
34
35 #if defined(HOST_DARWIN) || defined(HOST_BSD)
36         /* The BSD version has 6 arguments */
37         g_assert_not_reached ();
38 #else
39         r = sendfile (out_fd, in_fd, &_offset, (size_t) count);
40 #endif
41
42         *offset = _offset;
43
44         return r;
45 }
46 #endif /* ndef HAVE_SENDFILE */
47
48 G_END_DECLS
49
50 /*
51  * vim: noexpandtab
52  */