This commit is contained in:
Pavel 2023-06-27 16:30:30 +03:00
parent 24c7a29eb7
commit 9ce2cf59a3
15 changed files with 165 additions and 141 deletions

View File

@ -301,7 +301,7 @@ procedure THR_CRITICAL_LEAVE(thr:p_pthread); inline;
function THR_UMUTEX_TRYLOCK(thr:p_pthread;lck:p_umutex):Integer; inline;
function THR_UMUTEX_LOCK(thr:p_pthread;lck:p_umutex):Integer; inline;
function THR_UMUTEX_TIMEDLOCK(thr:p_pthread;lck:p_umutex;timo:ptimespec):Integer; inline;
function THR_UMUTEX_TIMEDLOCK(thr:p_pthread;lck:p_umutex;timo:p_timespec):Integer; inline;
function THR_UMUTEX_UNLOCK(thr:p_pthread;lck:p_umutex):Integer; inline;
procedure THR_LOCK_ACQUIRE(thr:p_pthread;lck:p_umutex); inline;
@ -380,7 +380,7 @@ begin
Result:=_thr_umutex_lock(lck,TID(thr));
end;
function THR_UMUTEX_TIMEDLOCK(thr:p_pthread;lck:p_umutex;timo:ptimespec):Integer; inline;
function THR_UMUTEX_TIMEDLOCK(thr:p_pthread;lck:p_umutex;timo:p_timespec):Integer; inline;
begin
Result:=_thr_umutex_timedlock(lck,TID(thr),timo);
end;

View File

