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
19 uses baseunix,unix,unixutil,sockets;
\r
24 procedure tv_add(var tv:ttimeval;msec:integer);
\r
25 function tv_compare(const tv1,tv2:ttimeval):boolean;
\r
26 procedure tv_substract(var tv:ttimeval;const tv2:ttimeval);
\r
27 procedure msectotimeval(var tv:ttimeval;msec:integer);
\r
29 //tv_invalidtimebig will always compare as greater than any valid timeval
\r
30 //unfortunately unixstuff.inc hasn't worked it's magic yet so we
\r
31 //have to ifdef this manually.
\r
34 tv_invalidtimebig : ttimeval = (sec:maxlongint;usec:maxlongint);
\r
36 tv_invalidtimebig : ttimeval = (tv_sec:maxlongint;tv_usec:maxlongint);
\r
43 procedure tv_add(var tv:ttimeval;msec:integer);
\r
45 inc(tv.tv_usec,msec*1000);
\r
46 inc(tv.tv_sec,tv.tv_usec div 1000000);
\r
47 tv.tv_usec := tv.tv_usec mod 1000000;
\r
51 function tv_compare(const tv1,tv2:ttimeval):boolean;
\r
53 if tv1.tv_sec = tv2.tv_sec then begin
\r
54 result := tv1.tv_usec >= tv2.tv_usec;
\r
55 end else result := tv1.tv_sec > tv2.tv_sec;
\r
58 procedure tv_substract(var tv:ttimeval;const tv2:ttimeval);
\r
60 dec(tv.tv_usec,tv2.tv_usec);
\r
61 if tv.tv_usec < 0 then begin
\r
62 inc(tv.tv_usec,1000000);
\r
65 dec(tv.tv_sec,tv2.tv_sec);
\r
68 procedure msectotimeval(var tv:ttimeval;msec:integer);
\r
70 tv.tv_sec := msec div 1000;
\r
71 tv.tv_usec := (msec mod 1000)*1000;
\r