Ignore:
Timestamp:
Nov 25, 2008, 12:35:56 AM (17 years ago)
Author:
bird
Message:

kmk: Implemented new switch --print-time. Fixes #65.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/function.c

    r2025 r2101  
    4545#if defined (CONFIG_WITH_MATH) || defined (CONFIG_WITH_NANOTS) || defined (CONFIG_WITH_FILE_SIZE) /* bird */
    4646# include <ctype.h>
    47 # ifdef _MSC_VER
    48 typedef __int64 math_int;
    49 # else
    50 #  include <stdint.h>
    51 typedef int64_t math_int;
    52 # endif
     47typedef big_int math_int;
    5348static char *math_int_to_variable_buffer (char *, math_int);
    5449#endif
     
    41024097func_nanots (char *o, char **argv, const char *funcname)
    41034098{
    4104   math_int ts;
    4105 
    4106 #if defined (WINDOWS32)
    4107   static int s_state = -1;
    4108   static LARGE_INTEGER s_freq;
    4109 
    4110   if (s_state == -1)
    4111     s_state = QueryPerformanceFrequency (&s_freq);
    4112   if (s_state)
    4113     {
    4114       LARGE_INTEGER pc;
    4115       if (!QueryPerformanceCounter (&pc))
    4116         {
    4117           s_state = 0;
    4118           return func_nanots (o, argv, funcname);
    4119         }
    4120       ts = (math_int)((long double)pc.QuadPart / (long double)s_freq.QuadPart * 1000000000);
    4121     }
    4122   else
    4123     {
    4124       /* fall back to low resolution system time. */
    4125       LARGE_INTEGER bigint;
    4126       FILETIME ft = {0,0};
    4127       GetSystemTimeAsFileTime (&ft);
    4128       bigint.u.LowPart = ft.dwLowDateTime;
    4129       bigint.u.HighPart = ft.dwLowDateTime;
    4130       ts = bigint.QuadPart * 100;
    4131     }
    4132 
    4133 /* FIXME: Linux and others have the realtime clock_* api, detect and use it. */
    4134 
    4135 #elif HAVE_GETTIMEOFDAY
    4136   struct timeval tv;
    4137   if (!gettimeofday (&tv, NULL))
    4138     ts = (math_int)tv.tv_sec * 1000000000
    4139        + tv.tv_usec * 1000;
    4140   else
    4141     {
    4142       error (NILF, _("$(nanots): gettimeofday failed"));
    4143       ts = 0;
    4144     }
    4145 
    4146 #else
    4147 # error "PORTME"
    4148 #endif
    4149 
    4150   return math_int_to_variable_buffer (o, ts);
     4099  return math_int_to_variable_buffer (o, nano_timestamp ());
    41514100}
    41524101#endif
Note: See TracChangeset for help on using the changeset viewer.