@ -39,32 +39,32 @@ function _thr_umutex_trylock(mtx:p_umutex;id:DWORD):Integer;
function _thr_umutex_trylock2(mtx:p_umutex;id:DWORD):Integer;
function _thr_umutex_lock(mtx:p_umutex;id:DWORD):Integer;
function _thr_umutex_lock_spin(mtx:p_umutex;id:DWORD):Integer;
function _thr_umutex_timedlock(mtx:p_umutex;id:DWORD;timeout:ptimespec):Integer;
function _thr_umutex_timedlock(mtx:p_umutex;id:DWORD;timeout:p_timespec):Integer;
function _thr_umutex_unlock(mtx:p_umutex;id:DWORD):Integer;
function _thr_rwlock_tryrdlock(rwlock:p_urwlock;flags:Integer):Integer;
function _thr_rwlock_trywrlock(rwlock:p_urwlock):Integer;
function _thr_rwlock_rdlock(rwlock:p_urwlock;flags:Integer;tsp:ptimespec):Integer;
function _thr_rwlock_wrlock(rwlock:p_urwlock;tsp:ptimespec):Integer;
function _thr_rwlock_rdlock(rwlock:p_urwlock;flags:Integer;tsp:p_timespec):Integer;
function _thr_rwlock_wrlock(rwlock:p_urwlock;tsp:p_timespec):Integer;
function _thr_rwlock_unlock(rwlock:p_urwlock):Integer;
procedure _thr_umutex_init(mtx:p_umutex);
procedure _thr_urwlock_init(rwl:p_urwlock);
function __thr_umutex_lock(mtx:p_umutex;id:DWORD):Integer;
function __thr_umutex_lock_spin(mtx:p_umutex;id:DWORD):Integer;
function __thr_umutex_timedlock(mtx:p_umutex;id:DWORD;ets:ptimespec):Integer;
function __thr_umutex_timedlock(mtx:p_umutex;id:DWORD;ets:p_timespec):Integer;
function __thr_umutex_unlock(mtx:p_umutex;id:DWORD):Integer;
function __thr_umutex_trylock(mtx:p_umutex):Integer;
function __thr_umutex_set_ceiling(mtx:p_umutex;ceiling:DWORD;oldceiling:PDWORD):Integer;
function _thr_umtx_wait(mtx:Pointer;id:QWORD;timeout:ptimespec):Integer;
function _thr_umtx_wait_uint(mtx:Pointer;id:DWORD;timeout:ptimespec;shared:Integer):Integer;
function _thr_umtx_timedwait_uint(mtx:Pointer;id:DWORD;clockid:Integer;abstime:ptimespec;shared:Integer):Integer;
function _thr_umtx_wait(mtx:Pointer;id:QWORD;timeout:p_timespec):Integer;
function _thr_umtx_wait_uint(mtx:Pointer;id:DWORD;timeout:p_timespec;shared:Integer):Integer;
function _thr_umtx_timedwait_uint(mtx:Pointer;id:DWORD;clockid:Integer;abstime:p_timespec;shared:Integer):Integer;
function _thr_umtx_wake(mtx:Pointer;nr_wakeup,shared:Integer):Integer;
procedure _thr_ucond_init(cv:p_ucond);
function _thr_ucond_wait(cv:p_ucond;m:p_umutex;timeout:ptimespec;flags:Integer):Integer;
function _thr_ucond_wait(cv:p_ucond;m:p_umutex;timeout:p_timespec;flags:Integer):Integer;
function _thr_ucond_signal(cv:p_ucond):Integer;
function _thr_ucond_broadcast(cv:p_ucond):Integer;
function __thr_rwlock_rdlock(rwlock:p_urwlock;flags:Integer;tsp:ptimespec):Integer;
function __thr_rwlock_wrlock(rwlock:p_urwlock;tsp:ptimespec):Integer;
function __thr_rwlock_rdlock(rwlock:p_urwlock;flags:Integer;tsp:p_timespec):Integer;
function __thr_rwlock_wrlock(rwlock:p_urwlock;tsp:p_timespec):Integer;
function __thr_rwlock_unlock(rwlock:p_urwlock):Integer;
procedure _thr_rwl_rdlock(rwlock:p_urwlock);
procedure _thr_rwl_wrlock(rwlock:p_urwlock);
@ -125,7 +125,7 @@ begin
Exit(__thr_umutex_lock_spin(mtx,id));
end;
function _thr_umutex_timedlock(mtx:p_umutex;id:DWORD;timeout:ptimespec):Integer;
function _thr_umutex_timedlock(mtx:p_umutex;id:DWORD;timeout:p_timespec):Integer;
begin
if (_thr_umutex_trylock2(mtx,id)=0) then
Exit(0);
@ -177,14 +177,14 @@ begin
Exit(EBUSY);
end;
function _thr_rwlock_rdlock(rwlock:p_urwlock;flags:Integer;tsp:ptimespec):Integer;
function _thr_rwlock_rdlock(rwlock:p_urwlock;flags:Integer;tsp:p_timespec):Integer;
begin
if (_thr_rwlock_tryrdlock(rwlock,flags)=0) then
Exit(0);
Exit(__thr_rwlock_rdlock(rwlock,flags,tsp));
end;
function _thr_rwlock_wrlock(rwlock:p_urwlock;tsp:ptimespec):Integer;
function _thr_rwlock_wrlock(rwlock:p_urwlock;tsp:p_timespec):Integer;
begin
if (_thr_rwlock_trywrlock(rwlock)=0) then
Exit(0);
@ -291,7 +291,7 @@ begin
Exit(_umtx_op_err(mtx,UMTX_OP_MUTEX_LOCK,0,nil,nil));
end;
function __thr_umutex_timedlock(mtx:p_umutex;id:DWORD;ets:ptimespec):Integer;
function __thr_umutex_timedlock(mtx:p_umutex;id:DWORD;ets:p_timespec):Integer;
var
timo,cts:timespec;
owner:DWORD;
@ -386,7 +386,7 @@ begin
Exit(_umtx_op_err(mtx,UMTX_OP_SET_CEILING,ceiling,oldceiling,nil));
end;
function _thr_umtx_wait(mtx:Pointer;id:QWORD;timeout:ptimespec):Integer;
function _thr_umtx_wait(mtx:Pointer;id:QWORD;timeout:p_timespec):Integer;
begin
if (timeout<>nil) and
((timeout^.tv_sec<0) or ((timeout^.tv_sec=0) and (timeout^.tv_nsec<=0))) then
@ -394,7 +394,7 @@ begin
Exit(_umtx_op_err(mtx,UMTX_OP_WAIT,id,nil,timeout));
end;
function _thr_umtx_wait_uint(mtx:Pointer;id:DWORD;timeout:ptimespec;shared:Integer):Integer;
function _thr_umtx_wait_uint(mtx:Pointer;id:DWORD;timeout:p_timespec;shared:Integer):Integer;
begin
if (timeout<>nil) and
((timeout^.tv_sec<0) or ((timeout^.tv_sec=0) and (timeout^.tv_nsec<=0))) then
@ -406,10 +406,10 @@ begin
Exit(_umtx_op_err(mtx,UMTX_OP_WAIT_UINT_PRIVATE,id,nil,timeout));
end;
function _thr_umtx_timedwait_uint(mtx:Pointer;id:DWORD;clockid:Integer;abstime:ptimespec;shared:Integer):Integer;
function _thr_umtx_timedwait_uint(mtx:Pointer;id:DWORD;clockid:Integer;abstime:p_timespec;shared:Integer):Integer;
var
ts,ts2:timespec;
tsp:ptimespec;
tsp:p_timespec;
begin
if (abstime<>nil) then
begin
@ -441,7 +441,7 @@ begin
FillChar(cv^,SizeOf(ucond),0);
end;
function _thr_ucond_wait(cv:p_ucond;m:p_umutex;timeout:ptimespec;flags:Integer):Integer;
function _thr_ucond_wait(cv:p_ucond;m:p_umutex;timeout:p_timespec;flags:Integer):Integer;
var
curthread:p_pthread;
begin
@ -469,12 +469,12 @@ begin
Exit(_umtx_op_err(cv,UMTX_OP_CV_BROADCAST,0,nil,nil));
end;
function __thr_rwlock_rdlock(rwlock:p_urwlock;flags:Integer;tsp:ptimespec):Integer; inline;
function __thr_rwlock_rdlock(rwlock:p_urwlock;flags:Integer;tsp:p_timespec):Integer; inline;
begin
Exit(_umtx_op_err(rwlock,UMTX_OP_RW_RDLOCK,flags,nil,tsp));
end;
function __thr_rwlock_wrlock(rwlock:p_urwlock;tsp:ptimespec):Integer; inline;
function __thr_rwlock_wrlock(rwlock:p_urwlock;tsp:p_timespec):Integer; inline;
begin
Exit(_umtx_op_err(rwlock,UMTX_OP_RW_WRLOCK,0,nil,tsp));
end;

View File

@ -24,7 +24,7 @@ procedure _cv_wait_unlock(cvp:p_cv;lock:Pointer);
function _cv_wait_sig(cvp:p_cv;lock:Pointer):Integer;
function _cv_timedwait(cvp:p_cv;lock:Pointer;timo:Int64):Integer;
function _cv_timedwait_sig(cvp:p_cv;lock:Pointer;timo:Int64):Integer;
function _cv_timedwait_sig_proctime(cvp:p_cv;lock:Pointer;timeout:ptimespec):Integer;
function _cv_timedwait_sig_proctime(cvp:p_cv;lock:Pointer;timeout:p_timespec):Integer;
procedure cv_signal(cvp:p_cv);
procedure cv_signalto(cvp:p_cv;td:p_kthread);
procedure cv_broadcastpri(cvp:p_cv;pri:Integer);
@ -217,7 +217,7 @@ begin
lc_lock(lock);
end;
function _cv_timedwait_sig_proctime(cvp:p_cv;lock:Pointer;timeout:ptimespec):Integer;
function _cv_timedwait_sig_proctime(cvp:p_cv;lock:Pointer;timeout:p_timespec):Integer;
var
tv,ts,ts2:Int64;
begin

