X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=nucleus%2Flibrary%2Ftimely%2Ftime_stamp.cpp;h=c24844a4e4c98be8958030612ea3a9abd8ab8324;hb=ee7596ce4d372d632f1d1555de9afd30b622bf29;hp=d015a34277479be915703f9d9da3777ed2d39493;hpb=567f3ce3668cc050498387b5e221b7ea4bf1badd;p=feisty_meow.git diff --git a/nucleus/library/timely/time_stamp.cpp b/nucleus/library/timely/time_stamp.cpp index d015a342..c24844a4 100644 --- a/nucleus/library/timely/time_stamp.cpp +++ b/nucleus/library/timely/time_stamp.cpp @@ -17,14 +17,21 @@ #include #include +#include #include #ifdef __WIN32__ #define _WINSOCKAPI_ // make windows.h happy about winsock. -// #include #include // 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; namespace timely { @@ -130,15 +137,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 +156,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.