X-Git-Url: http://www.lcore.org/git/lcore.git/blobdiff_plain/055fa6bf18e0733d1bf2f97075d6bb33c76e72b5..3124451e3e3e632e45928b7d28e3b2bff06e1879:/btime.pas

diff --git a/btime.pas b/btime.pas
index 9bb9550..33b32d0 100644
--- a/btime.pas
+++ b/btime.pas
@@ -12,6 +12,11 @@ unit btime;
 
 interface
 
+{$ifdef win32}
+uses
+  ltimevalstuff;
+{$endif}  
+
 type
   float=extended;
 
@@ -55,6 +60,11 @@ function mmtimefloat:float;
 function qpctimefloat:float;
 {$endif}
 
+{$ifdef win32}
+procedure gettimeofday(var tv:ttimeval);
+{$endif}
+
+
 const
   mmtime_driftavgsize=32;
   mmtime_warmupnum=4;
@@ -169,6 +179,22 @@ end;
 {$else} {delphi 3}
 {------------------------------ windows/delphi code to read time}
 
+
+{simulate gettimeofday on windows so one can always use gettimeofday if preferred}
+
+procedure gettimeofday(var tv:ttimeval);
+var
+  e:extended;
+begin
+  e := unixtimefloat;
+  tv.tv_sec := round(int(e));
+  tv.tv_usec := trunc(frac(e)*1000000);
+  {just in case}
+  if (tv.tv_usec < 0) then tv.tv_usec := 0;
+  if (tv.tv_usec > 999999) then tv.tv_usec := 999999;
+end;
+
+
 {
 time float: gettickcount
 resolution: 9x: ~55 ms NT: 1/64th of a second