View File

@ -37,7 +37,7 @@ procedure kqueue_task (arg:Pointer;pending:Integer);
function kqueue_scan (kq:p_kqueue;
maxevents:Integer;
k_ops:p_kevent_copyops;
tsp:ptimespec;
tsp:p_timespec;
keva:p_kevent):Integer;
procedure kqueue_wakeup (kq:p_kqueue);
function kqueue_fo_find (filt:Integer):p_filterops;
@ -117,7 +117,9 @@ uses
kern_sx,
vfs_subr,
subr_hash,
vsys_generic;
vsys_generic,
kern_callout,
kern_timeout;
//static MALLOC_DEFINE(M_KQUEUE, 'kqueue', 'memory for kqueue system');
@ -616,9 +618,9 @@ end;
procedure filt_timerexpire(knx:Pointer);
var
kn:p_knote;
calloutp:p_callout;
begin
kn:=knx;
//struct callout *calloutp;
Inc(kn^.kn_kevent.data);
KNOTE_ACTIVATE(kn, 0); { XXX - handle locking }
@ -632,8 +634,8 @@ begin
}
if ((kn^.kn_flags and EV_ONESHOT)<>EV_ONESHOT) then
begin
//calloutp:=kn^.kn_hook;
//callout_reset_curcpu(calloutp, timertoticks(kn^.kn_sdata) - 1, @filt_timerexpire, kn);
calloutp:=kn^.kn_hook;
callout_reset_curcpu(calloutp, timertoticks(kn^.kn_sdata) - 1, @filt_timerexpire, kn);
end;
end;
@ -641,9 +643,9 @@ end;
* data contains amount of time to sleep, in milliseconds
}
function filt_timerattach(kn:p_knote):Integer;
var
calloutp:p_callout;
begin
//struct callout *calloutp;
System.InterlockedIncrement(kq_ncallouts);
if (kq_ncallouts >= kq_calloutmax) then
@ -655,21 +657,21 @@ begin
kn^.kn_flags:=kn^.kn_flags or EV_CLEAR; { automatically set }
kn^.kn_status:=kn^.kn_status and (not KN_DETACHED); { knlist_add usually sets it }
//calloutp:=malloc(sizeof(calloutp), M_KQUEUE, M_WAITOK);
//callout_init(calloutp, CALLOUT_MPSAFE);
//kn^.kn_hook:=calloutp;
//callout_reset_curcpu(calloutp, timertoticks(kn^.kn_sdata), @filt_timerexpire, kn);
calloutp:=AllocMem(SizeOf(t_callout));
callout_init(calloutp, CALLOUT_MPSAFE);
kn^.kn_hook:=calloutp;
callout_reset_curcpu(calloutp, timertoticks(kn^.kn_sdata), @filt_timerexpire, kn);
Exit(0);
end;
procedure filt_timerdetach(kn:p_knote);
var
calloutp:p_callout;
begin
//struct callout *calloutp;
//calloutp:=(struct callout *)kn^.kn_hook;
//callout_drain(calloutp);
//free(calloutp, M_KQUEUE);
calloutp:=kn^.kn_hook;
callout_drain(calloutp);
FreeMem(calloutp);
System.InterlockedDecrement(kq_ncallouts);
kn^.kn_status:=kn^.kn_status or KN_DETACHED; { knlist_remove usually clears it }
@ -842,7 +844,7 @@ type
nchanges :Integer;
eventlist :p_kevent;
nevents :Integer;
timeout :ptimespec;
timeout :p_timespec;
end;
{
@ -887,7 +889,7 @@ function kern_kevent(fd:Integer;
nchanges:Integer;
nevents:Integer;
k_ops:p_kevent_copyops;
timeout:ptimespec):Integer;
timeout:p_timespec):Integer;
label
done_norel,
done;
@ -966,7 +968,7 @@ function sys_kevent(fd:Integer;
timeout:Pointer):Integer;
var
ts:timespec;
tsp:Ptimespec;
tsp:p_timespec;
error:Integer;
uap:t_kevent_args;
k_ops:t_kevent_copyops;
@ -1507,7 +1509,7 @@ end;
function kqueue_scan(kq:p_kqueue;
maxevents:Integer;
k_ops:p_kevent_copyops;
tsp:ptimespec;
tsp:p_timespec;
keva:p_kevent):Integer;
label
done,

View File

@ -94,7 +94,7 @@ begin
Exit(0);
end;
function ksched_rr_get_interval(ksched:p_ksched;td:p_kthread;time:Ptimespec):Integer;
function ksched_rr_get_interval(ksched:p_ksched;td:p_kthread;time:p_timespec):Integer;
begin
time^:=ksched^.rr_interval;
Exit(0);
@ -284,7 +284,7 @@ begin
Exit(error);
end;
function kern_sched_rr_get_interval(td:p_kthread;pid:Integer;ts:ptimespec):Integer;
function kern_sched_rr_get_interval(td:p_kthread;pid:Integer;ts:p_timespec):Integer;
var
e:Integer;
begin

View File

@ -796,7 +796,7 @@ end;
Function kern_sigtimedwait(td:p_kthread;
waitset:sigset_t;
ksi:p_ksiginfo;
timeout:ptimespec
timeout:p_timespec
):Integer;
var
saved_mask,new_block:sigset_t;

View File

