Parcourir la source

Merged revisions 4296 via svnmerge from
svn+ssh://svn.freepascal.org/FPC/svn/fpc/trunk

........
r4296 | micha | 2006-07-25 22:34:20 +0200 (di, 25 jul 2006) | 1 line

2.0.4: pthread_cond_timedwait needs absolute time (from crossbuilder, issue #7196)
........

git-svn-id: branches/fixes_2_0@4298 -

micha il y a 19 ans
Parent
commit
6aa1d948a7
1 fichiers modifiés avec 10 ajouts et 2 suppressions
  1. 10 2
      rtl/unix/cthreads.pp

+ 10 - 2
rtl/unix/cthreads.pp

@@ -550,10 +550,18 @@ procedure intRTLEventWaitForTimeout(AEvent: PRTLEvent;timeout : longint);
     p : pintrtlevent;
     errres : cint;
     timespec : ttimespec;
+    tnow : timeval;
+
   begin
     p:=pintrtlevent(aevent);
-    timespec.tv_sec:=timeout div 1000;
-    timespec.tv_nsec:=(timeout mod 1000)*1000000;
+    fpgettimeofday(@tnow,nil);
+    timespec.tv_sec:=tnow.tv_sec+(timeout div 1000);
+    timespec.tv_nsec:=(timeout mod 1000)*1000000 + tnow.tv_usec*1000;
+    if timespec.tv_nsec >= 1000000000 then
+    begin
+      inc(timespec.tv_sec);
+      dec(timespec.tv_nsec, 1000000000);
+    end;
     errres:=pthread_cond_timedwait(@p^.condvar, @p^.mutex, @timespec);
     if (errres=0) or (errres=ESysETIMEDOUT) then
       pthread_mutex_unlock(@p^.mutex);