diff options
Diffstat (limited to 'include/utils/Compat.h')
-rw-r--r-- | include/utils/Compat.h | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/include/utils/Compat.h b/include/utils/Compat.h index fb7748e..7d96310 100644 --- a/include/utils/Compat.h +++ b/include/utils/Compat.h @@ -19,11 +19,9 @@ #include <unistd.h> -/* Compatibility definitions for non-Linux (i.e., BSD-based) hosts. */ -#ifndef HAVE_OFF64_T -#if _FILE_OFFSET_BITS < 64 -#error "_FILE_OFFSET_BITS < 64; large files are not supported on this platform" -#endif /* _FILE_OFFSET_BITS < 64 */ +#if defined(__APPLE__) + +/* Mac OS has always had a 64-bit off_t, so it doesn't have off64_t. */ typedef off_t off64_t; @@ -31,20 +29,35 @@ static inline off64_t lseek64(int fd, off64_t offset, int whence) { return lseek(fd, offset, whence); } -#ifdef HAVE_PREAD static inline ssize_t pread64(int fd, void* buf, size_t nbytes, off64_t offset) { return pread(fd, buf, nbytes, offset); } -#endif -#endif /* !HAVE_OFF64_T */ +#endif /* __APPLE__ */ + +#if defined(_WIN32) +#define O_CLOEXEC O_NOINHERIT +#define O_NOFOLLOW 0 +#define DEFFILEMODE 0666 +#endif /* _WIN32 */ + +#if defined(_WIN32) +#define ZD "%ld" +#define ZD_TYPE long +#else +#define ZD "%zd" +#define ZD_TYPE ssize_t +#endif -#if HAVE_PRINTF_ZD -# define ZD "%zd" -# define ZD_TYPE ssize_t +/* + * Needed for cases where something should be constexpr if possible, but not + * being constexpr is fine if in pre-C++11 code (such as a const static float + * member variable). + */ +#if __cplusplus >= 201103L +#define CONSTEXPR constexpr #else -# define ZD "%ld" -# define ZD_TYPE long +#define CONSTEXPR #endif /* |