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_fsbase :Pointer;
pcb_gsbase :Pointer; pcb_gsbase :Pointer;
td_retval :array[0..1] of QWORD; td_retval :array[0..1] of QWORD;
td_ksttop :Pointer;
td_kstack :Pointer; td_kstack :Pointer;
// //
td_sleepqueue :Pointer; td_sleepqueue :Pointer;

View File

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

View File

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

View File

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

View File

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