fix: relayd: unaligned access in trace_chunk_registry_ht_key_hash
[lttng-tools.git] / src / common / compat / fcntl.hpp
... / ...
CommitLineData
1/*
2 * Copyright (C) 2011 David Goulet <dgoulet@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-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.hpp>
15
16static_assert(sizeof(off_t) == sizeof(int64_t),
17 "Build system is misconfigured, off_t must be 64-bit wide");
18
19#if (defined(__FreeBSD__) || defined(__sun__))
20typedef off64_t loff_t;
21#endif
22
23#ifdef __linux__
24extern int compat_sync_file_range(int fd, off_t offset, off_t nbytes,
25 unsigned int flags);
26#define lttng_sync_file_range(fd, offset, nbytes, flags) \
27 compat_sync_file_range(fd, offset, nbytes, flags)
28
29#endif /* __linux__ */
30
31#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
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
39static inline int lttng_sync_file_range(
40 int fd __attribute__((unused)),
41 off_t offset __attribute__((unused)),
42 off_t nbytes __attribute__((unused)),
43 unsigned int flags __attribute__((unused)))
44{
45 return -ENOSYS;
46}
47#endif
48
49#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
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
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)))
65{
66 return -ENOSYS;
67}
68#endif
69
70#if !(defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__))
71#error "Please add support for your OS."
72#endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__, __APPLE__ */
73
74#endif /* _COMPAT_FCNTL_H */
This page took 0.022621 seconds and 4 git commands to generate.