Browse Source

* nanosleep for sleep(), since it is now in the POSIX group.

git-svn-id: trunk@1341 -
marco 20 năm trước cách đây
mục cha
commit
f054a6df16
1 tập tin đã thay đổi với 5 bổ sung15 xóa
  1. 5 15
      rtl/unix/sysutils.pp

+ 5 - 15
rtl/unix/sysutils.pp

@@ -259,7 +259,7 @@ begin
   fpclose(Handle);
 end;
 
-Function FileTruncate (Handle,Size: Longint) : boolean;
+Function FileTruncate (Handle,Size: TFileOffset) : boolean;
 
 begin
   FileTruncate:=fpftruncate(Handle,Size)>=0;
@@ -1057,22 +1057,12 @@ End;
 procedure Sleep(milliseconds: Cardinal);
 
 Var
-  fd : Integer;
-  fds : TfdSet;
-  timeout : TimeVal;
+  timeout,timeoutresult : TTimespec;
 
 begin
-  fd:=FileOpen('/dev/null',fmOpenRead);
-  If Not(Fd<0) then
-    try
-      fpfd_zero(fds);
-      fpfd_set(0,fds);
-      timeout.tv_sec:=Milliseconds div 1000;
-      timeout.tv_usec:=(Milliseconds mod 1000) * 1000;
-      fpSelect(1,Nil,Nil,@fds,@timeout);
-    finally
-      FileClose(fd);
-    end;
+  timeout.tv_sec:=milliseconds div 1000;
+  timeout.tv_nsec:=1000*1000*(milliseconds mod 1000);
+  fpnanosleep(@timeout,@timeoutresult);
 end;
 
 Function GetLastOSError : Integer;