8bbdfe89cc75c122bda2ea7b77db27ca0727ebf6
[lttng-tools.git] / src / common / compat / fcntl.h
1 /*
2 * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 */
7
8 #ifndef _COMPAT_FCNTL_H
9 #define _COMPAT_FCNTL_H
10
11 #include <fcntl.h>
12 #include <sys/types.h>
13
14 #include <common/compat/errno.h>
15
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19
20 #if (defined(__CYGWIN__))
21 typedef long long off64_t;
22 #endif
23
24 #if (defined(__FreeBSD__) || defined(__sun__))
25 typedef off64_t loff_t;
26 #endif
27
28 #ifdef __linux__
29 extern int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes,
30 unsigned int flags);
31 #define lttng_sync_file_range(fd, offset, nbytes, flags) \
32 compat_sync_file_range(fd, offset, nbytes, flags)
33
34 #endif /* __linux__ */
35
36 #if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
37 /*
38 * Possible flags under Linux. Simply nullify them and avoid wrapper.
39 */
40 #define SYNC_FILE_RANGE_WAIT_AFTER 0
41 #define SYNC_FILE_RANGE_WAIT_BEFORE 0
42 #define SYNC_FILE_RANGE_WRITE 0
43
44 static inline int lttng_sync_file_range(int fd, off64_t offset,
45 off64_t nbytes, unsigned int flags)
46 {
47 return -ENOSYS;
48 }
49 #endif
50
51 #if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
52 /*
53 * Possible flags under Linux. Simply nullify them and avoid wrappers.
54 */
55 #define SPLICE_F_MOVE 0
56 #define SPLICE_F_NONBLOCK 0
57 #define SPLICE_F_MORE 0
58 #define SPLICE_F_GIFT 0
59
60 static inline ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out,
61 size_t len, unsigned int flags)
62 {
63 return -ENOSYS;
64 }
65 #endif
66
67 #if !(defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__))
68 #error "Please add support for your OS."
69 #endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__, __APPLE__ */
70
71 #ifdef __cplusplus
72 }
73 #endif
74
75 #endif /* _COMPAT_FCNTL_H */
This page took 0.029815 seconds and 3 git commands to generate.