@ -819,7 +819,7 @@ begin
Result:=sys_thr_kill(id,sig);
end;
function kern_thr_suspend(td:p_kthread;tsp:ptimespec):Integer;
function kern_thr_suspend(td:p_kthread;tsp:p_timespec):Integer;
var
tv:Int64;
begin
@ -884,7 +884,7 @@ function sys_thr_suspend(timeout:Pointer):Integer;
var
td:p_kthread;
ts:timespec;
tsp:ptimespec;
tsp:p_timespec;
begin
td:=curkthread;
if (td=nil) then Exit(-1);

View File

@ -10,9 +10,9 @@ uses
Procedure timeinit; //SYSINIT
procedure getmicrouptime(tvp:ptimeval);
procedure getnanotime(tp:Ptimespec);
procedure getmicrotime(tvp:ptimeval);
procedure getmicrouptime(tvp:p_timeval);
procedure getnanotime(tp:p_timespec);
procedure getmicrotime(tvp:p_timeval);
function sys_clock_gettime(clock_id:Integer;tp:Pointer):Integer;
function sys_clock_settime(clock_id:Integer;tp:Pointer):Integer;
@ -40,7 +40,7 @@ begin
getmicrouptime(@boottime);
end;
procedure getmicrouptime(tvp:ptimeval);
procedure getmicrouptime(tvp:p_timeval);
var
time:Int64;
begin
@ -49,7 +49,7 @@ begin
tvp^.tv_usec:=(time mod UNIT_PER_SEC) div 10;
end;
procedure getnanotime(tp:Ptimespec);
procedure getnanotime(tp:p_timespec);
var
time:Int64;
begin
@ -59,7 +59,7 @@ begin
tp^.tv_nsec:=(time mod UNIT_PER_SEC)*100;
end;
procedure getmicrotime(tvp:ptimeval);
procedure getmicrotime(tvp:p_timeval);
var
time:Int64;
begin
@ -105,7 +105,7 @@ end;
var
nanowait:Integer=0;
function kern_nanosleep(rqt,rmt:ptimespec):Integer;
function kern_nanosleep(rqt,rmt:p_timespec):Integer;
var
ts,ts2,tv:Int64;
error:Integer;
@ -212,7 +212,7 @@ begin
Exit(EPERM);
end;
function kern_adjtime(delta,olddelta:ptimeval):Integer;
function kern_adjtime(delta,olddelta:p_timeval):Integer;
var
atv:timeval;
begin
@ -237,7 +237,7 @@ end;
function sys_adjtime(delta,olddelta:Pointer):Integer;
var
_delta,_olddelta:timeval;
deltap:ptimeval;
deltap:p_timeval;
error:Integer;
begin
if (delta<>nil) then

View File

@ -27,7 +27,7 @@ function sys__umtx_op(obj:Pointer;op:Integer;val:QWORD;uaddr1,uaddr2:Pointer):I
function kern_umtx_wake(td:p_kthread;umtx:p_umtx;n_wake,priv:Integer):Integer;
function umtx_copyin_timeout(addr:Pointer;tsp:ptimespec):Integer;
function umtx_copyin_timeout(addr:Pointer;tsp:p_timespec):Integer;
procedure umtxq_sysinit; //SYSINIT
@ -476,7 +476,7 @@ begin
until false;
end;
function do_lock_umtx(td:p_kthread;umtx:p_umtx;id:QWORD;timeout:ptimespec):Integer;
function do_lock_umtx(td:p_kthread;umtx:p_umtx;id:QWORD;timeout:p_timespec):Integer;
var
tv,ts,ts2:Int64;
begin
@ -572,7 +572,7 @@ end;
function do_wait(td :p_kthread;
addr :Pointer;
id :QWORD;
timeout :ptimespec;
timeout :p_timespec;
compat32:Integer;
priv :Integer
):Integer;
@ -1421,7 +1421,7 @@ begin
end;
end;
function do_lock_umutex(td:p_kthread;m:p_umutex;timeout:ptimespec;mode:Integer):Integer;
function do_lock_umutex(td:p_kthread;m:p_umutex;timeout:p_timespec;mode:Integer):Integer;
var
flags:DWORD;
tv,ts,ts2:Int64;
@ -1486,7 +1486,7 @@ end;
////
function do_cv_wait(td:p_kthread;cv:p_ucond;m:p_umutex;timeout:ptimespec;wflags:QWORD):Integer;
function do_cv_wait(td:p_kthread;cv:p_ucond;m:p_umutex;timeout:p_timespec;wflags:QWORD):Integer;
label
_exit;
var
@ -1784,7 +1784,7 @@ begin
umtx_key_release(uq^.uq_key);
end;
function do_rw_rdlock2(td:p_kthread;rwlock:p_urwlock;fflag:QWORD;timeout:ptimespec):Integer;
function do_rw_rdlock2(td:p_kthread;rwlock:p_urwlock;fflag:QWORD;timeout:p_timespec):Integer;
var
ts,ts2,tv:Int64;
begin
@ -1951,7 +1951,7 @@ begin
umtx_key_release(uq^.uq_key);
end;
function do_rw_wrlock2(td:p_kthread;rwlock:p_urwlock;fflag:QWORD;timeout:ptimespec):Integer;
function do_rw_wrlock2(td:p_kthread;rwlock:p_urwlock;fflag:QWORD;timeout:p_timespec):Integer;
var
ts,ts2,tv:Int64;
begin
@ -2100,7 +2100,7 @@ end;
////
function do_sem_wait(td:p_kthread;sem:p__usem;timeout:ptimespec):Integer;
function do_sem_wait(td:p_kthread;sem:p__usem;timeout:p_timespec):Integer;
var
uq:p_umtx_q;
count:DWORD;
@ -2202,7 +2202,7 @@ end;
////
function umtx_copyin_timeout(addr:Pointer;tsp:ptimespec):Integer;
function umtx_copyin_timeout(addr:Pointer;tsp:p_timespec):Integer;
begin
Result:=copyin(addr,tsp,SizeOf(timespec));
if (Result=0) then
@ -2221,7 +2221,7 @@ end;
function __umtx_op_lock_umtx(td:p_kthread;obj:Pointer;val:QWORD;uaddr1,uaddr2:Pointer):Integer;
var
ts:ptimespec;
ts:p_timespec;
timeout:timespec;
begin
ts:=nil;
@ -2241,7 +2241,7 @@ end;
function __umtx_op_wait(td:p_kthread;obj:Pointer;val:QWORD;uaddr1,uaddr2:Pointer):Integer;
var
ts:ptimespec;
ts:p_timespec;
timeout:timespec;
begin
ts:=nil;
@ -2256,7 +2256,7 @@ end;
function __umtx_op_wait_uint(td:p_kthread;obj:Pointer;val:QWORD;uaddr1,uaddr2:Pointer):Integer;
var
ts:ptimespec;
ts:p_timespec;
timeout:timespec;
begin
ts:=nil;
@ -2271,7 +2271,7 @@ end;
function __umtx_op_wait_uint_private(td:p_kthread;obj:Pointer;val:QWORD;uaddr1,uaddr2:Pointer):Integer;
var
ts:ptimespec;
ts:p_timespec;
timeout:timespec;
begin
ts:=nil;
@ -2333,7 +2333,7 @@ end;
function __umtx_op_lock_umutex(td:p_kthread;obj:Pointer;val:QWORD;uaddr1,uaddr2:Pointer):Integer;
var
ts:ptimespec;
ts:p_timespec;
timeout:timespec;
begin
ts:=nil;
@ -2353,7 +2353,7 @@ end;
function __umtx_op_wait_umutex(td:p_kthread;obj:Pointer;val:QWORD;uaddr1,uaddr2:Pointer):Integer;
var
ts:ptimespec;
ts:p_timespec;
timeout:timespec;
begin
ts:=nil;
@ -2388,7 +2388,7 @@ end;
function __umtx_op_cv_wait(td:p_kthread;obj:Pointer;val:QWORD;uaddr1,uaddr2:Pointer):Integer;
var
ts:ptimespec;
ts:p_timespec;
timeout:timespec;
begin
ts:=nil;
@ -2472,7 +2472,7 @@ end;
function __umtx_op_sem_wait(td:p_kthread;obj:Pointer;val:QWORD;uaddr1,uaddr2:Pointer):Integer;
var
ts:ptimespec;
ts:p_timespec;
timeout:timespec;
begin
if (ptrint(obj)<$1000) then Exit(EFAULT);

