Final touches to the SEH library: now comes with a very basic setjmp/longjmp implemen...
authorKJK::Hyperion <hackbunny@reactos.org>
Thu, 3 Jun 2004 02:23:34 +0000 (02:23 +0000)
committerKJK::Hyperion <hackbunny@reactos.org>
Thu, 3 Jun 2004 02:23:34 +0000 (02:23 +0000)
svn path=/trunk/; revision=9598

reactos/include/pseh/framebased.h
reactos/include/pseh/setjmp.h [new file with mode: 0644]
reactos/lib/pseh/i386/setjmp.asm [new file with mode: 0644]
reactos/lib/pseh/makefile.i386

index 7d76aa2..085550b 100644 (file)
 #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
 {
diff --git a/reactos/include/pseh/setjmp.h b/reactos/include/pseh/setjmp.h
new file mode 100644 (file)
index 0000000..ef17bc6
--- /dev/null
@@ -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 */
diff --git a/reactos/lib/pseh/i386/setjmp.asm b/reactos/lib/pseh/i386/setjmp.asm
new file mode 100644 (file)
index 0000000..43431ba
--- /dev/null
@@ -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
index 1fde404..09e802f 100644 (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