buildroot/package/openvmtools/0010-Make-HgfsConvertFromNt...

53 lines
1.8 KiB
Diff

From 640effa0a8cdf5d00efa329bcf8dfe01790b3fbb Mon Sep 17 00:00:00 2001
Message-ID: <640effa0a8cdf5d00efa329bcf8dfe01790b3fbb.1693922825.git.stefan@agner.ch>
In-Reply-To: <b978727972e1a8b7e3f14886395047e5809b7a81.1693922825.git.stefan@agner.ch>
References: <b978727972e1a8b7e3f14886395047e5809b7a81.1693922825.git.stefan@agner.ch>
From: Stefan Agner <stefan@agner.ch>
Date: Tue, 5 Sep 2023 15:03:56 +0200
Subject: [PATCH] Make HgfsConvertFromNtTimeNsec aware of 64-bit time_t on i386
I verified that this function behaves as expected on x86_64, i386 with
32-bit time_t, and i386 with 64-bit time_t for the following values of
ntTtime:
UNIX_EPOCH-1, UNIX_EPOCH, UNIX_EPOCH+1, UNIX_S32_MAX-1, UNIX_S32_MAX,
UNIX_S32_MAX+1, UNIX_S32_MAX*2+1
I did not verify whether the use of Div643264 is optimal, performance
wise.
Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
[rebased against stable-12.3.0]
Signed-off-by: Stefan Agner <stefan@agner.ch>
---
lib/hgfs/hgfsUtil.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/lib/hgfs/hgfsUtil.c b/lib/hgfs/hgfsUtil.c
index fcd7fb72..f8606156 100644
--- a/lib/hgfs/hgfsUtil.c
+++ b/lib/hgfs/hgfsUtil.c
@@ -131,13 +131,15 @@ HgfsConvertFromNtTimeNsec(struct timespec *unixTime, // OUT: Time in UNIX format
Div643232(ntTime - UNIX_EPOCH, 10000000, &sec, &nsec);
unixTime->tv_sec = sec;
unixTime->tv_nsec = nsec * 100;
-
- return 0;
+ } else {
+ Div643264(ntTime - UNIX_EPOCH, 10000000, &sec64, &nsec);
+ unixTime->tv_sec = sec64;
+ unixTime->tv_nsec = nsec * 100;
}
-#endif
-
+#else
unixTime->tv_sec = (ntTime - UNIX_EPOCH) / 10000000;
unixTime->tv_nsec = ((ntTime - UNIX_EPOCH) % 10000000) * 100;
+#endif // __i386__
return 0;
}
--
2.42.0