View File

@ -17,12 +17,12 @@ procedure calcru_proc(user,syst:PInt64);
procedure get_process_cputime(time:PInt64);
procedure calcru_thread(user,syst:PInt64);
procedure get_thread_cputime(time:PInt64);
procedure gettimezone(z:Ptimezone);
procedure getadjtime(tv:ptimeval);
procedure gettimezone(z:p_timezone);
procedure getadjtime(tv:p_timeval);
function kern_clock_gettime_unit(clock_id:Integer;time:PInt64):Integer;
function kern_clock_gettime(clock_id:Integer;tp:Ptimespec):Integer;
function kern_clock_getres(clock_id:Integer;tp:Ptimespec):Integer;
function kern_clock_gettime(clock_id:Integer;tp:p_timespec):Integer;
function kern_clock_getres(clock_id:Integer;tp:p_timespec):Integer;
implementation
@ -142,7 +142,7 @@ begin
time^:=k.ExitTime.QuadPart-k.CreateTime.QuadPart;
end;
procedure gettimezone(z:Ptimezone);
procedure gettimezone(z:p_timezone);
var
TZInfo:TTimeZoneInformation;
tzi:DWORD;
@ -162,7 +162,7 @@ begin
end;
end;
procedure getadjtime(tv:ptimeval);
procedure getadjtime(tv:p_timeval);
var
STA:SYSTEM_QUERY_TIME_ADJUST_INFORMATION;
R:DWORD;
@ -245,7 +245,7 @@ begin
end;
end;
function kern_clock_gettime(clock_id:Integer;tp:Ptimespec):Integer;
function kern_clock_gettime(clock_id:Integer;tp:p_timespec):Integer;
var
time:Int64;
begin
@ -258,7 +258,7 @@ begin
end;
end;
function kern_clock_getres(clock_id:Integer;tp:Ptimespec):Integer;
function kern_clock_getres(clock_id:Integer;tp:p_timespec):Integer;
begin
Result:=0;

View File

@ -13,9 +13,9 @@ procedure umtx_init(var umtx:umtx); inline;
function umtx_owner(var umtx:umtx):QWORD; inline;
function umtx_lock(var umtx:umtx;id:QWORD):Integer; inline;
function umtx_trylock(var umtx:umtx;id:QWORD):Integer; inline;
function umtx_timedlock(var umtx:umtx;id:QWORD;timeout:ptimespec):Integer; inline;
function umtx_timedlock(var umtx:umtx;id:QWORD;timeout:p_timespec):Integer; inline;
function umtx_unlock(var umtx:umtx;id:QWORD):Integer; inline;
function umtx_wait(var umtx:umtx;id:QWORD;timeout:ptimespec):Integer; inline;
function umtx_wait(var umtx:umtx;id:QWORD;timeout:p_timespec):Integer; inline;
function umtx_wake(var umtx:umtx;nr_wakeup:Integer):Integer; inline;
function _umtx_op_err(obj:Pointer;op:Integer;val:QWORD;uaddr1,uaddr2:Pointer):Integer;
@ -57,7 +57,7 @@ begin
end;
end;
function umtx_timedlock(var umtx:umtx;id:QWORD;timeout:ptimespec):Integer; inline;
function umtx_timedlock(var umtx:umtx;id:QWORD;timeout:p_timespec):Integer; inline;
begin
Result:=0;
if (System.InterlockedCompareExchange64(umtx.u_owner,id,UMTX_UNOWNED)=0) then
@ -75,7 +75,7 @@ begin
end;
end;
function umtx_wait(var umtx:umtx;id:QWORD;timeout:ptimespec):Integer; inline;
function umtx_wait(var umtx:umtx;id:QWORD;timeout:p_timespec):Integer; inline;
begin
Result:=_umtx_op(@umtx,UMTX_OP_WAIT,id,nil,timeout)
end;

