mirror of
https://github.com/fmtlib/fmt.git
synced 2025-07-30 10:47:35 +02:00
Fix Windows build.
This commit is contained in:
@ -101,18 +101,21 @@ std::string FormatSystemErrorMessage(int error_code, fmt::StringRef message);
|
|||||||
#ifndef FMT_POSIX
|
#ifndef FMT_POSIX
|
||||||
# ifdef _WIN32
|
# ifdef _WIN32
|
||||||
// Fix warnings about deprecated symbols.
|
// Fix warnings about deprecated symbols.
|
||||||
# define FMT_POSIX(name) _##name
|
# define FMT_POSIX(call) _##call
|
||||||
# else
|
# else
|
||||||
# define FMT_POSIX(name) name
|
# define FMT_POSIX(call) call
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef FMT_POSIX_CALL
|
#ifdef FMT_SYSTEM
|
||||||
|
# define FMT_POSIX_CALL(call) FMT_SYSTEM(call)
|
||||||
|
#else
|
||||||
|
# define FMT_SYSTEM(call) call
|
||||||
# ifdef _WIN32
|
# ifdef _WIN32
|
||||||
// Fix warnings about deprecated symbols.
|
// Fix warnings about deprecated symbols.
|
||||||
# define FMT_POSIX_CALL(name) ::_##name
|
# define FMT_POSIX_CALL(call) ::_##call
|
||||||
# else
|
# else
|
||||||
# define FMT_POSIX_CALL(name) ::name
|
# define FMT_POSIX_CALL(call) ::call
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -30,6 +30,10 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
# include <io.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "gtest-extra.h"
|
#include "gtest-extra.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -42,6 +46,7 @@ int fileno_count;
|
|||||||
int read_count;
|
int read_count;
|
||||||
int write_count;
|
int write_count;
|
||||||
int pipe_count;
|
int pipe_count;
|
||||||
|
int fclose_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EMULATE_EINTR(func, error_result) \
|
#define EMULATE_EINTR(func, error_result) \
|
||||||
@ -102,10 +107,22 @@ test::ssize_t test::write(int fildes, const void *buf, test::size_t nbyte) {
|
|||||||
return ::write(fildes, buf, nbyte);
|
return ::write(fildes, buf, nbyte);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
int test::pipe(int fildes[2]) {
|
int test::pipe(int fildes[2]) {
|
||||||
EMULATE_EINTR(pipe, -1);
|
EMULATE_EINTR(pipe, -1);
|
||||||
return ::pipe(fildes);
|
return ::pipe(fildes);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
int test::pipe(int *pfds, unsigned psize, int textmode) {
|
||||||
|
EMULATE_EINTR(pipe, -1);
|
||||||
|
return _pipe(fildes, 256, O_BINARY);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int test::fclose(FILE *stream) {
|
||||||
|
EMULATE_EINTR(fclose, EOF);
|
||||||
|
return ::fclose(stream);
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
# define EXPECT_RETRY(statement, func, message) \
|
# define EXPECT_RETRY(statement, func, message) \
|
||||||
|
@ -56,10 +56,16 @@ int fileno(FILE *stream);
|
|||||||
ssize_t read(int fildes, void *buf, size_t nbyte);
|
ssize_t read(int fildes, void *buf, size_t nbyte);
|
||||||
ssize_t write(int fildes, const void *buf, size_t nbyte);
|
ssize_t write(int fildes, const void *buf, size_t nbyte);
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
int pipe(int fildes[2]);
|
int pipe(int fildes[2]);
|
||||||
|
#else
|
||||||
|
int pipe(int *pfds, unsigned psize, int textmode);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int fclose(FILE *stream);
|
||||||
|
|
||||||
} // namespace test
|
} // namespace test
|
||||||
|
|
||||||
#define FMT_POSIX_CALL(call) test::call
|
#define FMT_SYSTEM(call) test::call
|
||||||
|
|
||||||
#endif // FMT_POSIX_TEST_H
|
#endif // FMT_POSIX_TEST_H
|
||||||
|
Reference in New Issue
Block a user