updates from orpheus for windoze build
[feisty_meow.git] / nucleus / library / timely / time_stamp.cpp
index d015a34277479be915703f9d9da3777ed2d39493..1cfdf0fdc8f7e93c89951470a66d3028ee986e78 100644 (file)
 #include "earth_time.h"
 #include "time_stamp.h"
 
+#include <application/windoze_helper.h>
 #include <basis/environment.h>
 #include <basis/mutex.h>
+#include <loggers/program_wide_logger.h>
 
 #include <stdlib.h>
-#ifdef __WIN32__
-  #define _WINSOCKAPI_  // make windows.h happy about winsock.
-//  #include <windows.h>
-  #include <winsock2.h>  // timeval.
+//#ifdef __WIN32__
+//  #define _WINSOCKAPI_  // make windows.h happy about winsock.
+//  #include <winsock2.h>  // timeval.
+//#endif
+
+//#define DEBUG_TIME_STAMP
+
+#ifdef DEBUG_TIME_STAMP
+  #define LOG(s) CLASS_EMERGENCY_LOG(program_wide_logger::get(), s)
+  using namespace loggers;
 #endif
 
 using namespace basis;
@@ -130,15 +138,16 @@ double time_stamp::rolling_uptime()
   return double(__rollovers) * __rollover_point + double(ticks_up);
 }
 
-timeval time_stamp::fill_timeval_ms(int duration)
+void time_stamp::fill_timeval_ms(struct timeval &time_out, int duration)
 {
-  timeval time_out;  // timeval has tv_sec=seconds, tv_usec=microseconds.
+  FUNCDEF("fill_timeval_ms");
+  // timeval has tv_sec=seconds, tv_usec=microseconds.
   if (!duration) {
     // duration is immediate for the check; just a quick poll.
     time_out.tv_sec = 0;
     time_out.tv_usec = 0;
-#ifdef DEBUG_PORTABLE
-//    LOG("no duration specified");
+#ifdef DEBUG_TIME_STAMP
+    LOG("no duration specified");
 #endif
   } else {
     // a non-zero duration means we need to compute secs and usecs.
@@ -148,12 +157,11 @@ timeval time_stamp::fill_timeval_ms(int duration)
     // now take out the chunk we've already recorded as seconds.
     time_out.tv_usec = duration * 1000;
     // set the number of microseconds from the remaining milliseconds.
-#ifdef DEBUG_PORTABLE
-//    LOG(isprintf("duration of %d ms went to %d sec and %d usec.", duration,
-//        time_out.tv_sec, time_out.tv_usec));
+#ifdef DEBUG_TIME_STAMP
+    LOG(a_sprintf("duration of %d ms went to %d sec and %d usec.", duration,
+        time_out.tv_sec, time_out.tv_usec));
 #endif
   }
-  return time_out;
 }
 
 } //namespace.