View File

@ -34,28 +34,35 @@ const
CLOCK_EXT_RAW_NETWORK =19; // ORBIS only
type
Ptimespec=^timespec;
p_bintime=^bintime;
bintime=packed record
sec :Int64;
frac:Int64;
end;
{$IF sizeof(bintime)<>16}{$STOP sizeof(bintime)<>16}{$ENDIF}
p_timespec=^timespec;
timespec=packed record
tv_sec :Int64; /// seconds
tv_nsec:Int64; /// nanoseconds
end;
{$IF sizeof(timespec)<>16}{$STOP sizeof(timespec)<>16}{$ENDIF}
Ptimeval=^timeval;
p_timeval=^timeval;
timeval=packed record
tv_sec :Int64;
tv_usec:Int64; //microsecond
end;
{$IF sizeof(timeval)<>16}{$STOP sizeof(timeval)<>16}{$ENDIF}
Pitimerval=^itimerval;
p_itimerval=^itimerval;
itimerval=packed record
it_interval:timeval; { timer interval }
it_value :timeval; { current value }
end;
{$IF sizeof(itimerval)<>32}{$STOP sizeof(itimerval)<>32}{$ENDIF}
Ptimezone=^timezone;
p_timezone=^timezone;
timezone=packed record
tz_minuteswest:Integer;
tz_dsttime :Integer;
@ -93,29 +100,32 @@ function _nsec2usec(nsec:QWORD):QWORD; //Nanosecond to Microsecond
function _msec2nsec(msec:QWORD):QWORD; //Milisecond to Nanosecond
function _nsec2msec(nsec:QWORD):QWORD; //Nanosecond to Milisecond
procedure timevalfix(t1:ptimeval);
procedure timevaladd(t1,t2:ptimeval);
procedure timevalsub(t1,t2:ptimeval);
procedure bintime2timespec(bt:p_bintime;ts:p_timespec);
procedure timespec2bintime(ts:p_timespec;bt:p_bintime);
function timespeccmp_lt(tvp,uvp:ptimespec):Integer;
procedure timevalfix(t1:p_timeval);
procedure timevaladd(t1,t2:p_timeval);
procedure timevalsub(t1,t2:p_timeval);
procedure TIMEVAL_TO_TIMESPEC(tv:ptimeval;ts:ptimespec);
procedure TIMESPEC_TO_TIMEVAL(tv:ptimeval;ts:ptimespec);
function timespeccmp_lt(tvp,uvp:p_timespec):Integer;
function TIMESPEC_TO_UNIT(ts:ptimespec):Int64; //Unit
procedure UNIT_TO_TIMESPEC(ts:ptimespec;u:Int64); //Unit
function TIMEVAL_TO_UNIT (tv:ptimeval ):Int64; //Unit
procedure UNIT_TO_TIMEVAL (tv:ptimeval;u:Int64); //Unit
function USEC_TO_UNIT (usec:QWORD ):Int64; //Unit
procedure TIMEVAL_TO_TIMESPEC(tv:p_timeval;ts:p_timespec);
procedure TIMESPEC_TO_TIMEVAL(tv:p_timeval;ts:p_timespec);
function TIMESPEC_TO_UNIT(ts:p_timespec):Int64; //Unit
procedure UNIT_TO_TIMESPEC(ts:p_timespec;u:Int64); //Unit
function TIMEVAL_TO_UNIT (tv:p_timeval ):Int64; //Unit
procedure UNIT_TO_TIMEVAL (tv:p_timeval;u:Int64); //Unit
function USEC_TO_UNIT (usec:QWORD ):Int64; //Unit
function cputick2usec(time:QWORD):QWORD; inline;
function tvtohz(time:Int64):Int64;
procedure usec2timespec(ts:ptimespec;timeo:DWORD);
procedure usec2timespec(ts:p_timespec;timeo:DWORD);
procedure TIMESPEC_ADD(dst,src,val:ptimespec);
procedure TIMESPEC_SUB(dst,src,val:ptimespec);
procedure TIMESPEC_ADD(dst,src,val:p_timespec);
procedure TIMESPEC_SUB(dst,src,val:p_timespec);
function itimerfix(tv:ptimeval):Integer;
function itimerfix(tv:p_timeval):Integer;
var
boottime:timeval;
@ -155,7 +165,19 @@ begin
Result:=(nsec+999999) div 1000000;
end;
procedure timevalfix(t1:ptimeval);
procedure bintime2timespec(bt:p_bintime;ts:p_timespec);
begin
ts^.tv_sec :=bt^.sec;
ts^.tv_nsec:=(QWORD(1000000000)*DWORD(bt^.frac shr 32)) shr 32;
end;
procedure timespec2bintime(ts:p_timespec;bt:p_bintime);
begin
bt^.sec :=ts^.tv_sec;
bt^.frac:=ts^.tv_nsec*QWORD(18446744073);
end;
procedure timevalfix(t1:p_timeval);
begin
if (t1^.tv_usec < 0) then
begin
@ -169,21 +191,21 @@ begin
end;
end;
procedure timevaladd(t1,t2:ptimeval);
procedure timevaladd(t1,t2:p_timeval);
begin
Inc(t1^.tv_sec ,t2^.tv_sec);
Inc(t1^.tv_usec,t2^.tv_usec);
timevalfix(t1);
end;
procedure timevalsub(t1,t2:ptimeval);
procedure timevalsub(t1,t2:p_timeval);
begin
Dec(t1^.tv_sec ,t2^.tv_sec);
Dec(t1^.tv_usec,t2^.tv_usec);
timevalfix(t1);
end;
function timespeccmp_lt(tvp,uvp:ptimespec):Integer;
function timespeccmp_lt(tvp,uvp:p_timespec):Integer;
begin
if (tvp^.tv_sec=uvp^.tv_sec) then
begin
@ -194,35 +216,35 @@ begin
end;
end;
procedure TIMEVAL_TO_TIMESPEC(tv:ptimeval;ts:ptimespec);
procedure TIMEVAL_TO_TIMESPEC(tv:p_timeval;ts:p_timespec);
begin
ts^.tv_sec :=tv^.tv_sec;
ts^.tv_nsec:=tv^.tv_usec * 1000;
end;
procedure TIMESPEC_TO_TIMEVAL(tv:ptimeval;ts:ptimespec);
procedure TIMESPEC_TO_TIMEVAL(tv:p_timeval;ts:p_timespec);
begin
tv^.tv_sec :=ts^.tv_sec;
tv^.tv_usec:=ts^.tv_nsec div 1000;
end;
function TIMESPEC_TO_UNIT(ts:ptimespec):Int64; //Unit
function TIMESPEC_TO_UNIT(ts:p_timespec):Int64; //Unit
begin
Result:=(QWORD(ts^.tv_sec)*UNIT_PER_SEC)+(QWORD(ts^.tv_nsec) div NSEC_PER_UNIT);
end;
procedure UNIT_TO_TIMESPEC(ts:ptimespec;u:Int64); //Unit
procedure UNIT_TO_TIMESPEC(ts:p_timespec;u:Int64); //Unit
begin
ts^.tv_sec :=(u div UNIT_PER_SEC);
ts^.tv_nsec:=(u mod UNIT_PER_SEC)*NSEC_PER_UNIT;
end;
function TIMEVAL_TO_UNIT(tv:ptimeval):Int64; //Unit
function TIMEVAL_TO_UNIT(tv:p_timeval):Int64; //Unit
begin
Result:=(QWORD(tv^.tv_sec)*UNIT_PER_SEC)+(QWORD(tv^.tv_usec)*UNIT_PER_USEC);
end;
procedure UNIT_TO_TIMEVAL(tv:ptimeval;u:Int64); //Unit
procedure UNIT_TO_TIMEVAL(tv:p_timeval;u:Int64); //Unit
begin
tv^.tv_sec :=(u div UNIT_PER_SEC);
tv^.tv_usec:=(u mod UNIT_PER_SEC) div UNIT_PER_USEC;
@ -243,13 +265,13 @@ begin
Result:=time;
end;
procedure usec2timespec(ts:ptimespec;timeo:DWORD);
procedure usec2timespec(ts:p_timespec;timeo:DWORD);
begin
ts^.tv_sec :=(timeo div 1000000);
ts^.tv_nsec:=(timeo mod 1000000)*1000;
end;
procedure TIMESPEC_ADD(dst,src,val:ptimespec);
procedure TIMESPEC_ADD(dst,src,val:p_timespec);
begin
dst^.tv_sec :=src^.tv_sec +val^.tv_sec;
dst^.tv_nsec:=src^.tv_nsec+val^.tv_nsec;
@ -260,7 +282,7 @@ begin
end;
end;
procedure TIMESPEC_SUB(dst,src,val:ptimespec);
procedure TIMESPEC_SUB(dst,src,val:p_timespec);
begin
dst^.tv_sec :=src^.tv_sec -val^.tv_sec;
dst^.tv_nsec:=src^.tv_nsec-val^.tv_nsec;
@ -277,7 +299,7 @@ end;
* fix it to have at least minimal value (i.e. if it is less
* than the resolution of the clock, round it up.)
}
function itimerfix(tv:ptimeval):Integer;
function itimerfix(tv:p_timeval):Integer;
begin
if (tv^.tv_sec < 0) or (tv^.tv_usec < 0) or (tv^.tv_usec >= 1000000) then
Exit(EINVAL);

