Piotr Caban : ntdll: Work around futimens weak linking problem in set_file_times.
Alexandre Julliard
julliard at winehq.org
Mon Apr 20 15:01:57 CDT 2020
Module: wine
Branch: oldstable
Commit: 67672080bab1d0ab5a59339096a26922fabb7f92
URL: https://source.winehq.org/git/wine.git/?a=commit;h=67672080bab1d0ab5a59339096a26922fabb7f92
Author: Piotr Caban <piotr at codeweavers.com>
Date: Thu Nov 7 16:24:34 2019 +0100
ntdll: Work around futimens weak linking problem in set_file_times.
Newer XCode versions are weak linking to futimens function. Because of
that Wine will crash trying to execute the function on Mac OS <= 10.12.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit b4ec4028597c06bbdbf283b4a5f5957dd2c1b809)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>
---
dlls/ntdll/file.c | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/file.c b/dlls/ntdll/file.c
index a26c85509e..6614465490 100644
--- a/dlls/ntdll/file.c
+++ b/dlls/ntdll/file.c
@@ -1914,10 +1914,9 @@ static int futimens( int fd, const struct timespec spec[2] )
#define UTIME_OMIT ((1 << 30) - 2)
#endif
-static NTSTATUS set_file_times( int fd, const LARGE_INTEGER *mtime, const LARGE_INTEGER *atime )
+static BOOL set_file_times_precise( int fd, const LARGE_INTEGER *mtime,
+ const LARGE_INTEGER *atime, NTSTATUS *status )
{
- NTSTATUS status = STATUS_SUCCESS;
-
#ifdef HAVE_FUTIMENS
struct timespec tv[2];
@@ -1933,12 +1932,29 @@ static NTSTATUS set_file_times( int fd, const LARGE_INTEGER *mtime, const LARGE_
tv[1].tv_sec = mtime->QuadPart / 10000000 - SECS_1601_TO_1970;
tv[1].tv_nsec = (mtime->QuadPart % 10000000) * 100;
}
- if (futimens( fd, tv ) == -1) status = FILE_GetNtStatus();
+#ifdef __APPLE__
+ if (!&futimens) return FALSE;
+#endif
+ if (futimens( fd, tv ) == -1) *status = FILE_GetNtStatus();
+ else *status = STATUS_SUCCESS;
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
-#elif defined(HAVE_FUTIMES) || defined(HAVE_FUTIMESAT)
+static NTSTATUS set_file_times( int fd, const LARGE_INTEGER *mtime, const LARGE_INTEGER *atime )
+{
+ NTSTATUS status = STATUS_SUCCESS;
+#if defined(HAVE_FUTIMES) || defined(HAVE_FUTIMESAT)
struct timeval tv[2];
struct stat st;
+#endif
+
+ if (set_file_times_precise( fd, mtime, atime, &status ))
+ return status;
+#if defined(HAVE_FUTIMES) || defined(HAVE_FUTIMESAT)
if (!atime->QuadPart || !mtime->QuadPart)
{
More information about the wine-cvs
mailing list