This commit is contained in:
Pavel 2023-06-06 16:42:29 +03:00
parent 15ace505c1
commit 91c8ac17a7
5 changed files with 36 additions and 28 deletions

View File

@ -165,6 +165,7 @@ type
pcb_fsbase :Pointer;
pcb_gsbase :Pointer;
td_retval :array[0..1] of QWORD;
td_ksttop :Pointer;
td_kstack :Pointer;
//
td_sleepqueue :Pointer;

View File

@ -53,6 +53,8 @@ begin
PAGE_READWRITE
);
td^.td_ksttop:=data;
data:=data+SYS_STACK_SIZE;
td^.td_kstack:=data;
end;

View File

@ -147,16 +147,10 @@ begin
end;
end;
function alloca(size:qword):Pointer; sysv_abi_default; assembler; nostackframe;
asm
movqq %rsp,%rax
subq %rdi,%rax
lea -8(%rax),%rax
andq $-32,%rax
movqq (%rsp),%rdi
movqq %rax,%rsp
lea -32(%rsp),%rsp
jmp %rdi
function get_top_mem_td(td:p_kthread;size,align:qword):Pointer;
begin
Result:=System.Align(td^.td_ksttop,align);
if ((Result+size)>=SPtr) then Exit(nil);
end;
procedure ipi_sigreturn;
@ -164,6 +158,7 @@ var
td:p_kthread;
Context:PCONTEXT;
regs:p_trapframe;
save:Pointer;
begin
td:=curkthread;
regs:=td^.td_frame;
@ -171,12 +166,14 @@ begin
if ((regs^.tf_flags and TF_HASFPXSTATE)<>0) then
begin
//xmm,ymm
Context:=alloca(GetContextSize(CONTEXT_ALLX));
Context:=get_top_mem_td(td,GetContextSize(CONTEXT_ALLX),16);
Assert(Context<>nil);
Context:=InitializeContextExtended(Context,CONTEXT_ALLX);
end else
begin
//simple
Context:=alloca(SizeOf(TCONTEXT)+15);
Context:=get_top_mem_td(td,SizeOf(TCONTEXT),16);
Assert(Context<>nil);
Context^:=Default(TCONTEXT);
Context^.ContextFlags:=CONTEXT_INTEGER or CONTEXT_CONTROL;
end;
@ -268,8 +265,8 @@ begin
goto resume;
end;
Context:=alloca(GetContextSize(CONTEXT_ALLX));
Context:=get_top_mem_td(td,GetContextSize(CONTEXT_ALLX),16);
Assert(Context<>nil);
Context:=InitializeContextExtended(Context,CONTEXT_ALLX);
if (NtGetContextThread(td_handle,Context)<>STATUS_SUCCESS) then

View File

@ -563,10 +563,18 @@
<IncludeAssertionCode Value="True"/>
</SyntaxOptions>
</Parsing>
<CodeGeneration>
<SmartLinkUnit Value="True"/>
<RelocatableUnit Value="True"/>
<Optimizations>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf3"/>
</Debugging>
<LinkSmart Value="True"/>
</Linking>
</CompilerOptions>
<Debugging>

View File

@ -444,12 +444,12 @@ begin
if (tid<>curkthread^.td_tid) then
begin
//test_files;
//Writeln('[--test_dirs--]');
//test_dirs('','/',1);
//Writeln('[--test_dirs--]');
//
//readln;
test_files;
Writeln('[--test_dirs--]');
test_dirs('','/',1);
Writeln('[--test_dirs--]');
readln;
tid2:=curkthread^.td_tid;
@ -1104,18 +1104,18 @@ begin
//test_map;
sys_init;
Writeln(get_proc_prio());
Writeln(set_proc_prio(14));
Writeln(get_proc_prio());
//Writeln(get_proc_prio());
//Writeln(set_proc_prio(14));
//Writeln(get_proc_prio());
Writeln(sys_getrusage(RUSAGE_SELF,@ru));
Writeln(sys_getrusage(RUSAGE_THREAD,@ru));
//Writeln(sys_getrusage(RUSAGE_SELF,@ru));
//Writeln(sys_getrusage(RUSAGE_THREAD,@ru));
e:=_umtx_op(nil,UMTX_OP_RW_WRLOCK,0,nil,nil);
Writeln('me=',e,' _errno:',__error^);
kern_clock_gettime_unit(CLOCK_PROCTIME,@_time);
writeln(_time/10000000:0:3);
//kern_clock_gettime_unit(CLOCK_PROCTIME,@_time);
//writeln(_time/10000000:0:3);
sys_adjtime(nil,@_tv);
writeln(_tv.tv_sec,',',_tv.tv_usec);
@ -1192,7 +1192,7 @@ begin
readln;
}
//BeginThread(@_thread);
BeginThread(@_thread);
//BeginThread(@_thread);
//BeginThread(@_thread);