View File

@ -31,7 +31,7 @@ function vfs_busy(mp:p_mount;flags:Integer):Integer;
procedure vfs_unbusy(mp:p_mount);
function vfs_getvfs(fsid:p_fsid):p_mount;
procedure vfs_getnewfsid(mp:p_mount);
procedure vfs_timestamp(tsp:Ptimespec);
procedure vfs_timestamp(tsp:p_timespec);
procedure vattr_null(vap:p_vattr);
procedure v_incr_usecount(vp:p_vnode);
@ -363,7 +363,7 @@ end;
{
* Get a current timestamp.
}
procedure vfs_timestamp(tsp:Ptimespec);
procedure vfs_timestamp(tsp:p_timespec);
begin
getnanotime(tsp);
end;

View File

@ -24,9 +24,9 @@ uses
vfs_lookup;
function chroot_refuse_vdir_fds():Integer;
function getutimes(usrtvp:ptimeval;tvpseg:uio_seg;tsp:ptimespec):Integer;
function getutimes(usrtvp:p_timeval;tvpseg:uio_seg;tsp:p_timespec):Integer;
function setfflags(vp:p_vnode;flags:Integer):Integer;
function setutimes(vp:p_vnode;ts:ptimespec;numtimes,nilflag:Integer):Integer;
function setutimes(vp:p_vnode;ts:p_timespec;numtimes,nilflag:Integer):Integer;
function vn_access(vp:p_vnode;user_flags:Integer):Integer;
function setfown(vp:p_vnode;uid:uid_t;gid:gid_t):Integer;
function setfmode(vp:p_vnode;mode:Integer):Integer;
@ -113,10 +113,10 @@ function kern_fchmodat(fd:Integer;path:PChar;pathseg:uio_seg;mode,flag:Integer):
function kern_chmod(path:PChar;pathseg:uio_seg;mode:Integer):Integer;
function kern_chown(path:PChar;pathseg:uio_seg;uid,gid:Integer):Integer;
function kern_lchown(path:PChar;pathseg:uio_seg;uid,gid:Integer):Integer;
function kern_utimesat(fd:Integer;path:PChar;pathseg:uio_seg;tptr:ptimeval;tptrseg:uio_seg):Integer;
function kern_utimes(path:PChar;pathseg:uio_seg;tptr:ptimeval;tptrseg:uio_seg):Integer;
function kern_lutimes(path:PChar;pathseg:uio_seg;tptr:ptimeval;tptrseg:uio_seg):Integer;
function kern_futimes(fd:Integer;tptr:ptimeval;tptrseg:uio_seg):Integer;
function kern_utimesat(fd:Integer;path:PChar;pathseg:uio_seg;tptr:p_timeval;tptrseg:uio_seg):Integer;
function kern_utimes(path:PChar;pathseg:uio_seg;tptr:p_timeval;tptrseg:uio_seg):Integer;
function kern_lutimes(path:PChar;pathseg:uio_seg;tptr:p_timeval;tptrseg:uio_seg):Integer;
function kern_futimes(fd:Integer;tptr:p_timeval;tptrseg:uio_seg):Integer;
function kern_truncate(path:PChar;pathseg:uio_seg;length:Int64):Integer;
function kern_fsync(fd:Integer;fullsync:Boolean):Integer;
function kern_renameat(oldfd:Integer;old:PChar;newfd:Integer;new:PChar;pathseg:uio_seg):Integer;
@ -2174,10 +2174,10 @@ end;
{
* Common implementation code for utimes(), lutimes(), and futimes().
}
function getutimes(usrtvp:ptimeval;tvpseg:uio_seg;tsp:ptimespec):Integer;
function getutimes(usrtvp:p_timeval;tvpseg:uio_seg;tsp:p_timespec):Integer;
var
tv:array[0..1] of timeval;
tvp:ptimeval;
tvp:p_timeval;
error:Integer;
begin
if (usrtvp=nil) then
@ -2210,7 +2210,7 @@ end;
{
* Common implementation code for utimes(), lutimes(), and futimes().
}
function setutimes(vp:p_vnode;ts:ptimespec;numtimes,nilflag:Integer):Integer;
function setutimes(vp:p_vnode;ts:p_timespec;numtimes,nilflag:Integer):Integer;
var
error,setbirthtime:Integer;
mp:p_mount;
@ -2251,7 +2251,7 @@ begin
end;
function kern_utimesat(fd:Integer;path:PChar;pathseg:uio_seg;
tptr:ptimeval;tptrseg:uio_seg):Integer;
tptr:p_timeval;tptrseg:uio_seg):Integer;
var
nd:t_nameidata;
ts:array[0..1] of timespec;
@ -2274,7 +2274,7 @@ begin
end;
function kern_utimes(path:PChar;pathseg:uio_seg;
tptr:ptimeval;tptrseg:uio_seg):Integer;
tptr:p_timeval;tptrseg:uio_seg):Integer;
begin
Exit(kern_utimesat(AT_FDCWD, path, pathseg, tptr, tptrseg));
end;
@ -2293,7 +2293,7 @@ begin
end;
function kern_lutimes(path:PChar;pathseg:uio_seg;
tptr:ptimeval;tptrseg:uio_seg):Integer;
tptr:p_timeval;tptrseg:uio_seg):Integer;
var
ts:array[0..1] of timespec;
error:Integer;
@ -2323,7 +2323,7 @@ begin
Exit(kern_lutimes(path, UIO_USERSPACE, tptr, UIO_USERSPACE));
end;
function kern_futimes(fd:Integer;tptr:ptimeval;tptrseg:uio_seg):Integer;
function kern_futimes(fd:Integer;tptr:p_timeval;tptrseg:uio_seg):Integer;
var
ts:array[0..1] of timespec;
fp:p_file;

