2
0
Эх сурвалжийг харах

+ 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 жил өмнө
parent
commit
024ebb287e

+ 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;
 asm
   mov si, sp
@@ -80,3 +102,5 @@ asm
   {$endif FPC_X86_CODE_NEAR}
 {$endif FPC_X86_DATA_NEAR}
 end;
+
+{$endif WIN16}

+ 6 - 2
rtl/i8086/setjumph.inc

@@ -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;