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