Final touches to the SEH library: now comes with a very basic setjmp/longjmp implementation for when the compiler's native one can't be used

svn path=/trunk/; revision=9598
This commit is contained in:
KJK::Hyperion 2004-06-03 02:23:34 +00:00
parent ecc193a6f0
commit ce86f5b576
4 changed files with 120 additions and 3 deletions

View file

@ -24,9 +24,17 @@
#define KJK_PSEH_FRAMEBASED_H_
#include <pseh/framebased/internal.h>
#include <excpt.h>
#ifdef _SEH_NO_NATIVE_NLG
#include <setjmp.h>
#include <stddef.h>
#include <excpt.h>
#else
#include <pseh/setjmp.h>
#define longjmp _SEHLongJmp
#define setjmp _SEHSetJmp
#define jmp_buf _SEHJmpBuf_t
#endif
typedef struct __SEHFrame
{

View file

@ -0,0 +1,44 @@
/*
Copyright (c) 2004 KJK::Hyperion
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef KJK_PSEH_SETJMP_H_
#define KJK_PSEH_SETJMP_H_
#ifdef _M_IX86
typedef struct __SEHJmpBuf
{
unsigned long JB_Ebp;
unsigned long JB_Esp;
unsigned long JB_Eip;
unsigned long JB_Ebx;
unsigned long JB_Esi;
unsigned long JB_Edi;
}
_SEHJmpBuf_t[1];
#endif
extern __declspec(noreturn) void __stdcall _SEHLongJmp(_SEHJmpBuf_t, int);
extern int __stdcall _SEHSetJmp(_SEHJmpBuf_t);
#endif
/* EOF */

View file

@ -0,0 +1,65 @@
; Copyright (c) 2004 KJK::Hyperion
; Permission is hereby granted, free of charge, to any person obtaining a copy
; of this software and associated documentation files (the "Software"), to deal
; in the Software without restriction, including without limitation the rights
; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
; copies of the Software, and to permit persons to whom the Software is
; furnished to dos so, subject to the following conditions:
; The above copyright notice and this permission notice shall be included in all
; copies or substantial portions of the Software.
; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
; SOFTWARE.
cpu 486
segment .text use32
global SEHSetJmp
global __SEHSetJmp
SEHSetJmp:
__SEHSetJmp@8:
; jump buffer
mov eax, [esp+4]
; program counter
mov ecx, [esp+0]
; stack pointer
lea edx, [esp+4]
; fill the jump buffer
mov [eax+0], ebp
mov [eax+4], edx
mov [eax+8], ecx
mov [eax+12], ebx
mov [eax+16], esi
mov [eax+20], edi
ret 4
global SEHLongJmp
global __SEHLongJmp@8
SEHLongJmp:
__SEHLongJmp@8:
; return value
mov eax, [esp+8]
; jump buffer
mov ecx, [esp+4]
; restore the saved context
mov ebp, [ecx+0]
mov esp, [ecx+4]
mov edx, [ecx+8]
mov ebx, [ecx+12]
mov esi, [ecx+16]
mov edi, [ecx+20]
jmp edx
; EOF

View file

@ -1,5 +1,5 @@
# $Id: makefile.i386,v 1.1 2004/06/02 18:36:55 hyperion Exp $
# $Id: makefile.i386,v 1.2 2004/06/03 02:23:34 hyperion Exp $
TARGET_ARCH_OBJECTS = $(ARCH)/framebased.o
TARGET_ARCH_OBJECTS = $(ARCH)/framebased.o $(ARCH)/setjmp.o
# EOF