+ implemented set_jmp and long_jmp on win16 via the Catch and Throw winapi

functions, which provide the same functionality, but are safe to use in all
  windows modes (e.g. they include the magic for handling jumps to discarded
  or moved code segments in real mode)

git-svn-id: trunk@31579 -
This commit is contained in:
nickysn 2015-09-08 16:03:50 +00:00
parent 600d2cfbc6
commit 024ebb287e
2 changed files with 30 additions and 2 deletions

View File

@ -13,6 +13,28 @@
**********************************************************************}
{$ifdef WIN16}
Function fpc_SetJmp (Var S : Jmp_buf) : smallint;[Public, alias : 'FPC_SETJMP']; compilerproc;
begin
{$ifdef FPC_X86_DATA_NEAR}
fpc_SetJmp:=Catch(Ptr(DSeg,Word(@CATCHBUF(S.catch_buf))));
{$else FPC_X86_DATA_NEAR}
fpc_SetJmp:=Catch(@CATCHBUF(S.catch_buf));
{$endif FPC_X86_DATA_NEAR}
end;
Procedure fpc_longJmp (Var S : Jmp_buf; value : smallint);[Public, alias : 'FPC_LONGJMP']; compilerproc;
begin
{$ifdef FPC_X86_DATA_NEAR}
Throw(Ptr(DSeg,Word(@CATCHBUF(S.catch_buf))),value);
{$else FPC_X86_DATA_NEAR}
Throw(@CATCHBUF(S.catch_buf),value);
{$endif FPC_X86_DATA_NEAR}
end;
{$else WIN16}
Function fpc_SetJmp (Var S : Jmp_buf) : smallint;assembler;nostackframe;[Public, alias : 'FPC_SETJMP']; compilerproc;
asm
mov si, sp
@ -80,3 +102,5 @@ asm
{$endif FPC_X86_CODE_NEAR}
{$endif FPC_X86_DATA_NEAR}
end;
{$endif WIN16}

View File

@ -15,12 +15,16 @@
Type
jmp_buf = packed record
{$ifdef WIN16}
catch_buf: array [0..8] of SmallInt;
{$else WIN16}
// bx,si,di: Word;
bp,sp: Word;
ip: Word;
{$ifdef FPC_X86_CODE_FAR}
{$ifdef FPC_X86_CODE_FAR}
cs: Word;
{$endif FPC_X86_CODE_FAR}
{$endif FPC_X86_CODE_FAR}
{$endif WIN16}
end;
PJmp_buf = ^jmp_buf;