View File

@ -568,12 +568,12 @@ end;
function kern_select(nd:Integer;
fd_in,fd_ou,fd_ex:p_fd_set;
tvp:ptimeval;
tvp:p_timeval;
abi_nfdbits:Integer):Integer; forward;
function kern_pselect(nd:Integer;
uin,uou,uex:p_fd_set;
tvp:ptimeval;
tvp:p_timeval;
uset:p_sigset_t;
abi_nfdbits:Integer):Integer;
var
@ -604,7 +604,7 @@ function sys_pselect(nd:Integer;uin,uou,uex,uts,sm:Pointer):Integer;
var
ts:timespec;
tv:timeval;
tvp:ptimeval;
tvp:p_timeval;
_set:sigset_t;
uset:p_sigset_t;
error:Integer;
@ -632,7 +632,7 @@ end;
function sys_select(nd:Integer;uin,uou,uex,utv:Pointer):Integer;
var
tv:timeval;
tvp:ptimeval;
tvp:p_timeval;
error:Integer;
begin
if (utv<>nil) then
@ -687,7 +687,7 @@ end;
function kern_select(nd:Integer;
fd_in,fd_ou,fd_ex:p_fd_set;
tvp:ptimeval;
tvp:p_timeval;
abi_nfdbits:Integer):Integer;
label
done;