Port: Add Solaris support to fcntl compat
[lttng-tools.git] / src / common / compat / fcntl.h
1 /*
2 * Copyright (C) 2011 - David Goulet <dgoulet@efficios.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2 only,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #ifndef _COMPAT_FCNTL_H
19 #define _COMPAT_FCNTL_H
20
21 #include <fcntl.h>
22 #include <errno.h>
23 #include <sys/types.h>
24
25 #if (defined(__FreeBSD__) || defined(__CYGWIN__))
26 typedef long long off64_t;
27 #endif
28
29 #if (defined(__FreeBSD__) || defined(__sun__))
30 typedef off64_t loff_t;
31 #endif
32
33 #ifdef __linux__
34 extern int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes,
35 unsigned int flags);
36 #define lttng_sync_file_range(fd, offset, nbytes, flags) \
37 compat_sync_file_range(fd, offset, nbytes, flags)
38
39 #endif /* __linux__ */
40
41 #if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
42 /*
43 * Possible flags under Linux. Simply nullify them and avoid wrapper.
44 */
45 #define SYNC_FILE_RANGE_WAIT_AFTER 0
46 #define SYNC_FILE_RANGE_WAIT_BEFORE 0
47 #define SYNC_FILE_RANGE_WRITE 0
48
49 static inline int lttng_sync_file_range(int fd, off64_t offset,
50 off64_t nbytes, unsigned int flags)
51 {
52 return -ENOSYS;
53 }
54 #endif
55
56 #if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
57 /*
58 * Possible flags under Linux. Simply nullify them and avoid wrappers.
59 */
60 #define SPLICE_F_MOVE 0
61 #define SPLICE_F_NONBLOCK 0
62 #define SPLICE_F_MORE 0
63 #define SPLICE_F_GIFT 0
64
65 static inline ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out,
66 size_t len, unsigned int flags)
67 {
68 return -ENOSYS;
69 }
70 #endif
71
72 #ifdef __FreeBSD__
73 #define POSIX_FADV_DONTNEED 0
74
75 static inline int posix_fadvise(int fd, off_t offset, off_t len, int advice)
76 {
77 return -ENOSYS;
78 }
79 #endif
80
81 #if !(defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
82 #error "Please add support for your OS."
83 #endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__ */
84
85 #endif /* _COMPAT_FCNTL_H */
This page took 0.045839 seconds and 4 git commands to generate.