mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 19:29:26 +02:00
2.0.4: pthread_cond_timedwait needs absolute time (from crossbuilder, issue #7196)
git-svn-id: trunk@4296 -
This commit is contained in:
parent
f5a902b2ee
commit
d0e0ef3d8c
@ -554,10 +554,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);
|
||||
|
Loading…
Reference in New Issue
Block a user