Fix: libcompat is now part of libcommon
[lttng-tools.git] / src / common / compat / fcntl.h
CommitLineData
dbb5dfe6
DG
1/*
2 * Copyright (C) 2011 - David Goulet <dgoulet@efficios.com>
3 *
d14d33bf
AM
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2 only,
6 * as published by the Free Software Foundation.
dbb5dfe6
DG
7 *
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
d14d33bf
AM
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
dbb5dfe6
DG
16 */
17
18#ifndef _COMPAT_FCNTL_H
19#define _COMPAT_FCNTL_H
20
21#include <fcntl.h>
4443d2b1 22#include <errno.h>
1268b9d6 23#include <sys/types.h>
db14a5c9 24#include <common/macros.h>
dbb5dfe6 25
4443d2b1
MD
26#if (defined(__FreeBSD__) || defined(__CYGWIN__))
27typedef long long off64_t;
28#endif
29
a3a9e86d 30#if (defined(__FreeBSD__) || defined(__sun__))
4443d2b1
MD
31typedef off64_t loff_t;
32#endif
1268b9d6 33
4443d2b1 34#ifdef __linux__
db14a5c9
JR
35LTTNG_HIDDEN
36int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes,
1268b9d6 37 unsigned int flags);
dbb5dfe6
DG
38#define lttng_sync_file_range(fd, offset, nbytes, flags) \
39 compat_sync_file_range(fd, offset, nbytes, flags)
40
4443d2b1 41#endif /* __linux__ */
dbb5dfe6 42
a3a9e86d 43#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
dbb5dfe6
DG
44/*
45 * Possible flags under Linux. Simply nullify them and avoid wrapper.
46 */
47#define SYNC_FILE_RANGE_WAIT_AFTER 0
48#define SYNC_FILE_RANGE_WAIT_BEFORE 0
49#define SYNC_FILE_RANGE_WRITE 0
50
4443d2b1
MD
51static inline int lttng_sync_file_range(int fd, off64_t offset,
52 off64_t nbytes, unsigned int flags)
53{
54 return -ENOSYS;
55}
56#endif
57
a3a9e86d 58#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__))
dbb5dfe6
DG
59/*
60 * Possible flags under Linux. Simply nullify them and avoid wrappers.
61 */
62#define SPLICE_F_MOVE 0
63#define SPLICE_F_NONBLOCK 0
64#define SPLICE_F_MORE 0
65#define SPLICE_F_GIFT 0
66
1268b9d6
DG
67static inline ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out,
68 size_t len, unsigned int flags)
69{
70 return -ENOSYS;
71}
4443d2b1
MD
72#endif
73
74#ifdef __FreeBSD__
75#define POSIX_FADV_DONTNEED 0
1268b9d6
DG
76
77static inline int posix_fadvise(int fd, off_t offset, off_t len, int advice)
dbb5dfe6
DG
78{
79 return -ENOSYS;
80}
4443d2b1 81#endif
dbb5dfe6 82
82513a40 83#if !(defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__))
7657ae75 84#error "Please add support for your OS."
82513a40 85#endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__, __APPLE__ */
dbb5dfe6
DG
86
87#endif /* _COMPAT_FCNTL_H */
This page took 0.062971 seconds and 5 git commands to generate.