Browse Source

+ 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 -

nickysn 10 years ago
parent
commit
024ebb287e
2 changed files with 30 additions and 2 deletions
  1. 24 0
      rtl/i8086/setjump.inc
  2. 6 2
      rtl/i8086/setjumph.inc

+ 24 - 0
rtl/i8086/setjump.inc

@@ -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;
 Function fpc_SetJmp (Var S : Jmp_buf) : smallint;assembler;nostackframe;[Public, alias : 'FPC_SETJMP']; compilerproc;
 asm
 asm
   mov si, sp
   mov si, sp
@@ -80,3 +102,5 @@ asm
   {$endif FPC_X86_CODE_NEAR}
   {$endif FPC_X86_CODE_NEAR}
 {$endif FPC_X86_DATA_NEAR}
 {$endif FPC_X86_DATA_NEAR}
 end;
 end;
+
+{$endif WIN16}

+ 6 - 2
rtl/i8086/setjumph.inc

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