Commit | Line | Data |
---|---|---|
dbb5dfe6 | 1 | /* |
ab5be9fa | 2 | * Copyright (C) 2011 David Goulet <dgoulet@efficios.com> |
dbb5dfe6 | 3 | * |
c922647d | 4 | * SPDX-License-Identifier: LGPL-2.1-only |
dbb5dfe6 | 5 | * |
dbb5dfe6 DG |
6 | */ |
7 | ||
8 | #ifndef _COMPAT_FCNTL_H | |
9 | #define _COMPAT_FCNTL_H | |
10 | ||
28f23191 JG |
11 | #include <common/compat/errno.hpp> |
12 | ||
dbb5dfe6 | 13 | #include <fcntl.h> |
1268b9d6 | 14 | #include <sys/types.h> |
dbb5dfe6 | 15 | |
57fd9937 JG |
16 | static_assert(sizeof(off_t) == sizeof(int64_t), |
17 | "Build system is misconfigured, off_t must be 64-bit wide"); | |
4443d2b1 | 18 | |
a3a9e86d | 19 | #if (defined(__FreeBSD__) || defined(__sun__)) |
4443d2b1 MD |
20 | typedef off64_t loff_t; |
21 | #endif | |
1268b9d6 | 22 | |
4443d2b1 | 23 | #ifdef __linux__ |
28f23191 | 24 | extern int compat_sync_file_range(int fd, off_t offset, off_t nbytes, unsigned int flags); |
dbb5dfe6 DG |
25 | #define lttng_sync_file_range(fd, offset, nbytes, flags) \ |
26 | compat_sync_file_range(fd, offset, nbytes, flags) | |
27 | ||
4443d2b1 | 28 | #endif /* __linux__ */ |
dbb5dfe6 | 29 | |
a3a9e86d | 30 | #if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__)) |
dbb5dfe6 DG |
31 | /* |
32 | * Possible flags under Linux. Simply nullify them and avoid wrapper. | |
33 | */ | |
28f23191 JG |
34 | #define SYNC_FILE_RANGE_WAIT_AFTER 0 |
35 | #define SYNC_FILE_RANGE_WAIT_BEFORE 0 | |
36 | #define SYNC_FILE_RANGE_WRITE 0 | |
dbb5dfe6 | 37 | |
28f23191 JG |
38 | static inline int lttng_sync_file_range(int fd __attribute__((unused)), |
39 | off_t offset __attribute__((unused)), | |
40 | off_t nbytes __attribute__((unused)), | |
41 | unsigned int flags __attribute__((unused))) | |
4443d2b1 MD |
42 | { |
43 | return -ENOSYS; | |
44 | } | |
45 | #endif | |
46 | ||
a3a9e86d | 47 | #if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__)) |
dbb5dfe6 DG |
48 | /* |
49 | * Possible flags under Linux. Simply nullify them and avoid wrappers. | |
50 | */ | |
28f23191 JG |
51 | #define SPLICE_F_MOVE 0 |
52 | #define SPLICE_F_NONBLOCK 0 | |
53 | #define SPLICE_F_MORE 0 | |
54 | #define SPLICE_F_GIFT 0 | |
dbb5dfe6 | 55 | |
28f23191 JG |
56 | static inline ssize_t splice(int fd_in __attribute__((unused)), |
57 | loff_t *off_in __attribute__((unused)), | |
58 | int fd_out __attribute__((unused)), | |
59 | loff_t *off_out __attribute__((unused)), | |
60 | size_t len __attribute__((unused)), | |
61 | unsigned int flags __attribute__((unused))) | |
1268b9d6 DG |
62 | { |
63 | return -ENOSYS; | |
64 | } | |
4443d2b1 MD |
65 | #endif |
66 | ||
28f23191 JG |
67 | #if !(defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || \ |
68 | defined(__APPLE__)) | |
7657ae75 | 69 | #error "Please add support for your OS." |
82513a40 | 70 | #endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__, __APPLE__ */ |
dbb5dfe6 DG |
71 | |
72 | #endif /* _COMPAT_FCNTL_H */ |