compat: off64_t is not defined by musl
[lttng-tools.git] / src / common / compat / fcntl.hpp
CommitLineData
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
11#include <fcntl.h>
1268b9d6 12#include <sys/types.h>
dbb5dfe6 13
c9e313bc 14#include <common/compat/errno.hpp>
edf4b93e 15
57fd9937
JG
16static_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
20typedef off64_t loff_t;
21#endif
1268b9d6 22
4443d2b1 23#ifdef __linux__
57fd9937 24extern int compat_sync_file_range(int fd, off_t offset, off_t nbytes,
1268b9d6 25 unsigned int flags);
dbb5dfe6
DG
26#define lttng_sync_file_range(fd, offset, nbytes, flags) \
27 compat_sync_file_range(fd, offset, nbytes, flags)
28
4443d2b1 29#endif /* __linux__ */
dbb5dfe6 30
a3a9e86d 31#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
dbb5dfe6
DG
32/*
33 * Possible flags under Linux. Simply nullify them and avoid wrapper.
34 */
35#define SYNC_FILE_RANGE_WAIT_AFTER 0
36#define SYNC_FILE_RANGE_WAIT_BEFORE 0
37#define SYNC_FILE_RANGE_WRITE 0
38
4eac90eb
MJ
39static inline int lttng_sync_file_range(
40 int fd __attribute__((unused)),
57fd9937
JG
41 off_t offset __attribute__((unused)),
42 off_t nbytes __attribute__((unused)),
4eac90eb 43 unsigned int flags __attribute__((unused)))
4443d2b1
MD
44{
45 return -ENOSYS;
46}
47#endif
48
a3a9e86d 49#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
dbb5dfe6
DG
50/*
51 * Possible flags under Linux. Simply nullify them and avoid wrappers.
52 */
53#define SPLICE_F_MOVE 0
54#define SPLICE_F_NONBLOCK 0
55#define SPLICE_F_MORE 0
56#define SPLICE_F_GIFT 0
57
4eac90eb
MJ
58static inline ssize_t splice(
59 int fd_in __attribute__((unused)),
60 loff_t *off_in __attribute__((unused)),
61 int fd_out __attribute__((unused)),
62 loff_t *off_out __attribute__((unused)),
63 size_t len __attribute__((unused)),
64 unsigned int flags __attribute__((unused)))
1268b9d6
DG
65{
66 return -ENOSYS;
67}
4443d2b1
MD
68#endif
69
82513a40 70#if !(defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__))
7657ae75 71#error "Please add support for your OS."
82513a40 72#endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__, __APPLE__ */
dbb5dfe6
DG
73
74#endif /* _COMPAT_FCNTL_H */
This page took 0.072794 seconds and 4 git commands to generate.