From 6c9eb15409063fe1f9f2a172e189096cdf76b235 Mon Sep 17 00:00:00 2001 From: red-prig Date: Tue, 7 Feb 2023 23:30:58 +0300 Subject: [PATCH] + --- kernel/libthr/thr_private.pas | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/kernel/libthr/thr_private.pas b/kernel/libthr/thr_private.pas index d803f78f..29c26d88 100644 --- a/kernel/libthr/thr_private.pas +++ b/kernel/libthr/thr_private.pas @@ -161,6 +161,7 @@ type td_event_msg_t=array[0..5] of DWORD; + pthread_t=^pthread; pthread=packed record tid :Integer; _align1 :Integer; @@ -248,7 +249,31 @@ const THR_MAGIC=$d09ba115; +function SHOULD_CANCEL(thr:pthread_t):Boolean; inline; +function THR_SHOULD_GC(thr:pthread_t):Boolean; inline; +function THR_IN_CRITICAL(thr:pthread_t):Boolean; inline; + implementation +function SHOULD_CANCEL(thr:pthread_t):Boolean; inline; +begin + Result:=(thr^.cancel_pending<>0) and + (thr^.cancel_enable<>0) and + (thr^.no_cancel=0); +end; + +function THR_SHOULD_GC(thr:pthread_t):Boolean; inline; +begin + Result:=(thr^.refcount=0) and + (thr^.state=PS_DEAD) and + ((thr^.flags and THR_FLAGS_DETACHED)<>0); +end; + +function THR_IN_CRITICAL(thr:pthread_t):Boolean; inline; +begin + Result:=(thr^.locklevel>0) or + (thr^.critical_count>0); +end; + end.