Commit b4ec4028 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

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: 's avatarPiotr Caban <piotr@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 43a44390
...@@ -1907,10 +1907,9 @@ static int futimens( int fd, const struct timespec spec[2] ) ...@@ -1907,10 +1907,9 @@ static int futimens( int fd, const struct timespec spec[2] )
#define UTIME_OMIT ((1 << 30) - 2) #define UTIME_OMIT ((1 << 30) - 2)
#endif #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 #ifdef HAVE_FUTIMENS
struct timespec tv[2]; struct timespec tv[2];
...@@ -1926,12 +1925,29 @@ static NTSTATUS set_file_times( int fd, const LARGE_INTEGER *mtime, const LARGE_ ...@@ -1926,12 +1925,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_sec = mtime->QuadPart / 10000000 - SECS_1601_TO_1970;
tv[1].tv_nsec = (mtime->QuadPart % 10000000) * 100; 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 timeval tv[2];
struct stat st; 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) if (!atime->QuadPart || !mtime->QuadPart)
{ {
......
Markdown is supported
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