From: Francesco Chemolli <5175948+kinkie@users.noreply.github.com> Date: Thu, 25 Jan 2024 13:48:35 +0000 (+0000) Subject: Emulate fsync on mingw (#1650) X-Git-Tag: SQUID_7_0_1~232 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3f045e25d2d4d543a0e7bc5423b3922d9441a54a;p=thirdparty%2Fsquid.git Emulate fsync on mingw (#1650) MS Windows (and mingw) do not offer fsync(), but they offer the API-compatible _commit(). --- diff --git a/compat/os/mingw.h b/compat/os/mingw.h index 6abd702db8..6a0d2a8649 100644 --- a/compat/os/mingw.h +++ b/compat/os/mingw.h @@ -32,5 +32,19 @@ #include #endif +// needed for _commmit and _get_osfhandle +#if HAVE_IO_H +#include +#endif + +#if !HAVE_FSYNC +// _commit(fd) is API-compatible with fsync(fd) and has equivalent behaviour +inline int +fsync(int fd) +{ + return _commit(fd); +} +#endif + #endif /* _SQUID_MINGW_*/ #endif /* SQUID_OS_MINGW_H */ diff --git a/configure.ac b/configure.ac index 57c5cdafc6..de6bc5e5ac 100644 --- a/configure.ac +++ b/configure.ac @@ -191,7 +191,7 @@ AS_CASE(["$squid_host_os"], CXXFLAGS="$CXXFLAGS -mthreads -static-libgcc -static-libstdc++" dnl Check for Winsock only on MinGW SQUID_CHECK_WINSOCK_LIB - AC_CHECK_HEADERS([ws2tcpip.h winsock2.h windows.h],,,[ + AC_CHECK_HEADERS([ws2tcpip.h winsock2.h windows.h io.h],,,[ #if HAVE_WS2TCPIP_H #include #endif @@ -204,6 +204,7 @@ AS_CASE(["$squid_host_os"], ]) MINGW_LIBS="-lmingwex" AC_SUBST(MINGW_LIBS) + AC_CHECK_FUNCS([fsync]) ], [freebsd],[