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
23 uses baseunix,unix,unixutil,sockets;
\r
28 procedure tv_add(var tv:ttimeval;msec:integer);
\r
29 function tv_compare(const tv1,tv2:ttimeval):boolean;
\r
30 procedure tv_subtract(var tv:ttimeval;const tv2:ttimeval);
\r
31 procedure msectotimeval(var tv:ttimeval;msec:integer);
\r
33 //tv_invalidtimebig will always compare as greater than any valid timeval
\r
34 //unfortunately unixstuff.inc hasn't worked it's magic yet so we
\r
35 //have to ifdef this manually.
\r
38 tv_invalidtimebig : ttimeval = (sec:maxlongint;usec:maxlongint);
\r
40 tv_invalidtimebig : ttimeval = (tv_sec:maxlongint;tv_usec:maxlongint);
\r
47 procedure tv_add(var tv:ttimeval;msec:integer);
\r
49 inc(tv.tv_usec,msec*1000);
\r
50 inc(tv.tv_sec,tv.tv_usec div 1000000);
\r
51 tv.tv_usec := tv.tv_usec mod 1000000;
\r
55 function tv_compare(const tv1,tv2:ttimeval):boolean;
\r
57 if tv1.tv_sec = tv2.tv_sec then begin
\r
58 result := tv1.tv_usec >= tv2.tv_usec;
\r
59 end else result := tv1.tv_sec > tv2.tv_sec;
\r
62 procedure tv_subtract(var tv:ttimeval;const tv2:ttimeval);
\r
64 dec(tv.tv_usec,tv2.tv_usec);
\r
65 if tv.tv_usec < 0 then begin
\r
66 inc(tv.tv_usec,1000000);
\r
69 dec(tv.tv_sec,tv2.tv_sec);
\r
72 procedure msectotimeval(var tv:ttimeval;msec:integer);
\r
74 tv.tv_sec := msec div 1000;
\r
75 tv.tv_usec := (msec mod 1000)*1000;
\r