Author: hyperion Date: Mon Feb 26 18:32:19 2007 New Revision: 25908
URL: http://svn.reactos.org/svn/reactos?rev=25908&view=rev Log: modified include/reactos/libs/pseh/framebased.h Removed some bad optimization ideas that never worked anyway. If you want optimization, use the uglier _SEHX macros. If you enjoy several huge, non-optimizable nested loops in all of your functions, just keep using the _SEH form
deleted include/reactos/libs/pseh/native.h deleted include/reactos/libs/pseh/prettybased.h Deleted some really bad ideas that nobody used or maintained anyway
All and all else Reformatted. Goodbye one-space indentation, hello tabs
Removed: trunk/reactos/include/reactos/libs/pseh/native.h trunk/reactos/include/reactos/libs/pseh/prettybased.h Modified: trunk/reactos/include/reactos/libs/pseh/excpt.h trunk/reactos/include/reactos/libs/pseh/framebased.h trunk/reactos/include/reactos/libs/pseh/framebased/internal.h trunk/reactos/include/reactos/libs/pseh/pseh.h trunk/reactos/include/reactos/libs/pseh/setjmp.h trunk/reactos/lib/pseh/framebased.c trunk/reactos/lib/pseh/i386/framebased.asm trunk/reactos/lib/pseh/i386/setjmp.asm
Modified: trunk/reactos/include/reactos/libs/pseh/excpt.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/pseh/e... ============================================================================== --- trunk/reactos/include/reactos/libs/pseh/excpt.h (original) +++ trunk/reactos/include/reactos/libs/pseh/excpt.h Mon Feb 26 18:32:19 2007 @@ -1,23 +1,23 @@ /* - Copyright (c) 2004/2005 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. + Copyright (c) 2004/2005 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_EXCPT_H_
Modified: trunk/reactos/include/reactos/libs/pseh/framebased.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/pseh/f... ============================================================================== --- trunk/reactos/include/reactos/libs/pseh/framebased.h (original) +++ trunk/reactos/include/reactos/libs/pseh/framebased.h Mon Feb 26 18:32:19 2007 @@ -1,23 +1,23 @@ /* - Copyright (c) 2004/2005 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. + Copyright (c) 2004/2005 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_FRAMEBASED_H_ @@ -27,47 +27,47 @@ #include <pseh/excpt.h>
#ifndef offsetof -# include <stddef.h> +# include <stddef.h> #endif
/* - Fall back to non-optimal, non-native NLG implementation for environments - without their own (e.g., currently, kernel-mode ReactOS/Windows). THIS IS NOT - RECOMMENDED AND IT WILL BE DROPPED IN A FUTURE VERSION BECAUSE IT MAY CAUSE - SEVERE STACK CORRUPTION. REIMPLEMENT OR PORT YOUR COMPILER'S NATIVE NLG - IMPLEMENTATION INSTEAD. + Fall back to non-optimal, non-native NLG implementation for environments + without their own (e.g., currently, kernel-mode ReactOS/Windows). THIS IS NOT + RECOMMENDED AND IT WILL BE DROPPED IN A FUTURE VERSION BECAUSE IT MAY CAUSE + SEVERE STACK CORRUPTION. REIMPLEMENT OR PORT YOUR COMPILER'S NATIVE NLG + IMPLEMENTATION INSTEAD. */ #ifdef _SEH_NO_NATIVE_NLG -# include <pseh/setjmp.h> +# include <pseh/setjmp.h> #else -# include <setjmp.h> -# define _SEHLongJmp longjmp -# define _SEHSetJmp setjmp -# define _SEHJmpBuf_t jmp_buf -#endif -unsigned long DbgPrint(const char * Format,...); +# include <setjmp.h> +# define _SEHLongJmp longjmp +# define _SEHSetJmp setjmp +# define _SEHJmpBuf_t jmp_buf +#endif + typedef struct __SEHFrame { - _SEHPortableFrame_t SEH_Header; - void * SEH_Locals; + _SEHPortableFrame_t SEH_Header; + void * SEH_Locals; } _SEHFrame_t;
typedef struct __SEHTryLevel { - _SEHPortableTryLevel_t ST_Header; - _SEHJmpBuf_t ST_JmpBuf; + _SEHPortableTryLevel_t ST_Header; + _SEHJmpBuf_t ST_JmpBuf; } _SEHTryLevel_t;
static __declspec(noreturn) __inline void __stdcall _SEHCompilerSpecificHandler ( - _SEHPortableTryLevel_t * trylevel + _SEHPortableTryLevel_t * trylevel ) { - _SEHTryLevel_t * mytrylevel; - mytrylevel = _SEH_CONTAINING_RECORD(trylevel, _SEHTryLevel_t, ST_Header); - _SEHLongJmp(mytrylevel->ST_JmpBuf, 1); + _SEHTryLevel_t * mytrylevel; + mytrylevel = _SEH_CONTAINING_RECORD(trylevel, _SEHTryLevel_t, ST_Header); + _SEHLongJmp(mytrylevel->ST_JmpBuf, 1); }
static const int _SEHScopeKind = 1; @@ -76,14 +76,14 @@ /* SHARED LOCALS */ /* Access the locals for the current frame */ #define _SEH_ACCESS_LOCALS(LOCALS_) \ - _SEH_LOCALS_TYPENAME(LOCALS_) * _SEHPLocals; \ - _SEHPLocals = \ - _SEH_PVOID_CAST \ - ( \ - _SEH_LOCALS_TYPENAME(LOCALS_) *, \ - _SEH_CONTAINING_RECORD(_SEHPortableFrame, _SEHFrame_t, SEH_Header) \ - ->SEH_Locals \ - ); + _SEH_LOCALS_TYPENAME(LOCALS_) * _SEHPLocals; \ + _SEHPLocals = \ + _SEH_PVOID_CAST \ + ( \ + _SEH_LOCALS_TYPENAME(LOCALS_) *, \ + _SEH_CONTAINING_RECORD(_SEHPortableFrame, _SEHFrame_t, SEH_Header) \ + ->SEH_Locals \ + );
/* Access local variable VAR_ */ #define _SEH_VAR(VAR_) _SEHPLocals->VAR_ @@ -91,292 +91,265 @@ /* FILTER FUNCTIONS */ /* Declares a filter function's prototype */ #define _SEH_FILTER(NAME_) \ - long __stdcall NAME_ \ - ( \ - struct _EXCEPTION_POINTERS * _SEHExceptionPointers, \ - struct __SEHPortableFrame * _SEHPortableFrame \ - ) + long __stdcall NAME_ \ + ( \ + struct _EXCEPTION_POINTERS * _SEHExceptionPointers, \ + struct __SEHPortableFrame * _SEHPortableFrame \ + )
/* Declares a static filter */ #define _SEH_STATIC_FILTER(ACTION_) ((_SEHFilter_t)((ACTION_) + 2))
/* Declares a PSEH filter wrapping a regular filter function */ #define _SEH_WRAP_FILTER(WRAPPER_, NAME_) \ - static __inline _SEH_FILTER(WRAPPER_) \ - { \ - return (NAME_)(_SEHExceptionPointers); \ - } + static __inline _SEH_FILTER(WRAPPER_) \ + { \ + return (NAME_)(_SEHExceptionPointers); \ + }
/* FINALLY FUNCTIONS */ /* Declares a finally function's prototype */ #define _SEH_FINALLYFUNC(NAME_) \ - void __stdcall NAME_ \ - ( \ - struct __SEHPortableFrame * _SEHPortableFrame \ - ) + void __stdcall NAME_ \ + ( \ + struct __SEHPortableFrame * _SEHPortableFrame \ + )
/* Declares a PSEH finally function wrapping a regular function */ #define _SEH_WRAP_FINALLY(WRAPPER_, NAME_) \ - _SEH_WRAP_FINALLY_ARGS(WRAPPER_, NAME_, ()) + _SEH_WRAP_FINALLY_ARGS(WRAPPER_, NAME_, ())
#define _SEH_WRAP_FINALLY_ARGS(WRAPPER_, NAME_, ARGS_) \ - static __inline _SEH_FINALLYFUNC(WRAPPER_) \ - { \ - NAME_ ARGS_; \ - } + static __inline _SEH_FINALLYFUNC(WRAPPER_) \ + { \ + NAME_ ARGS_; \ + }
#define _SEH_WRAP_FINALLY_LOCALS_ARGS(WRAPPER_, LOCALS_, NAME_, ARGS_) \ - static __inline _SEH_FINALLYFUNC(WRAPPER_) \ - { \ - _SEH_ACCESS_LOCALS(LOCALS_); \ - NAME_ ARGS_; \ - } + static __inline _SEH_FINALLYFUNC(WRAPPER_) \ + { \ + _SEH_ACCESS_LOCALS(LOCALS_); \ + NAME_ ARGS_; \ + }
/* SAFE BLOCKS */ #define _SEHX_TRY_FINALLY(FINALLY_) \ - _SEH_TRY_FILTER_FINALLY \ - ( \ - _SEH_STATIC_FILTER(_SEH_CONTINUE_SEARCH), \ - (FINALLY_) \ - ) + _SEH_TRY_FILTER_FINALLY \ + ( \ + _SEH_STATIC_FILTER(_SEH_CONTINUE_SEARCH), \ + (FINALLY_) \ + )
#define _SEHX_END_FINALLY _SEH_HANDLE _SEH_END
#define _SEHX_TRY_FILTER(FILTER_) \ - _SEH_TRY_FILTER_FINALLY((FILTER_), 0) + _SEH_TRY_FILTER_FINALLY((FILTER_), 0)
#define _SEHX_TRY_HANDLE_FINALLY(FINALLY_) \ - _SEH_TRY_FILTER_FINALLY \ - ( \ - _SEH_STATIC_FILTER(_SEH_EXECUTE_HANDLER), \ - (FINALLY_) \ - ) + _SEH_TRY_FILTER_FINALLY \ + ( \ + _SEH_STATIC_FILTER(_SEH_EXECUTE_HANDLER), \ + (FINALLY_) \ + )
#define _SEHX_TRY \ - _SEH_TRY_HANDLE_FINALLY(0) + _SEH_TRY_HANDLE_FINALLY(0)
#ifdef __cplusplus -# define _SEH_DECLARE_HANDLERS(FILTER_, FINALLY_) \ - static const _SEHHandlers_t _SEHHandlers = { (FILTER_), (FINALLY_) }; +# define _SEH_DECLARE_HANDLERS(FILTER_, FINALLY_) \ + static const _SEHHandlers_t _SEHHandlers = { (FILTER_), (FINALLY_) }; #else -# define _SEH_DECLARE_HANDLERS(FILTER_, FINALLY_) \ - _SEHHandlers_t _SEHHandlers = { (0), (0) }; \ - _SEHHandlers.SH_Filter = (FILTER_); \ - _SEHHandlers.SH_Finally = (FINALLY_); +# define _SEH_DECLARE_HANDLERS(FILTER_, FINALLY_) \ + _SEHHandlers_t _SEHHandlers = { (0), (0) }; \ + _SEHHandlers.SH_Filter = (FILTER_); \ + _SEHHandlers.SH_Finally = (FINALLY_); #endif
#define _SEHX_TRY_FILTER_FINALLY(FILTER_, FINALLY_) \ - { \ - _SEHPortableFrame_t * const _SEHCurPortableFrame = _SEHPortableFrame; \ - \ - { \ - _SEHFrame_t _SEHFrame; \ - _SEHTryLevel_t _SEHTryLevel; \ - _SEHPortableFrame_t * const _SEHPortableFrame = \ - _SEHScopeKind ? &_SEHFrame.SEH_Header : _SEHCurPortableFrame; \ - \ - (void)_SEHPortableFrame; \ - \ - _SEH_DECLARE_HANDLERS((FILTER_), (FINALLY_)); \ - \ - _SEHTryLevel.ST_Header.SPT_Handlers = &_SEHHandlers; \ - \ - if(_SEHScopeKind) \ - { \ - if(&_SEHLocals != _SEHDummyLocals) \ - _SEHFrame.SEH_Locals = &_SEHLocals; \ - \ - _SEHFrame.SEH_Header.SPF_Handler = _SEHCompilerSpecificHandler; \ - _SEHEnterFrame(&_SEHFrame.SEH_Header, &_SEHTryLevel.ST_Header); \ - } \ - else \ - _SEHEnterTry(&_SEHTryLevel.ST_Header); \ - \ - { \ - static const int _SEHScopeKind = 0; \ - (void)_SEHScopeKind; \ - \ - if(_SEHSetJmp(_SEHTryLevel.ST_JmpBuf) == 0) \ - { \ - for(;;) \ - { + { \ + _SEHPortableFrame_t * const _SEHCurPortableFrame = _SEHPortableFrame; \ + \ + { \ + _SEHFrame_t _SEHFrame; \ + _SEHTryLevel_t _SEHTryLevel; \ + _SEHPortableFrame_t * const _SEHPortableFrame = \ + _SEHScopeKind ? &_SEHFrame.SEH_Header : _SEHCurPortableFrame; \ + \ + (void)_SEHPortableFrame; \ + \ + _SEH_DECLARE_HANDLERS((FILTER_), (FINALLY_)); \ + \ + _SEHTryLevel.ST_Header.SPT_Handlers = &_SEHHandlers; \ + \ + if(_SEHScopeKind) \ + { \ + if(&_SEHLocals != _SEHDummyLocals) \ + _SEHFrame.SEH_Locals = &_SEHLocals; \ + \ + _SEHFrame.SEH_Header.SPF_Handler = _SEHCompilerSpecificHandler; \ + _SEHEnterFrame(&_SEHFrame.SEH_Header, &_SEHTryLevel.ST_Header); \ + } \ + else \ + _SEHEnterTry(&_SEHTryLevel.ST_Header); \ + \ + { \ + static const int _SEHScopeKind = 0; \ + (void)_SEHScopeKind; \ + \ + if(_SEHSetJmp(_SEHTryLevel.ST_JmpBuf) == 0) \ + { \ + for(;;) \ + {
#define _SEHX_HANDLE \ - \ - break; \ - } \ - \ - _SEHLeave(); \ - } \ - else \ - { \ - _SEHLeave(); + \ + break; \ + } \ + \ + _SEHLeave(); \ + } \ + else \ + { \ + _SEHLeave();
#define _SEHX_END \ - } \ - \ - if(_SEHHandlers.SH_Finally) \ - _SEHHandlers.SH_Finally(_SEHPortableFrame); \ - } \ - } \ - } + } \ + \ + if(_SEHHandlers.SH_Finally) \ + _SEHHandlers.SH_Finally(_SEHPortableFrame); \ + } \ + } \ + }
#define _SEHX_LEAVE break
#define _SEHX_GetExceptionCode() (unsigned long)(_SEHPortableFrame->SPF_Code)
#define _SEHX_GetExceptionPointers() \ - ((struct _EXCEPTION_POINTERS *)_SEHExceptionPointers) + ((struct _EXCEPTION_POINTERS *)_SEHExceptionPointers)
#define _SEHX_AbnormalTermination() (_SEHPortableFrame->SPF_Code != 0)
/* New syntax */
-/* - NOTE: do not move, remove or modify any instance of _SEH2_ASSUME and - _SEH2_ASSUMING without doing extensive tests for correctness. Compilers can - generate the wrong code in presence of __assume in unpredictable ways. BE SURE - IT DOESN'T HAPPEN -*/ -#if defined(_MSC_VER) && (_MSC_VER > 1200) -# define _SEH2_ASSUME(X_) __assume(X_) -# if !defined(_SEH_NO_NATIVE_NLG) - /* - If we use the native setjmp, the compiler stops keeping track of variables, so - their actual values don't matter anymore. Optimize out some assignments - */ -# define _SEH2_ASSUMING(X_) -# else - /* No native setjmp, no magic, no assumptions. Actually set the values */ -# define _SEH2_ASSUMING(X_) X_ -# endif +#ifdef __cplusplus +# define _SEH2_INIT_CONST static const #else -# define _SEH2_ASSUME(X_) -# define _SEH2_ASSUMING(X_) X_ -#endif - -#ifdef __cplusplus -# define _SEH2_INIT_CONST static const -#else -# define _SEH2_INIT_CONST register const +# define _SEH2_INIT_CONST register const #endif
#define _SEH_LEAVE break
#define _SEH_TRY \ - { \ - _SEH2_INIT_CONST int _SEH2TopTryLevel = (_SEHScopeKind != 0); \ - _SEHPortableFrame_t * const _SEH2CurPortableFrame = _SEHPortableFrame; \ - \ - { \ - static const int _SEHScopeKind = 0; \ - register int _SEH2State = 0; \ - register int _SEH2Handle = 0; \ - _SEHFrame_t _SEH2Frame; \ - _SEHTryLevel_t _SEH2TryLevel; \ - _SEHPortableFrame_t * const _SEHPortableFrame = \ - _SEH2TopTryLevel ? &_SEH2Frame.SEH_Header : _SEH2CurPortableFrame; \ - \ - (void)_SEHScopeKind; \ - (void)_SEHPortableFrame; \ - (void)_SEH2Handle; \ - \ - for(;;) \ - { \ - if(_SEH2State) \ - { \ - for(;;) \ - { \ - { + { \ + _SEH2_INIT_CONST int _SEH2TopTryLevel = (_SEHScopeKind != 0); \ + _SEHPortableFrame_t * const _SEH2CurPortableFrame = _SEHPortableFrame; \ + \ + { \ + static const int _SEHScopeKind = 0; \ + register int _SEH2State = 0; \ + register int _SEH2Handle = 0; \ + _SEHFrame_t _SEH2Frame; \ + _SEHTryLevel_t _SEH2TryLevel; \ + _SEHPortableFrame_t * const _SEHPortableFrame = \ + _SEH2TopTryLevel ? &_SEH2Frame.SEH_Header : _SEH2CurPortableFrame; \ + \ + (void)_SEHScopeKind; \ + (void)_SEHPortableFrame; \ + (void)_SEH2Handle; \ + \ + for(;;) \ + { \ + if(_SEH2State) \ + { \ + for(;;) \ + { \ + {
#define _SEH_EXCEPT(FILTER_) \ - } \ - \ - break; \ - } \ - \ - _SEH2_ASSUME(_SEH2Handle == 0); \ - break; \ - } \ - else \ - { \ - _SEH_DECLARE_HANDLERS((FILTER_), 0); \ - \ - _SEH2TryLevel.ST_Header.SPT_Handlers = &_SEHHandlers; \ - \ - if(_SEH2TopTryLevel) \ - { \ - if(&_SEHLocals != _SEHDummyLocals) \ - _SEH2Frame.SEH_Locals = &_SEHLocals; \ - \ - _SEH2Frame.SEH_Header.SPF_Handler = _SEHCompilerSpecificHandler; \ - _SEHEnterFrame(&_SEH2Frame.SEH_Header, &_SEH2TryLevel.ST_Header); \ - } \ - else \ - _SEHEnterTry(&_SEH2TryLevel.ST_Header); \ - \ - if((_SEH2Handle = _SEHSetJmp(_SEH2TryLevel.ST_JmpBuf)) == 0) \ - { \ - _SEH2_ASSUMING(++ _SEH2State); \ - _SEH2_ASSUME(_SEH2State != 0); \ - continue; \ - } \ - else \ - { \ - break; \ - } \ - } \ - \ - break; \ - } \ - \ - _SEHLeave(); \ - \ - if(_SEH2Handle) \ - { + } \ + \ + break; \ + } \ + \ + break; \ + } \ + else \ + { \ + _SEH_DECLARE_HANDLERS((FILTER_), 0); \ + \ + _SEH2TryLevel.ST_Header.SPT_Handlers = &_SEHHandlers; \ + \ + if(_SEH2TopTryLevel) \ + { \ + if(&_SEHLocals != _SEHDummyLocals) \ + _SEH2Frame.SEH_Locals = &_SEHLocals; \ + \ + _SEH2Frame.SEH_Header.SPF_Handler = _SEHCompilerSpecificHandler; \ + _SEHEnterFrame(&_SEH2Frame.SEH_Header, &_SEH2TryLevel.ST_Header); \ + } \ + else \ + _SEHEnterTry(&_SEH2TryLevel.ST_Header); \ + \ + if((_SEH2Handle = _SEHSetJmp(_SEH2TryLevel.ST_JmpBuf)) == 0) \ + { \ + continue; \ + } \ + else \ + { \ + break; \ + } \ + } \ + \ + break; \ + } \ + \ + _SEHLeave(); \ + \ + if(_SEH2Handle) \ + {
#define _SEH_FINALLY(FINALLY_) \ - } \ - \ - break; \ - } \ - \ - _SEHLeave(); \ - break; \ - } \ - else \ - { \ - _SEH_DECLARE_HANDLERS(0, (FINALLY_)); \ - \ - _SEH2TryLevel.ST_Header.SPT_Handlers = &_SEHHandlers; \ - \ - if(_SEH2TopTryLevel) \ - { \ - if(&_SEHLocals != _SEHDummyLocals) \ - _SEH2Frame.SEH_Locals = &_SEHLocals; \ - \ - _SEH2Frame.SEH_Header.SPF_Handler = 0; \ - _SEHEnterFrame(&_SEH2Frame.SEH_Header, &_SEH2TryLevel.ST_Header); \ - } \ - else \ - _SEHEnterTry(&_SEH2TryLevel.ST_Header); \ - \ - ++ _SEH2State; \ - _SEH2_ASSUME(_SEH2State != 0); \ - continue; \ - } \ - \ - break; \ - } \ - \ - (FINALLY_)(&_SEH2Frame.SEH_Header); \ - if(0) \ - { + } \ + \ + break; \ + } \ + \ + _SEHLeave(); \ + break; \ + } \ + else \ + { \ + _SEH_DECLARE_HANDLERS(0, (FINALLY_)); \ + \ + _SEH2TryLevel.ST_Header.SPT_Handlers = &_SEHHandlers; \ + \ + if(_SEH2TopTryLevel) \ + { \ + if(&_SEHLocals != _SEHDummyLocals) \ + _SEH2Frame.SEH_Locals = &_SEHLocals; \ + \ + _SEH2Frame.SEH_Header.SPF_Handler = 0; \ + _SEHEnterFrame(&_SEH2Frame.SEH_Header, &_SEH2TryLevel.ST_Header); \ + } \ + else \ + _SEHEnterTry(&_SEH2TryLevel.ST_Header); \ + \ + ++ _SEH2State; \ + continue; \ + } \ + \ + break; \ + } \ + \ + (FINALLY_)(&_SEH2Frame.SEH_Header); \ + if(0) \ + {
#define _SEH_END \ - } \ - } \ - } + } \ + } \ + }
#define _SEH_HANDLE _SEH_EXCEPT(_SEH_STATIC_FILTER(_SEH_EXECUTE_HANDLER))
Modified: trunk/reactos/include/reactos/libs/pseh/framebased/internal.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/pseh/f... ============================================================================== --- trunk/reactos/include/reactos/libs/pseh/framebased/internal.h (original) +++ trunk/reactos/include/reactos/libs/pseh/framebased/internal.h Mon Feb 26 18:32:19 2007 @@ -1,23 +1,23 @@ /* - Copyright (c) 2004/2005 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. + Copyright (c) 2004/2005 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_FRAMEBASED_INTERNAL_H_ @@ -26,19 +26,19 @@ struct _EXCEPTION_RECORD; struct _EXCEPTION_POINTERS; struct _CONTEXT; - + typedef int (__cdecl * _SEHFrameHandler_t) ( - struct _EXCEPTION_RECORD *, - void *, - struct _CONTEXT *, - void * + struct _EXCEPTION_RECORD *, + void *, + struct _CONTEXT *, + void * );
typedef struct __SEHRegistration { - struct __SEHRegistration * SER_Prev; - _SEHFrameHandler_t SER_Handler; + struct __SEHRegistration * SER_Prev; + _SEHFrameHandler_t SER_Handler; } _SEHRegistration_t;
@@ -47,40 +47,40 @@
typedef long (__stdcall * _SEHFilter_t) ( - struct _EXCEPTION_POINTERS *, - struct __SEHPortableFrame * + struct _EXCEPTION_POINTERS *, + struct __SEHPortableFrame * );
typedef void (__stdcall * _SEHHandler_t) ( - struct __SEHPortableTryLevel * + struct __SEHPortableTryLevel * );
typedef void (__stdcall * _SEHFinally_t) ( - struct __SEHPortableFrame * + struct __SEHPortableFrame * );
typedef struct __SEHHandlers { - _SEHFilter_t SH_Filter; - _SEHFinally_t SH_Finally; + _SEHFilter_t SH_Filter; + _SEHFinally_t SH_Finally; } _SEHHandlers_t;
typedef struct __SEHPortableTryLevel { - struct __SEHPortableTryLevel * SPT_Next; - const _SEHHandlers_t * SPT_Handlers; + struct __SEHPortableTryLevel * SPT_Next; + const _SEHHandlers_t * SPT_Handlers; } _SEHPortableTryLevel_t;
typedef struct __SEHPortableFrame { - _SEHRegistration_t SPF_Registration; - unsigned long SPF_Code; - _SEHHandler_t SPF_Handler; - _SEHPortableTryLevel_t * SPF_TopTryLevel; + _SEHRegistration_t SPF_Registration; + unsigned long SPF_Code; + _SEHHandler_t SPF_Handler; + _SEHPortableTryLevel_t * SPF_TopTryLevel; } _SEHPortableFrame_t;
@@ -91,8 +91,8 @@
extern void __stdcall _SEHEnterFrame_s ( - _SEHPortableFrame_t *, - _SEHPortableTryLevel_t * + _SEHPortableFrame_t *, + _SEHPortableTryLevel_t * );
extern void __stdcall _SEHEnterTry_s(_SEHPortableTryLevel_t *); @@ -107,8 +107,8 @@
extern void _SEH_FASTCALL _SEHEnterFrame_f ( - _SEHPortableFrame_t *, - _SEHPortableTryLevel_t * + _SEHPortableFrame_t *, + _SEHPortableTryLevel_t * );
extern void _SEH_FASTCALL _SEHEnterTry_f(_SEHPortableTryLevel_t *);
Removed: trunk/reactos/include/reactos/libs/pseh/native.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/pseh/n... ============================================================================== --- trunk/reactos/include/reactos/libs/pseh/native.h (original) +++ trunk/reactos/include/reactos/libs/pseh/native.h (removed) @@ -1,242 +1,0 @@ -/* - Copyright (c) 2004/2005 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_NATIVE_H_ -#define KJK_PSEH_NATIVE_H_ - -#include <excpt.h> -#include <pseh/excpt.h> - -/* - Note: just define __inline to an empty symbol if your C compiler doesn't - support it -*/ -#ifdef __cplusplus -# ifndef __inline -# define __inline inline -# endif -#endif - -typedef long (__stdcall * _SEHFilter_t) -( - long, - struct _EXCEPTION_POINTERS *, - void * -); - -typedef void (__stdcall * _SEHFinally_t) -( - int, - void * -); - -static __inline long _SEHCallFilter -( - _SEHFilter_t _SEHFilter, - long _SEHExceptionCode, - struct _EXCEPTION_POINTERS * _SEHExceptionPointers, - void * _SEHPVLocals -) -{ - if(_SEHFilter == _SEH_STATIC_FILTER(_SEH_EXECUTE_HANDLER)) - return _SEH_EXECUTE_HANDLER; - else if(_SEHFilter == _SEH_STATIC_FILTER(_SEH_CONTINUE_SEARCH)) - return _SEH_CONTINUE_SEARCH; - else if(_SEHFilter == _SEH_STATIC_FILTER(_SEH_CONTINUE_EXECUTION)) - return _SEH_CONTINUE_EXECUTION; - else if(_SEHFilter) - return _SEHFilter(_SEHExceptionCode, _SEHExceptionPointers, _SEHPVLocals); - else - return _SEH_CONTINUE_SEARCH; -} - -static __inline void _SEHCallFinally -( - _SEHFinally_t _SEHFinally, - int _SEHAbnormalTermination, - void * _SEHPVLocals -) -{ - if(_SEHFinally) - (_SEHFinally)(_SEHAbnormalTermination, _SEHPVLocals); -} - -/* SHARED LOCALS */ -/* Access the locals for the current frame */ -#define _SEH_ACCESS_LOCALS(LOCALS_) \ - _SEH_LOCALS_TYPENAME(LOCALS_) * _SEHPLocals; \ - _SEHPLocals = _SEH_PVOID_CAST(_SEH_LOCALS_TYPENAME(LOCALS_) *, _SEHPVLocals); - -/* Access local variable VAR_ */ -#define _SEH_VAR(VAR_) _SEHPLocals->VAR_ - -/* FILTER FUNCTIONS */ -/* Declares a filter function's prototype */ -#define _SEH_FILTER(NAME_) \ - long __stdcall NAME_ \ - ( \ - long _SEHExceptionCode, \ - struct _EXCEPTION_POINTERS * _SEHExceptionPointers, \ - void * _SEHPVLocals \ - ) - -/* Declares a static filter */ -#define _SEH_STATIC_FILTER(ACTION_) ((_SEHFilter_t)((ACTION_) + 2)) - -/* Declares a PSEH filter wrapping a regular filter function */ -#define _SEH_WRAP_FILTER(WRAPPER_, NAME_) \ - static __inline _SEH_FILTER(WRAPPER_) \ - { \ - return (NAME_)(_SEHExceptionPointers); \ - } - -/* FINALLY FUNCTIONS */ -/* Declares a finally function's prototype */ -#define _SEH_FINALLYFUNC(NAME_) \ - void __stdcall NAME_ \ - ( \ - int _SEHAbnormalTermination, \ - void * _SEHPVLocals \ - ) - -/* Declares a PSEH finally function wrapping a regular function */ -#define _SEH_WRAP_FINALLY(WRAPPER_, NAME_) \ - _SEH_WRAP_FINALLY_ARGS(WRAPPER_, NAME_, ()) - -#define _SEH_WRAP_FINALLY_ARGS(WRAPPER_, NAME_, ARGS_) \ - static __inline _SEH_FINALLYFUNC(WRAPPER_) \ - { \ - NAME_ ARGS_; \ - } - -#define _SEH_WRAP_FINALLY_LOCALS_ARGS(WRAPPER_, LOCALS_, NAME_, ARGS_) \ - static __inline _SEH_FINALLYFUNC(WRAPPER_) \ - { \ - _SEH_ACCESS_LOCALS(LOCALS_); \ - NAME_ ARGS_; \ - } - -/* SAFE BLOCKS */ -#define _SEH_TRY_FINALLY(FINALLY_) \ - _SEH_TRY_FILTER_FINALLY \ - ( \ - _SEH_STATIC_FILTER(_SEH_CONTINUE_SEARCH), \ - (FINALLY_) \ - ) - -#define _SEH_END_FINALLY _SEH_HANDLE _SEH_END - -#define _SEH_TRY_FILTER(FILTER_) \ - _SEH_TRY_FILTER_FINALLY((FILTER_), NULL) - -#define _SEH_TRY_HANDLE_FINALLY(FINALLY_) \ - _SEH_TRY_FILTER_FINALLY \ - ( \ - _SEH_STATIC_FILTER(_SEH_EXECUTE_HANDLER), \ - (FINALLY_) \ - ) - -#define _SEH_TRY \ - _SEH_TRY_HANDLE_FINALLY(NULL) - -#define _SEH_CALL_FILTER(FILTER_) \ - _SEHCallFilter \ - ( \ - (FILTER_), \ - GetExceptionCode(), \ - GetExceptionPointers(), \ - _SEHPVLocals \ - ) - -#define _SEH_CALL_FINALLY(FINALLY_) \ - _SEHCallFinally((FINALLY_), (AbnormalTermination() != 0), _SEHPVLocals) - -#define _SEH_TRY_FILTER_FINALLY(FILTER_, FINALLY_) \ - __try \ - { \ - _SEHFinally_t _SEHFinally = (FINALLY_); \ - _SEHFilter_t _SEHFilter = (FILTER_); \ - void * _SEHPVLocals = &_SEHLocals; \ - (void)_SEHPVLocals; \ - \ - __try \ - { - -#define _SEH_HANDLE \ - } \ - __except(_SEH_CALL_FILTER(_SEHFilter)) \ - { \ - struct _EXCEPTION_POINTERS * _SEHExceptionPointers = GetExceptionPointers();\ - long _SEHExceptionCode = GetExceptionCode(); \ - -#define _SEH_END \ - } \ - } \ - __finally \ - { \ - _SEH_CALL_FINALLY(_SEHFinally); \ - } - -#define _SEH_LEAVE __leave - -#define _SEH_GetExceptionCode() (_SEHExceptionCode) -#define _SEH_GetExceptionPointers() (_SEHExceptionPointers) -#define _SEH_AbnormalTermination() (_SEHAbnormalTermination) - -/* New syntax */ - -#define _SEH2_TRY \ - { \ - void * _SEHPVLocals = &_SEHLocals; \ - (void)_SEHPVLocals; \ - \ - __try \ - { - -#define _SEH2_EXCEPT(FILTER_) \ - } \ - __except(_SEH_CALL_FILTER(FILTER_)) \ - { \ - struct _EXCEPTION_POINTERS * _SEHExceptionPointers = GetExceptionPointers();\ - long _SEHExceptionCode = GetExceptionCode(); \ - -#define _SEH2_FINALLY(FINALLY_) \ - } \ - __finally \ - { \ - _SEH_CALL_FINALLY(FINALLY_) - -#define _SEH2_END \ - } \ - } - -#define _SEH2_HANDLE _SEH2_EXCEPT(_SEH_STATIC_FILTER(_SEH_EXECUTE_HANDLER)) - -#define _SEH2_LEAVE _SEH_LEAVE - -#define _SEH2_GetExceptionCode _SEH_GetExceptionCode -#define _SEH2_GetExceptionPointers _SEH_GetExceptionPointers -#define _SEH2_AbnormalTermination _SEH_AbnormalTermination - -#endif - -/* EOF */
Removed: trunk/reactos/include/reactos/libs/pseh/prettybased.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/pseh/p... ============================================================================== --- trunk/reactos/include/reactos/libs/pseh/prettybased.h (original) +++ trunk/reactos/include/reactos/libs/pseh/prettybased.h (removed) @@ -1,299 +1,0 @@ -/* - 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. -*/ -/* -Pretty PSEH - -Made to be macro compatible with ms seh syntax and to be pretty, having the -finally block inline etc. Being pretty is not cheap. PPSEH has more -overhead than PSEH, thou mostly during exception/unwinding. Normal execution -only add the overhead of one setjmp, and only in the try/finally case. -PPSEH is probably much less portable than PSEH also..... - -ALERT!ALERT!ALERT!ALERT!ALERT!ALERT!ALERT!ALERT!ALERT!ALERT!ALERT!ALERT!ALERT! --must always use non-native NLG cause a special version of longjmp (which doesn't -restore esp) is needed - --compiler must use ebp as stack frame pointer, cause the finally block rely -on this to access external variables - --all external variables that are used in the except/finally block MUST be volatile -to prevent variables from being optimized into registers. -See: http://alphalinux.org/archives/axp-list/1998/February1998/0330.html - --you can't use return within a try/except/finally block - --you can't use __LEAVE within a (for/do/while) loop. it will only leave the loop -and not the try-block itself - - -USAGE: - -__TRY{ - __LEAVE; -} -__EXCEPT(_SEH_STATIC_FILTER(EXCEPTION_EXECUTE_HANDLER)){ -} -__ENDTRY; - - -__TRY{ -} -__FINALLY{ -} -__ENDTRY; - - -_SEH_FILTER(filter){ - return EXCEPTION_EXECUTE_HANDLER; -} -__TRY2{ -} -__EXCEPT2(filter){ -} -__FINALLY2{ -} -__ENDTRY2; - - - --Gunnar - -*/ - - -#ifndef KJK_PPSEH_FRAMEBASED_H_ -#define KJK_PPSEH_FRAMEBASED_H_ - -#include <pseh/framebased/internal.h> -#include <pseh/excpt.h> -#include <malloc.h> - -#ifndef offsetof -# include <stddef.h> -#endif - -/* -Must always use non-native NLG since we need a special version of longjmp which does -not restore esp -*/ -#include <pseh/setjmp.h> - - -typedef struct __SEHFrame -{ - _SEHPortableFrame_t SEH_Header; - _SEHJmpBuf_t SEH_JmpBuf; - _SEHJmpBuf_t* SEH_JmpRetPtr; -} -_SEHFrame_t; - -/* - Note: just define __inline to an empty symbol if your C compiler doesn't - support it -*/ -#ifdef __cplusplus -# ifndef __inline -# define __inline inline -# endif -#endif - - -/* FILTER FUNCTIONS */ -/* Declares a filter function's prototype */ -#define _SEH_FILTER(NAME_) \ - long __stdcall NAME_ \ - ( \ - struct _EXCEPTION_POINTERS * _SEHExceptionPointers, \ - struct __SEHPortableFrame * _SEHPortableFrame \ - ) - - -/* Declares a static filter */ -#define _SEH_STATIC_FILTER(ACTION_) ((_SEHFilter_t)((ACTION_) + 2)) - - -static __declspec(noreturn) __inline void __stdcall _SEHCompilerSpecificHandler -( - _SEHPortableFrame_t * frame -) -{ - _SEHFrame_t * myframe; - myframe = (_SEHFrame_t *)(((char *)frame) - offsetof(_SEHFrame_t, SEH_Header)); - _SEHLongJmp(myframe->SEH_JmpBuf, 1); -} - - - -void __stdcall _FinallyPretty -( - struct __SEHPortableFrame * frame -) -{ - _SEHFrame_t * myframe; - _SEHJmpBuf_t jmpRetBuf; - - myframe = (_SEHFrame_t *)(((char *)frame) - offsetof(_SEHFrame_t, SEH_Header)); - - if(_SEHSetJmp(jmpRetBuf) == 0) - { - myframe->SEH_JmpRetPtr = &jmpRetBuf; - _SEHLongJmp_KeepEsp(myframe->SEH_JmpBuf, 2); - } -} - - - -#define ___EXCEPT_DUAL(filter) \ - } while(0); \ - \ - _SEHLeave(&_SEHFrame->SEH_Header); \ - } \ - else \ - { \ - _SEHHandlers.SH_Filter = (filter); \ - _SEHHandlers.SH_Finally = _FinallyPretty; \ - \ - if(_loop == 2 || (_ret = _SEHSetJmp(_SEHFrame->SEH_JmpBuf))) \ - { \ - if (_ret == 1) \ - { \ - _SEHLeave(&_SEHFrame->SEH_Header); \ - do \ - { - - - -#define ___FINALLY_DUAL \ - } while (0); \ - } \ - \ - do \ - { - - - -#define ___EXCEPT_SINGLE(filter) \ - } while(0); \ - \ - _SEHLeave(&_SEHFrame->SEH_Header); \ - break; \ - } \ - else \ - { \ - _SEHHandlers.SH_Filter = (filter); \ - _SEHHandlers.SH_Finally = (NULL); \ - \ - if(_SEHSetJmp(_SEHFrame->SEH_JmpBuf)) \ - { \ - _SEHLeave(&_SEHFrame->SEH_Header); \ - do \ - { - - - -#define ___TRY \ - do \ - { \ - int _loop =0; int _ret = 0; \ - static _SEHHandlers_t _SEHHandlers = \ - { \ - (NULL), \ - _SEHCompilerSpecificHandler, \ - (NULL) \ - }; \ - \ - _SEHFrame_t * _SEHFrame; \ - volatile _SEHPortableFrame_t * _SEHPortableFrame; \ - \ - _SEHFrame = _alloca(sizeof(_SEHFrame_t)); \ - _SEHFrame->SEH_Header.SPF_Handlers = &_SEHHandlers; \ - \ - _SEHPortableFrame = &_SEHFrame->SEH_Header; \ - (void)_SEHPortableFrame; \ - \ - for(;;_loop++) \ - if (_loop == 1) \ - { \ - _SEHEnter(&_SEHFrame->SEH_Header); \ - \ - do \ - { - - -#define ___FINALLY_SINGLE \ - } while(0); \ - \ - _SEHLeave(&_SEHFrame->SEH_Header); \ - } \ - else \ - { \ - _SEHHandlers.SH_Filter = _SEH_STATIC_FILTER(_SEH_CONTINUE_SEARCH); \ - _SEHHandlers.SH_Finally = _FinallyPretty; \ - \ - if(_loop == 2 || (_ret = _SEHSetJmp(_SEHFrame->SEH_JmpBuf))) \ - { \ - do \ - { - - - -#define ___ENDTRY \ - } while (0); \ - \ - if (_ret == 2) \ - { \ - _SEHLongJmp(*_SEHFrame->SEH_JmpRetPtr, 1); \ - } \ - break; \ - } \ - } \ - } while (0); - - - -#ifdef _MSC_VER - #define __TRY2 __try{__try - #define __EXCEPT2 __except - #define __FINALLY2 }__finally - #define __ENDTRY2 - #define __TRY __try - #define __EXCEPT __except - #define __FINALLY __finally - #define __ENDTRY - #define _SEH_STATIC_FILTER(ACTION_) (ACTION_) - #define __LEAVE __leave - #define __LEAVE2 __leave -#else - #define __TRY2 ___TRY - #define __EXCEPT2 ___EXCEPT_DUAL - #define __FINALLY2 ___FINALLY_DUAL - #define __ENDTRY2 __ENDTRY - #define __TRY ___TRY - #define __EXCEPT ___EXCEPT_SINGLE - #define __FINALLY ___FINALLY_SINGLE - #define __ENDTRY ___ENDTRY - #define __LEAVE break - #define __LEAVE2 break -#endif - - -#endif
Modified: trunk/reactos/include/reactos/libs/pseh/pseh.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/pseh/p... ============================================================================== --- trunk/reactos/include/reactos/libs/pseh/pseh.h (original) +++ trunk/reactos/include/reactos/libs/pseh/pseh.h Mon Feb 26 18:32:19 2007 @@ -1,23 +1,23 @@ /* - Copyright (c) 2004/2005 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. + Copyright (c) 2004/2005 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_H_ @@ -25,53 +25,53 @@
/* Some useful macros */ #if defined(__cplusplus) -# define _SEH_PVOID_CAST(TYPE_, P_) ((TYPE_)(P_)) +# define _SEH_PVOID_CAST(TYPE_, P_) ((TYPE_)(P_)) #else -# define _SEH_PVOID_CAST(TYPE_, P_) (P_) +# define _SEH_PVOID_CAST(TYPE_, P_) (P_) #endif
#if defined(FIELD_OFFSET) -# define _SEH_FIELD_OFFSET FIELD_OFFSET +# define _SEH_FIELD_OFFSET FIELD_OFFSET #else -# include <stddef.h> -# define _SEH_FIELD_OFFSET offsetof +# include <stddef.h> +# define _SEH_FIELD_OFFSET offsetof #endif
#if defined(CONTAINING_RECORD) -# define _SEH_CONTAINING_RECORD CONTAINING_RECORD +# define _SEH_CONTAINING_RECORD CONTAINING_RECORD #else -# define _SEH_CONTAINING_RECORD(ADDR_, TYPE_, FIELD_) \ - ((TYPE_ *)(((char *)(ADDR_)) - _SEH_FIELD_OFFSET(TYPE_, FIELD_))) +# define _SEH_CONTAINING_RECORD(ADDR_, TYPE_, FIELD_) \ + ((TYPE_ *)(((char *)(ADDR_)) - _SEH_FIELD_OFFSET(TYPE_, FIELD_))) #endif
#if defined(__CONCAT) -# define _SEH_CONCAT __CONCAT +# define _SEH_CONCAT __CONCAT #else -# define _SEH_CONCAT1(X_, Y_) X_ ## Y_ -# define _SEH_CONCAT(X_, Y_) _SEH_CONCAT1(X_, Y_) +# define _SEH_CONCAT1(X_, Y_) X_ ## Y_ +# define _SEH_CONCAT(X_, Y_) _SEH_CONCAT1(X_, Y_) #endif
/* - Note: just define __inline to an empty symbol if your C compiler doesn't - support it + Note: just define __inline to an empty symbol if your C compiler doesn't + support it */ #ifdef __cplusplus -# ifndef __inline -# define __inline inline -# endif +# ifndef __inline +# define __inline inline +# endif #endif
/* Locals sharing support */ #define _SEH_LOCALS_TYPENAME(BASENAME_) \ - struct _SEH_CONCAT(_SEHLocalsTag, BASENAME_) + struct _SEH_CONCAT(_SEHLocalsTag, BASENAME_)
#define _SEH_DEFINE_LOCALS(BASENAME_) \ - _SEH_LOCALS_TYPENAME(BASENAME_) + _SEH_LOCALS_TYPENAME(BASENAME_)
#define _SEH_DECLARE_LOCALS(BASENAME_) \ - _SEH_LOCALS_TYPENAME(BASENAME_) _SEHLocals; \ - _SEH_LOCALS_TYPENAME(BASENAME_) * _SEHPLocals; \ - _SEHPLocals = &_SEHLocals; + _SEH_LOCALS_TYPENAME(BASENAME_) _SEHLocals; \ + _SEH_LOCALS_TYPENAME(BASENAME_) * _SEHPLocals; \ + _SEHPLocals = &_SEHLocals;
/* Dummy locals */ static int _SEHLocals;
Modified: trunk/reactos/include/reactos/libs/pseh/setjmp.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/libs/pseh/s... ============================================================================== --- trunk/reactos/include/reactos/libs/pseh/setjmp.h (original) +++ trunk/reactos/include/reactos/libs/pseh/setjmp.h Mon Feb 26 18:32:19 2007 @@ -1,23 +1,23 @@ /* - Copyright (c) 2004/2005 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. + Copyright (c) 2004/2005 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_ @@ -26,12 +26,12 @@ #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; + 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
Modified: trunk/reactos/lib/pseh/framebased.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/pseh/framebased.c?rev=2... ============================================================================== --- trunk/reactos/lib/pseh/framebased.c (original) +++ trunk/reactos/lib/pseh/framebased.c Mon Feb 26 18:32:19 2007 @@ -1,23 +1,23 @@ /* - 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. + Copyright (c) 2004/2005 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. */
#define STRICT
Modified: trunk/reactos/lib/pseh/i386/framebased.asm URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/pseh/i386/framebased.as... ============================================================================== --- trunk/reactos/lib/pseh/i386/framebased.asm (original) +++ trunk/reactos/lib/pseh/i386/framebased.asm Mon Feb 26 18:32:19 2007 @@ -22,51 +22,51 @@
global __SEHCleanHandlerEnvironment __SEHCleanHandlerEnvironment: - cld - ret + cld + ret
global __SEHCurrentRegistration __SEHCurrentRegistration: - mov eax, [fs:0] - ret + mov eax, [fs:0] + ret
global __SEHRegisterFrame __SEHRegisterFrame: - mov ecx, [esp+4] - mov eax, [fs:0] - mov [ecx+0], eax - mov [fs:0], ecx - ret + mov ecx, [esp+4] + mov eax, [fs:0] + mov [ecx+0], eax + mov [fs:0], ecx + ret
global __SEHUnregisterFrame __SEHUnregisterFrame: - mov ecx, [fs:0] - mov ecx, [ecx+0] - mov [fs:0], ecx - ret + mov ecx, [fs:0] + mov ecx, [ecx+0] + mov [fs:0], ecx + ret
global __SEHGlobalUnwind __SEHGlobalUnwind:
- extern __SEHRtlUnwind + extern __SEHRtlUnwind
; RtlUnwind clobbers all the "don't clobber" registers, so we save them - push ebx - mov ebx, [esp+8] - push esi - push edi + push ebx + mov ebx, [esp+8] + push esi + push edi
- push dword 0x0 ; ReturnValue - push dword 0x0 ; ExceptionRecord - push dword .RestoreRegisters ; TargetIp - push ebx ; TargetFrame - call [__SEHRtlUnwind] + push dword 0x0 ; ReturnValue + push dword 0x0 ; ExceptionRecord + push dword .RestoreRegisters ; TargetIp + push ebx ; TargetFrame + call [__SEHRtlUnwind]
.RestoreRegisters: - pop edi - pop esi - pop ebx + pop edi + pop esi + pop ebx
- ret + ret
; EOF
Modified: trunk/reactos/lib/pseh/i386/setjmp.asm URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/pseh/i386/setjmp.asm?re... ============================================================================== --- trunk/reactos/lib/pseh/i386/setjmp.asm (original) +++ trunk/reactos/lib/pseh/i386/setjmp.asm Mon Feb 26 18:32:19 2007 @@ -26,63 +26,63 @@ global __SEHSetJmp@4 _SEHSetJmp: __SEHSetJmp@4: - ; jump buffer - mov eax, [esp+4] + ; jump buffer + mov eax, [esp+4]
- ; program counter - mov ecx, [esp+0] + ; program counter + mov ecx, [esp+0]
- ; stack pointer - lea edx, [esp+8] + ; stack pointer + lea edx, [esp+8]
- ; 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 + ; 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
- xor eax, eax - ret 4 + xor eax, eax + ret 4
global _SEHLongJmp global __SEHLongJmp@8 _SEHLongJmp: __SEHLongJmp@8: - ; return value - mov eax, [esp+8] + ; return value + mov eax, [esp+8]
- ; jump buffer - mov ecx, [esp+4] + ; 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 + ; 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
global _SEHLongJmp_KeepEsp global __SEHLongJmp_KeepEsp@8 _SEHLongJmp_KeepEsp: __SEHLongJmp_KeepEsp@8: - ; return value - mov eax, [esp+8] + ; return value + mov eax, [esp+8]
- ; jump buffer - mov ecx, [esp+4] + ; jump buffer + mov ecx, [esp+4]
- ; restore the saved context - mov ebp, [ecx+0] -; don't restore esp + ; restore the saved context + mov ebp, [ecx+0] +; don't restore esp ; mov esp, [ecx+4] - mov edx, [ecx+8] - mov ebx, [ecx+12] - mov esi, [ecx+16] - mov edi, [ecx+20] - jmp edx + mov edx, [ecx+8] + mov ebx, [ecx+12] + mov esi, [ecx+16] + mov edi, [ecx+20] + jmp edx
; EOF