From c8688576f2ead6a47a5559ab39f7e8dba179ea8b Mon Sep 17 00:00:00 2001 From: vitaut Date: Mon, 11 May 2015 19:10:31 -0700 Subject: [PATCH] Fix MinGW build --- appveyor.yml | 10 +++++----- test/posix-test.cc | 32 +++++++++++++++----------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 6eae7cd8..23d1afa0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,12 +1,12 @@ environment: CTEST_OUTPUT_ON_FAILURE: 1 matrix: - - BUILD: msvc - CONFIG: Debug - - BUILD: msvc - CONFIG: Release -# - BUILD: mingw +# - BUILD: msvc # CONFIG: Debug +# - BUILD: msvc +# CONFIG: Release + - BUILD: mingw + CONFIG: Debug # - BUILD: mingw # CONFIG: Release diff --git a/test/posix-test.cc b/test/posix-test.cc index b2964e0f..a914ae7b 100644 --- a/test/posix-test.cc +++ b/test/posix-test.cc @@ -78,32 +78,16 @@ int test::open(const char *path, int oflag, int mode) { EMULATE_EINTR(open, -1); return ::open(path, oflag, mode); } - -#ifdef _WIN32 -typedef fmt::LongLong FileSize; -#else -typedef off_t FileSize; -#endif - -static FileSize max_file_size() { return std::numeric_limits::max(); } - -int (test::fstat)(int fd, struct stat *buf) { - int result = ::fstat(fd, buf); - if (fstat_sim == MAX_SIZE) - buf->st_size = max_file_size(); - return result; -} #else errno_t test::sopen_s( int* pfh, const char *filename, int oflag, int shflag, int pmode) { EMULATE_EINTR(open, EINTR); return _sopen_s(pfh, filename, oflag, shflag, pmode); } - -static LONGLONG max_file_size() { return std::numeric_limits::max(); } #endif #ifndef _WIN32 + long test::sysconf(int name) { long result = ::sysconf(name); if (!sysconf_error) @@ -112,7 +96,20 @@ long test::sysconf(int name) { errno = EINVAL; return -1; } + +static off_t max_file_size() { return std::numeric_limits::max(); } + +int test::fstat(int fd, struct stat *buf) { + int result = ::fstat(fd, buf); + if (fstat_sim == MAX_SIZE) + buf->st_size = max_file_size(); + return result; +} + #else + +static LONGLONG max_file_size() { return std::numeric_limits::max(); } + DWORD test::GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) { if (fstat_sim == ERROR) { SetLastError(ERROR_ACCESS_DENIED); @@ -125,6 +122,7 @@ DWORD test::GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) { } return ::GetFileSize(hFile, lpFileSizeHigh); } + #endif int test::close(int fildes) {