X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fcommon%2Fcompat%2Ffcntl.h;h=9fca7f0cdc4699e8ed6155a08b6e7630d1417dfa;hb=4878de5c7deb512bbdac4fdfc498907efa06fb7c;hp=58c1579e79a4d0583b98e0700338fced3d907066;hpb=d14d33bf091e72b23b1f90ea18a0a01bed098b76;p=lttng-tools.git diff --git a/src/common/compat/fcntl.h b/src/common/compat/fcntl.h index 58c1579e7..9fca7f0cd 100644 --- a/src/common/compat/fcntl.h +++ b/src/common/compat/fcntl.h @@ -1,18 +1,8 @@ /* - * Copyright (C) 2011 - David Goulet + * Copyright (C) 2011 David Goulet * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License, version 2 only, - * as published by the Free Software Foundation. + * SPDX-License-Identifier: LGPL-2.1-only * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef _COMPAT_FCNTL_H @@ -21,20 +11,25 @@ #include #include -#ifdef __linux__ +#include + +#if (defined(__CYGWIN__)) +typedef long long off64_t; +#endif +#if (defined(__FreeBSD__) || defined(__sun__)) +typedef off64_t loff_t; +#endif + +#ifdef __linux__ extern int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags); #define lttng_sync_file_range(fd, offset, nbytes, flags) \ compat_sync_file_range(fd, offset, nbytes, flags) -#elif defined(__FreeBSD__) - -typedef long int off64_t; -typedef off64_t loff_t; - -#include +#endif /* __linux__ */ +#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__)) /* * Possible flags under Linux. Simply nullify them and avoid wrapper. */ @@ -42,6 +37,17 @@ typedef off64_t loff_t; #define SYNC_FILE_RANGE_WAIT_BEFORE 0 #define SYNC_FILE_RANGE_WRITE 0 +static inline int lttng_sync_file_range( + int fd __attribute__((unused)), + off64_t offset __attribute__((unused)), + off64_t nbytes __attribute__((unused)), + unsigned int flags __attribute__((unused))) +{ + return -ENOSYS; +} +#endif + +#if (defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__)) /* * Possible flags under Linux. Simply nullify them and avoid wrappers. */ @@ -50,27 +56,20 @@ typedef off64_t loff_t; #define SPLICE_F_MORE 0 #define SPLICE_F_GIFT 0 -#define POSIX_FADV_DONTNEED 0 - -static inline int lttng_sync_file_range(int fd, off64_t offset, - off64_t nbytes, unsigned int flags) -{ - return -ENOSYS; -} - -static inline ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, - size_t len, unsigned int flags) -{ - return -ENOSYS; -} - -static inline int posix_fadvise(int fd, off_t offset, off_t len, int advice) +static inline ssize_t splice( + int fd_in __attribute__((unused)), + loff_t *off_in __attribute__((unused)), + int fd_out __attribute__((unused)), + loff_t *off_out __attribute__((unused)), + size_t len __attribute__((unused)), + unsigned int flags __attribute__((unused))) { return -ENOSYS; } +#endif -#else +#if !(defined(__linux__) || defined(__FreeBSD__) || defined(__CYGWIN__) || defined(__sun__) || defined(__APPLE__)) #error "Please add support for your OS." -#endif /* __linux__ , __FreeBSD__ */ +#endif /* __linux__ , __FreeBSD__, __CYGWIN__, __sun__, __APPLE__ */ #endif /* _COMPAT_FCNTL_H */