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@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2019-11-07 16:24:34 +01:00 committed by Alexandre Julliard
parent 43a4439068
commit b4ec402859
1 changed files with 21 additions and 5 deletions

View File

@ -1907,10 +1907,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];
@ -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_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)
{