2 * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef _COMPAT_FCNTL_H
9 #define _COMPAT_FCNTL_H
11 #include <common/compat/errno.hpp>
14 #include <sys/types.h>
16 static_assert(sizeof(off_t) == sizeof(int64_t),
17 "Build system is misconfigured, off_t must be 64-bit wide");
19 #if (defined(__FreeBSD__) || defined(__sun__))
20 typedef off64_t loff_t;
24 extern int compat_sync_file_range(int fd, off_t offset, off_t nbytes, unsigned int flags);
25 #define lttng_sync_file_range(fd, offset, nbytes, flags) \
26 compat_sync_file_range(fd, offset, nbytes, flags)
28 #endif /* __linux__ */
30 #if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
32 * Possible flags under Linux. Simply nullify them and avoid wrapper.
34 #define SYNC_FILE_RANGE_WAIT_AFTER 0
35 #define SYNC_FILE_RANGE_WAIT_BEFORE 0
36 #define SYNC_FILE_RANGE_WRITE 0
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)))
47 #if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
49 * Possible flags under Linux. Simply nullify them and avoid wrappers.
51 #define SPLICE_F_MOVE 0
52 #define SPLICE_F_NONBLOCK 0
53 #define SPLICE_F_MORE 0
54 #define SPLICE_F_GIFT 0
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)))
67 #if !(defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || \
69 #error "Please add support for your OS."
70 #endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__, __APPLE__ */
72 #endif /* _COMPAT_FCNTL_H */