mirror of
https://github.com/fmtlib/fmt.git
synced 2025-01-16 22:19:40 +00:00
Improve OpenBSD workaround
This commit is contained in:
parent
52a99a67f7
commit
6b0082e6c7
@ -48,6 +48,7 @@
|
|||||||
|
|
||||||
// Calls to system functions are wrapped in FMT_SYSTEM for testability.
|
// Calls to system functions are wrapped in FMT_SYSTEM for testability.
|
||||||
#ifdef FMT_SYSTEM
|
#ifdef FMT_SYSTEM
|
||||||
|
# define FMT_HAS_SYSTEM
|
||||||
# define FMT_POSIX_CALL(call) FMT_SYSTEM(call)
|
# define FMT_POSIX_CALL(call) FMT_SYSTEM(call)
|
||||||
#else
|
#else
|
||||||
# define FMT_SYSTEM(call) ::call
|
# define FMT_SYSTEM(call) ::call
|
||||||
|
14
src/os.cc
14
src/os.cc
@ -18,8 +18,8 @@
|
|||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
|
|
||||||
# ifdef _WRS_KERNEL // VxWorks7 kernel
|
# ifdef _WRS_KERNEL // VxWorks7 kernel
|
||||||
# include <ioLib.h> // getpagesize
|
# include <ioLib.h> // getpagesize
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifndef _WIN32
|
# ifndef _WIN32
|
||||||
@ -182,10 +182,14 @@ void buffered_file::close() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int buffered_file::descriptor() const {
|
int buffered_file::descriptor() const {
|
||||||
#ifdef fileno // fileno is a macro on OpenBSD so we cannot use FMT_POSIX_CALL.
|
#if !defined(fileno)
|
||||||
int fd = fileno(file_);
|
|
||||||
#else
|
|
||||||
int fd = FMT_POSIX_CALL(fileno(file_));
|
int fd = FMT_POSIX_CALL(fileno(file_));
|
||||||
|
#elif defined(FMT_HAS_SYSTEM)
|
||||||
|
// fileno is a macro on OpenBSD so we cannot use FMT_POSIX_CALL.
|
||||||
|
# define FMT_DISABLE_MACRO
|
||||||
|
int fd = FMT_SYSTEM(fileno FMT_DISABLE_MACRO(file_));
|
||||||
|
#else
|
||||||
|
int fd = fileno(file_);
|
||||||
#endif
|
#endif
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
FMT_THROW(system_error(errno, FMT_STRING("cannot get file descriptor")));
|
FMT_THROW(system_error(errno, FMT_STRING("cannot get file descriptor")));
|
||||||
|
Loading…
Reference in New Issue
Block a user