#REFACTORING by cg
class: UnixOperatingSystem class
added: #getOSTimeWithMicros
removed: #getOSTimeInMicros
--- a/UnixOperatingSystem.st Fri Mar 16 12:18:50 2018 +0100
+++ b/UnixOperatingSystem.st Fri Mar 16 14:20:41 2018 +0100
@@ -10151,8 +10151,9 @@
"
!
-getOSTimeInMicros
- "This returns the OS time as a 3-element vector in microsecond resolution.
+getOSTimeWithMicros
+ "This returns the OS time as a 2-element vector with milliseconds (as before)
+ plus microseconds.
The base of the returned value is not consistent across
different OS's - some return the number of microseconds since jan, 1st 1970;
others since 1900. The Time classes are prepared for this, and
@@ -10166,6 +10167,7 @@
|seconds millis micros|
%{
+#if defined(HAS_GETTIMEOFDAY)
unsigned long _secs, _millis, _micros;
struct timeval tb;
@@ -10179,8 +10181,13 @@
seconds = __MKUINT(_secs);
millis = __MKUINT(_millis);
micros = __MKUINT(_micros);
-%}.
- ^ { seconds . millis . micros }
+#endif
+%}.
+ seconds notNil ifTrue:[
+ ^ { ((seconds * 1000) + millis) . micros }
+ ].
+
+ self primitiveFailed.
"
OperatingSystem getOSTimeInMicros printCR.