/[lcore]/trunk/ltimevalstuff.pas
ViewVC logotype

Diff of /trunk/ltimevalstuff.pas

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 156 by beware, Fri Mar 28 03:18:52 2014 UTC revision 157 by beware, Fri Aug 13 03:52:55 2021 UTC
# Line 20  Line 20 
20    {$ifdef ver1_0}    {$ifdef ver1_0}
21      uses linux;      uses linux;
22    {$else}    {$else}
23      uses baseunix,unix,unixutil,sockets;      uses
24          {$ifdef linux}linux,{$endif} //for clock_gettime
25          {$ifdef freebsd}freebsd,{$endif} //for clock_gettime      
26          baseunix,unix,unixutil,sockets;
27    {$endif}    {$endif}
28  {$endif}  {$endif}
29                                                                    
# Line 30  Line 33 
33  procedure tv_subtract(var tv:ttimeval;const tv2:ttimeval);  procedure tv_subtract(var tv:ttimeval;const tv2:ttimeval);
34  procedure msectotimeval(var tv:ttimeval;msec:integer);  procedure msectotimeval(var tv:ttimeval;msec:integer);
35    
36    {$ifdef unix}
37    //for internal use by lcore as a replacement for gettimeofday -beware
38    procedure gettimemonotonic(var tv:ttimeval);
39    {$endif}
40    
41  //tv_invalidtimebig will always compare as greater than any valid timeval  //tv_invalidtimebig will always compare as greater than any valid timeval
42  //unfortunately unixstuff.inc hasn't worked it's magic yet so we  //unfortunately unixstuff.inc hasn't worked it's magic yet so we
43  //have to ifdef this manually.  //have to ifdef this manually.
# Line 75  Line 83 
83    tv.tv_usec := (msec mod 1000)*1000;    tv.tv_usec := (msec mod 1000)*1000;
84  end;  end;
85    
86    
87    {$ifdef unix}
88    {$ifdef linux}{$define have_clock_gettime}{$endif}
89    {$ifdef freebsd}{$define have_clock_gettime}{$endif}
90    
91    procedure gettimemonotonic(var tv:ttimeval);
92    var
93      ts:ttimespec;
94    begin
95      {$ifdef have_clock_gettime}
96      if (clock_gettime(CLOCK_MONOTONIC, @ts) = 0) then begin
97        tv.tv_sec := ts.tv_sec;
98        tv.tv_usec := ts.tv_nsec div 1000;
99        exit;
100      end;
101      {$endif}
102      gettimeofday(tv);
103    end;
104    {$endif}
105    
106  end.  end.

Legend:
Removed from v.156  
changed lines
  Added in v.157

No admin address has been configured">No admin address has been configured
ViewVC Help
Powered by ViewVC 1.1.26