ReXGlue SDK
Loading...
Searching...
No Matches
seh.h File Reference
#include <atomic>
#include <cstdint>
#include <exception>
#include <rex/platform.h>
#include <rex/platform/thread.h>
#include <rex/types.h>
#include <rex/utility.h>
#include <setjmp.h>

Go to the source code of this file.

Classes

struct  rex::platform::SEHScope
struct  rex::platform::SEHThreadState
class  rex::platform::HostCallDepth
class  rex::SEHException

Namespaces

namespace  rex
namespace  rex::platform

Macros

#define REX_SEH_TRY
#define REX_SEH_CATCH   else
#define REX_SEH_CATCH_ALL   else
#define REX_SEH_RETHROW   ::rex::platform::SEHRethrow()
#define REX_SEH_END
#define REX_SEH_RETURN

Functions

REX_PPC_API SEHThreadState & rex::platform::GetSEHThreadState ()
REX_PPC_API int rex::platform::SEHFilter (u32 code, void *exception_pointers)
REX_PPC_API void rex::platform::SEHRethrow ()
REX_PPC_API void rex::platform::SEHInitialize ()
void rex::platform::SEHEnter (SEHScope &scope)
void rex::platform::SEHLeave (SEHScope &scope)
void rex::InitializeSEHThread ()
void rex::InitializeSEH ()

Detailed Description

License
BSD 3-Clause License See LICENSE file in the project root for full license text.
Remarks
Provides cross platform SEH support for recompiled PPC code. On Windows, uses native __try/__except (works with MSVC and Clang-cl). On POSIX, uses signal handlers for SIGSEGV, SIGBUS, SIGFPE and SIGILL.
Usage
  1. Call rex::InitializeSEH() at startup
  2. Generated code wraps SEH scopes with REX_SEH_TRY blocks
  3. Hardware exceptions (null deref, access violation) throw SEHException
  4. Catch blocks call finally handlers and rethrow

Macro Definition Documentation

◆ REX_SEH_CATCH

#define REX_SEH_CATCH   else

Opens the handler of the scope.

◆ REX_SEH_CATCH_ALL

#define REX_SEH_CATCH_ALL   else

Same as REX_SEH_CATCH on POSIX.

◆ REX_SEH_END

#define REX_SEH_END
Value:
::rex::platform::SEHLeave(rex_seh_scope); \
}
void SEHLeave(SEHScope &scope)
Definition seh.h:92

◆ REX_SEH_RETHROW

#define REX_SEH_RETHROW   ::rex::platform::SEHRethrow()

Passes the captured exception to the next open scope from inside a handler.

◆ REX_SEH_RETURN

#define REX_SEH_RETURN
Value:
do { \
::rex::platform::SEHLeave(rex_seh_scope); \
return; \
} while (0)

Returns from the function that holds the SEH scope.

◆ REX_SEH_TRY

#define REX_SEH_TRY
Value:
{ \
::rex::platform::SEHScope rex_seh_scope; \
::rex::platform::SEHEnter(rex_seh_scope); \
if (sigsetjmp(rex_seh_scope.env, 0) == 0)
Definition seh.h:40
sigjmp_buf env
Definition seh.h:41

Opens an SEH scope. Pair with REX_SEH_CATCH or REX_SEH_CATCH_ALL and REX_SEH_END, and leave the body early only through REX_SEH_RETURN.

body();
cleanup();
} REX_SEH_END
#define REX_SEH_CATCH_ALL
Definition seh.h:225
#define REX_SEH_TRY
Definition seh.h:215
#define REX_SEH_RETHROW
Definition seh.h:228