fd_utils,\r
{$endif}\r
lcorernd,\r
- sysutils;\r
+ sysutils,
+ ltimevalstuff;\r
\r
//convert a name to an IP\r
//will return v4 or v6 depending on what seems favorable, or manual preference setting\r
{$endif}\r
\r
{$i unixstuff.inc}\r
-{$i ltimevalstuff.inc}\r
\r
var\r
numsockused:integer;\r
{$endif}\r
fd_utils,\r
{$endif}\r
- classes,pgtypes,bfifo;\r
+ classes,pgtypes,bfifo,ltimevalstuff;\r
procedure processtasks;\r
\r
\r
var\r
timerwrapperinterface : ttimerwrapperinterface;\r
type\r
- {$ifdef win32}\r
- ttimeval = record\r
- tv_sec : longint;\r
- tv_usec : longint;\r
- end;\r
- {$endif}\r
tltimer=class(tlcomponent)\r
protected\r
\r
{$ifndef win32}\r
{$include unixstuff.inc}\r
{$endif}\r
-{$include ltimevalstuff.inc}\r
\r
\r
{!!! added sleep call -beware}\r
lcore,sysutils,\r
classes,pgtypes,bfifo,\r
{$ifndef nosignal}\r
- lsignal;\r
+ lsignal,\r
{$endif}\r
+ ltimevalstuff;
\r
{$include unixstuff.inc}\r
-{$include ltimevalstuff.inc}\r
\r
const\r
absoloutemaxs_select = (sizeof(fdset)*8)-1;\r
\r
implementation\r
uses\r
- baseunix,unix,lcore,unixutil;//,safewriteln;\r
+ baseunix,unix,lcore,unixutil,ltimevalstuff;//,safewriteln;\r
{$i unixstuff.inc}\r
\r
type\r
//than crash after over four billion\r
//windows have been made ;)\r
nextwindowhandle : qword = $100000000;\r
-{$i ltimevalstuff.inc}\r
+
\r
//findthreaddata should only be called while holding the structurelock\r
function findthreaddata(threadid : integer) : tthreaddata;\r
+++ /dev/null
-{ Copyright (C) 2005 Bas Steendijk and Peter Green\r
- For conditions of distribution and use, see copyright notice in zlib_license.txt\r
- which is included in the package\r
- ----------------------------------------------------------------------------- }\r
-\r
-\r
-\r
-{add nn msec to tv}\r
-const\r
- tv_invalidtimebig : ttimeval = (tv_sec:maxlongint;tv_usec:maxlongint);\r
- //tv_invalidtimebig will always compare as greater than any valid timeval\r
-procedure tv_add(var tv:ttimeval;msec:integer);//{ $ifdef fpc}inline;{ $endif}\r
-begin\r
- inc(tv.tv_usec,msec*1000);\r
- inc(tv.tv_sec,tv.tv_usec div 1000000);\r
- tv.tv_usec := tv.tv_usec mod 1000000;\r
-end;\r
-\r
-{tv1 >= tv2}\r
-function tv_compare(const tv1,tv2:ttimeval):boolean;//{ $ifdef fpc}inline;{ $endif}\r
-begin\r
- if tv1.tv_sec = tv2.tv_sec then begin\r
- result := tv1.tv_usec >= tv2.tv_usec;\r
- end else result := tv1.tv_sec > tv2.tv_sec;\r
-end;\r
-\r
-procedure tv_substract(var tv:ttimeval;const tv2:ttimeval);//{ $ifdef fpc}inline;{ $endif}\r
-begin\r
- dec(tv.tv_usec,tv2.tv_usec);\r
- if tv.tv_usec < 0 then begin\r
- inc(tv.tv_usec,1000000);\r
- dec(tv.tv_sec)\r
- end;\r
- dec(tv.tv_sec,tv2.tv_sec);\r
-end;\r
-\r
-procedure msectotimeval(var tv:ttimeval;msec:integer);\r
-begin\r
- tv.tv_sec := msec div 1000;\r
- tv.tv_usec := (msec mod 1000)*1000;\r
-end;\r
-\r
--- /dev/null
+{ Copyright (C) 2005 Bas Steendijk and Peter Green\r
+ For conditions of distribution and use, see copyright notice in zlib_license.txt\r
+ which is included in the package\r
+ ----------------------------------------------------------------------------- }\r
+\r
+unit ltimevalstuff;\r
+interface\r
+
+{$ifdef win32}
+ type
+ ttimeval = record
+ tv_sec : longint;
+ tv_usec : longint;
+ end;
+{$else}
+ {$ifdef ver1_0}
+ uses linux;
+ {$else}
+ uses baseunix,unix;
+ {$endif}
+{$endif}
+
+\r
+procedure tv_add(var tv:ttimeval;msec:integer);\r
+function tv_compare(const tv1,tv2:ttimeval):boolean;\r
+procedure tv_substract(var tv:ttimeval;const tv2:ttimeval);\r
+procedure msectotimeval(var tv:ttimeval;msec:integer);\r
+
+//tv_invalidtimebig will always compare as greater than any valid timeval\r
+//unfortunately unixstuff.inc hasn't worked it's magic yet so we
+//have to ifdef this manually.\r
+const\r
+ {$ifdef ver1_0}
+ tv_invalidtimebig : ttimeval = (sec:maxlongint;usec:maxlongint);\r
+ {$else}
+ \rtv_invalidtimebig : ttimeval = (tv_sec:maxlongint;tv_usec:maxlongint);\r
+\r {$endif}
+implementation\r
+
+{$i unixstuff.inc}
+\r
+{add nn msec to tv}\r
+procedure tv_add(var tv:ttimeval;msec:integer);\r
+begin\r
+ inc(tv.tv_usec,msec*1000);\r
+ inc(tv.tv_sec,tv.tv_usec div 1000000);\r
+ tv.tv_usec := tv.tv_usec mod 1000000;\r
+end;\r
+\r
+{tv1 >= tv2}\r
+function tv_compare(const tv1,tv2:ttimeval):boolean;\r
+begin\r
+ if tv1.tv_sec = tv2.tv_sec then begin\r
+ result := tv1.tv_usec >= tv2.tv_usec;\r
+ end else result := tv1.tv_sec > tv2.tv_sec;\r
+end;\r
+\r
+procedure tv_substract(var tv:ttimeval;const tv2:ttimeval);\r
+begin\r
+ dec(tv.tv_usec,tv2.tv_usec);\r
+ if tv.tv_usec < 0 then begin\r
+ inc(tv.tv_usec,1000000);\r
+ dec(tv.tv_sec)\r
+ end;\r
+ dec(tv.tv_sec,tv2.tv_sec);\r
+end;\r
+\r
+procedure msectotimeval(var tv:ttimeval;msec:integer);\r
+begin\r
+ tv.tv_sec := msec div 1000;\r
+ tv.tv_usec := (msec mod 1000)*1000;\r
+end;\r
+\r
+end.
\ No newline at end of file