[Vm-dev] [OpenSmalltalk/opensmalltalk-vm] Heart defect on Windows since October (#531)
Eliot Miranda
notifications at github.com
Fri Oct 23 06:15:47 UTC 2020
Hi Christoph,
first it's not true that Time is broken on Windows:
Smalltalk os platformName 'Win32'
Smalltalk getSystemAttribute: 1007 'CoInterpreter VMMaker.oscog-eem.2850 uuid: 4d7fc8a4-2c7d-4bad-8aeb-5f8c5766e12a Oct 21 2020'
DateAndTime now 2020-10-22T23:06:29.983933-07:00
Time utcMicrosecondClock 3780886299961528
It is true that unless you have 8.1 or later and have GetSystemTimePreciseAsFileTime in kernel32 then Time will not work. Here:
```
$ git diff 712cfe6c3e29667b56e668d7641daced18efb666 platforms/win32/vm/sqWin32Heartbeat.c | more
diff --git a/platforms/win32/vm/sqWin32Heartbeat.c b/platforms/win32/vm/sqWin32H
eartbeat.c
old mode 100644
new mode 100755
index 85d27674a..70c430889
--- a/platforms/win32/vm/sqWin32Heartbeat.c
+++ b/platforms/win32/vm/sqWin32Heartbeat.c
@@ -14,6 +14,7 @@
#include <mmsystem.h>
#include "sq.h"
+#undef EXPORT
#include "sqAssert.h"
#include "sqMemoryFence.h"
@@ -76,19 +77,41 @@ sqLong ioHighResClock(void) {
return value;
}
+#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
+
+/* Compute the current VM time basis, the number of microseconds from 1901.
+ *
+ * As of Windows 8 there is a FILETIME wall clock interface which is high
+ * precision and so does not have to be combined with the millisecond clock.
+ */
+# define currentUTCMicroseconds(a,b,c) currentUTCMicrosecondsImplementation()
+static inline unsigned __int64
+currentUTCMicrosecondsImplementation(void)
+{
+ union { // got to love little-endian architectures...
+ FILETIME utcNowFiletime;
+ unsigned __int64 utcNow;
+ } un;
+
+ // cannot fail...
+ GetSystemTimePreciseAsFileTime(&un.utcNowFiletime);
+ return un.utcNow / TocksPerMicrosecond - MicrosecondsFrom1601To1901;
+}
+#else // _WIN32_WINNT >= _WIN32_WINNT_WIN8
+
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/531#issuecomment-714939175
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20201022/8d126e83/attachment.html>
More information about the Vm-dev
mailing list