[Vm-dev] [commit] r2163 - Add ioMicroSeconds, sqUnixUtcWithOffset.

commits at squeakvm.org commits at squeakvm.org
Fri Apr 2 02:55:02 UTC 2010


Author: piumarta
Date: 2010-04-01 19:55:01 -0700 (Thu, 01 Apr 2010)
New Revision: 2163

Modified:
   trunk/platforms/unix/vm/sqUnixMain.c
Log:
Add ioMicroSeconds, sqUnixUtcWithOffset.

Modified: trunk/platforms/unix/vm/sqUnixMain.c
===================================================================
--- trunk/platforms/unix/vm/sqUnixMain.c	2010-04-02 02:54:29 UTC (rev 2162)
+++ trunk/platforms/unix/vm/sqUnixMain.c	2010-04-02 02:55:01 UTC (rev 2163)
@@ -27,7 +27,7 @@
 
 /* Author: Ian Piumarta <ian.piumarta at squeakland.org>
  *
- * Last edited: 2009-09-14 14:03:15 by piumarta on ubuntu.piumarta.com
+ * Last edited: 2010-04-01 13:43:17 by piumarta on emilia-2.local
  */
 
 #include "sq.h"
@@ -193,6 +193,35 @@
   return ioMSecs();	/* this already to the nearest millisecond */
 }
 
+sqLong ioMicroSeconds(void)
+{
+  struct timeval now;
+  sqLong microSecs;
+  gettimeofday(&now, 0);
+  if ((now.tv_usec -= startUpTime.tv_usec) < 0) {
+    now.tv_usec += 1000000;
+    now.tv_sec -= 1;
+  }
+  now.tv_sec -= startUpTime.tv_sec;
+  microSecs= now.tv_usec;
+  microSecs= microSecs + now.tv_sec * 1000000;
+  return microSecs;
+}
+
+/* implementation of ioUtcWithOffset(), defined in config.h to
+/* override default definition in src/vm/interp.h
+ */
+sqInt sqUnixUtcWithOffset(sqLong *microSeconds, int *offset)
+{
+  struct timeval timeval;
+  if (gettimeofday(&timeval, NULL) == -1) return -1;
+  time_t seconds= timeval.tv_sec;
+  suseconds_t usec= timeval.tv_usec;
+  *microSeconds= seconds * 1000000 + usec;
+  *offset= localtime(&seconds)->tm_gmtoff;
+  return 0;
+}
+
 time_t convertToSqueakTime(time_t unixTime)
 {
 #ifdef HAVE_TM_GMTOFF
@@ -221,7 +250,7 @@
 
 /* copy src filename to target, if src is not an absolute filename,
  * prepend the cwd to make target absolute
-  */
+ */
 static void pathCopyAbs(char *target, const char *src, size_t targetSize)
 {
   if (src[0] == '/')



More information about the Vm-dev mailing list