Commit aecd6244 authored by Jørgen Lind's avatar Jørgen Lind
Browse files

Merge branch feature/jorgen.lind/usecmaketocheckforsyncfs with...

Merge branch feature/jorgen.lind/usecmaketocheckforsyncfs with refs/heads/master into refs/merge-requests/73/train
parents e22edb73 711efde1
Pipeline #951 passed with stages
in 19 minutes and 42 seconds
......@@ -178,6 +178,17 @@ if (WIN32)
set_source_files_properties(IO/Linux_File.cpp PROPERTIES HEADER_FILE_ONLY TRUE)
elseif (UNIX)
set_source_files_properties(IO/Win_File.cpp PROPERTIES HEADER_FILE_ONLY TRUE)
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
check_symbol_exists(syncfs "unistd.h" HAVE_SYNCFS)
set(CMAKE_REQUIRED_DEFINITIONS "")
if (HAVE_SYNCFS)
set_source_files_properties(IO/Linux_File.cpp
PROPERTIES COMPILE_DEFINITIONS
HAVE_SYNCFS
)
endif()
endif()
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
......
......@@ -17,8 +17,8 @@
#include "File.h"
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 500
#ifdef HAVE_SYNCFS
#define _GNU_SOURCE
#endif
#include <sys/mman.h>
......@@ -332,9 +332,9 @@ bool File::Write(const void* pxData, int64_t nOffset, int32_t nLength, Error & e
bool File::Flush()
{
#ifdef LINUX
int fd = (int)(intptr_t)_pxPlatformHandle;
return syncfs(fd) == 0;
#ifdef HAVE_SYNCFS
int fd = (int)(intptr_t)_pxPlatformHandle;
return syncfs(fd) == 0;
#else
sync();
return true;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment