Commit | Line | Data |
---|---|---|
dbb5dfe6 | 1 | /* |
ab5be9fa | 2 | * Copyright (C) 2011 David Goulet <dgoulet@efficios.com> |
dbb5dfe6 | 3 | * |
ab5be9fa | 4 | * SPDX-License-Identifier: GPL-2.0-only |
dbb5dfe6 | 5 | * |
dbb5dfe6 DG |
6 | */ |
7 | ||
8 | #ifndef _COMPAT_FCNTL_H | |
9 | #define _COMPAT_FCNTL_H | |
10 | ||
11 | #include <fcntl.h> | |
1268b9d6 | 12 | #include <sys/types.h> |
dbb5dfe6 | 13 | |
edf4b93e MJ |
14 | #include <common/compat/errno.h> |
15 | ||
740da7d5 SM |
16 | #ifdef __cplusplus |
17 | extern "C" { | |
18 | #endif | |
19 | ||
3306f57f | 20 | #if (defined(__CYGWIN__)) |
4443d2b1 MD |
21 | typedef long long off64_t; |
22 | #endif | |
23 | ||
a3a9e86d | 24 | #if (defined(__FreeBSD__) || defined(__sun__)) |
4443d2b1 MD |
25 | typedef off64_t loff_t; |
26 | #endif | |
1268b9d6 | 27 | |
4443d2b1 | 28 | #ifdef __linux__ |
1268b9d6 DG |
29 | extern int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes, |
30 | unsigned int flags); | |
dbb5dfe6 DG |
31 | #define lttng_sync_file_range(fd, offset, nbytes, flags) \ |
32 | compat_sync_file_range(fd, offset, nbytes, flags) | |
33 | ||
4443d2b1 | 34 | #endif /* __linux__ */ |
dbb5dfe6 | 35 | |
a3a9e86d | 36 | #if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__)) |
dbb5dfe6 DG |
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 | ||
4443d2b1 MD |
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 | ||
a3a9e86d | 51 | #if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__)) |
dbb5dfe6 DG |
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 | ||
1268b9d6 DG |
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 | } | |
4443d2b1 MD |
65 | #endif |
66 | ||
82513a40 | 67 | #if !(defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__)) |
7657ae75 | 68 | #error "Please add support for your OS." |
82513a40 | 69 | #endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__, __APPLE__ */ |
dbb5dfe6 | 70 | |
740da7d5 SM |
71 | #ifdef __cplusplus |
72 | } | |
73 | #endif | |
74 | ||
dbb5dfe6 | 75 | #endif /* _COMPAT_FCNTL_H */ |