mcst-linux-kernel/patches-2024.06.26/zstd-1.4.4/0002-Fix-build-PLATFORM_POS...

60 lines
1.7 KiB
Diff

From 6a7617be4dac954c80339310c0b9353c3310d206 Mon Sep 17 00:00:00 2001
From: Alexander Troosh <trush@yandex.ru>
Date: Tue, 4 Feb 2020 16:10:16 +0300
Subject: [PATCH 2/5] Fix build (PLATFORM_POSIX_VERSION and st_mtime)
---
programs/util.c | 16 ++++++++--------
programs/util.h | 2 +-
2 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/programs/util.c b/programs/util.c
index 5d15450..c4c4a9f 100644
--- a/programs/util.c
+++ b/programs/util.c
@@ -62,20 +62,20 @@ int UTIL_setFileStat(const char *filename, stat_t *statbuf)
return -1;
/* set access and modification times */
-#if defined(_WIN32) || (PLATFORM_POSIX_VERSION < 200809L)
- {
- struct utimbuf timebuf;
- timebuf.actime = time(NULL);
- timebuf.modtime = statbuf->st_mtime;
- res += utime(filename, &timebuf);
- }
-#else
+#if (PLATFORM_POSIX_VERSION >= 200809L) && defined(st_mtime)
{
/* (atime, mtime) */
struct timespec timebuf[2] = { {0, UTIME_NOW} };
timebuf[1] = statbuf->st_mtim;
res += utimensat(AT_FDCWD, filename, timebuf, 0);
}
+#else
+ {
+ struct utimbuf timebuf;
+ timebuf.actime = time(NULL);
+ timebuf.modtime = statbuf->st_mtime;
+ res += utime(filename, &timebuf);
+ }
#endif
#if !defined(_WIN32)
diff --git a/programs/util.h b/programs/util.h
index 1f524f2..133ef6f 100644
--- a/programs/util.h
+++ b/programs/util.h
@@ -30,7 +30,7 @@ extern "C" {
# include <io.h> /* _chmod */
#else
# include <unistd.h> /* chown, stat */
-#if PLATFORM_POSIX_VERSION < 200809L
+#if PLATFORM_POSIX_VERSION < 200809L || !defined(st_mtime)
# include <utime.h> /* utime */
#else
# include <fcntl.h> /* AT_FDCWD */
--
1.9.5