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

Contents of /trunk/ltimevalstuff.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations)
Fri Mar 28 02:26:58 2008 UTC (12 years, 7 months ago) by plugwash
File size: 1293 byte(s)
initial import

1 { Copyright (C) 2005 Bas Steendijk and Peter Green
2 For conditions of distribution and use, see copyright notice in zlib_license.txt
3 which is included in the package
4 ----------------------------------------------------------------------------- }
5
6
7
8 {add nn msec to tv}
9 const
10 tv_invalidtimebig : ttimeval = (tv_sec:maxlongint;tv_usec:maxlongint);
11 //tv_invalidtimebig will always compare as greater than any valid timeval
12 procedure tv_add(var tv:ttimeval;msec:integer);//{ $ifdef fpc}inline;{ $endif}
13 begin
14 inc(tv.tv_usec,msec*1000);
15 inc(tv.tv_sec,tv.tv_usec div 1000000);
16 tv.tv_usec := tv.tv_usec mod 1000000;
17 end;
18
19 {tv1 >= tv2}
20 function tv_compare(const tv1,tv2:ttimeval):boolean;//{ $ifdef fpc}inline;{ $endif}
21 begin
22 if tv1.tv_sec = tv2.tv_sec then begin
23 result := tv1.tv_usec >= tv2.tv_usec;
24 end else result := tv1.tv_sec > tv2.tv_sec;
25 end;
26
27 procedure tv_substract(var tv:ttimeval;const tv2:ttimeval);//{ $ifdef fpc}inline;{ $endif}
28 begin
29 dec(tv.tv_usec,tv2.tv_usec);
30 if tv.tv_usec < 0 then begin
31 inc(tv.tv_usec,1000000);
32 dec(tv.tv_sec)
33 end;
34 dec(tv.tv_sec,tv2.tv_sec);
35 end;
36
37 procedure msectotimeval(var tv:ttimeval;msec:integer);
38 begin
39 tv.tv_sec := msec div 1000;
40 tv.tv_usec := (msec mod 1000)*1000;
41 end;
42

Properties

Name Value
svn:executable

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