Index: configure.ac ================================================================== --- configure.ac +++ configure.ac @@ -586,60 +586,32 @@ AS_IF([test x"$enable_seluid24" = x"yes"], [ AC_DEFINE(OF_SELUID24, 1, [Whether to use 24 bit selector UIDs]) ]) AC_MSG_CHECKING(for exception type) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([ - extern void foo(); - ], [ - @try { - foo(); - } @finally { - foo(); - } - ]) - ], [ - AS_IF([$SED 's/[[^[:print:]]]//g' /dev/null], [ - exception_type="DWARF" - ]) - AS_IF([$SED 's/[[^[:print:]]]//g' /dev/null], [ + AC_EGREP_CPP(egrep_cpp_yes, [ + #ifdef __SEH__ + egrep_cpp_yes + #endif + ], [ + AC_MSG_RESULT(SEH) + exception_type="SEH" + raise_exception="_Unwind_RaiseException" + ], [ + AC_EGREP_CPP(egrep_cpp_yes, [ + #ifdef __USING_SJLJ_EXCEPTIONS__ + egrep_cpp_yes + #endif + ], [ + AC_MSG_RESULT(SjLj) exception_type="SjLj" - ]) - AS_IF([$SED 's/[[^[:print:]]]//g' /dev/null], [ - exception_type="SEH" - ]) - - case "$exception_type" in - DWARF) - AC_DEFINE(HAVE_DWARF_EXCEPTIONS, 1, - [Whether DWARF exceptions are used]) - raise_exception="_Unwind_RaiseException" - ;; - SjLj) - AC_DEFINE(HAVE_SJLJ_EXCEPTIONS, 1, - [Whether SjLj exceptions are used]) - raise_exception="_Unwind_SjLj_RaiseException" - ;; - SEH) - AC_DEFINE(HAVE_SEH_EXCEPTIONS, 1, - [Whether SEH exceptions are used]) - raise_exception="_Unwind_RaiseException" - ;; - *) - AC_MSG_RESULT(unknown) - AC_MSG_ERROR([Exception type not detected!]) - ;; - esac - - AC_MSG_RESULT($exception_type) - ], [ - AC_MSG_RESULT(exceptions unavailable!) - AC_MSG_ERROR([Exceptions not accepted by compiler!]) + raise_exception="_Unwind_SjLj_RaiseException" + ], [ + AC_MSG_RESULT(DWARF) + exception_type="DWARF" + raise_exception="_Unwind_RaiseException" + ]) ]) AC_SEARCH_LIBS($raise_exception, [c++abi gcc_s gcc unwind], [ dnl c++abi requires pthread on OpenBSD AS_IF([test x"$ac_lib" = x"c++abi"], [LIBS="$LIBS -lpthread"]) Index: src/runtime/exception.m ================================================================== --- src/runtime/exception.m +++ src/runtime/exception.m @@ -31,26 +31,24 @@ #import "macros.h" #ifdef OF_HAVE_THREADS # import "OFPlainMutex.h" #endif -#ifdef HAVE_SEH_EXCEPTIONS +#ifdef __SEH__ # include #endif -#if defined(HAVE_DWARF_EXCEPTIONS) -# define PERSONALITY __gnu_objc_personality_v0 -# define CXX_PERSONALITY_STR "__gxx_personality_v0" -#elif defined(HAVE_SJLJ_EXCEPTIONS) +#if defined(__SEH__) +# define PERSONALITY gnu_objc_personality +#elif defined(__USING_SJLJ_EXCEPTIONS__) # define PERSONALITY __gnu_objc_personality_sj0 # define CXX_PERSONALITY_STR "__gxx_personality_sj0" # define _Unwind_RaiseException _Unwind_SjLj_RaiseException # define __builtin_eh_return_data_regno(i) (i) -#elif defined(HAVE_SEH_EXCEPTIONS) -# define PERSONALITY gnu_objc_personality #else -# error Unknown exception type! +# define PERSONALITY __gnu_objc_personality_v0 +# define CXX_PERSONALITY_STR "__gxx_personality_v0" #endif #if defined(OF_ARM) && !defined(__ARM_DWARF_EH__) # define HAVE_ARM_EHABI_EXCEPTIONS #endif @@ -128,11 +126,11 @@ struct _Unwind_Exception { uint64_t class; void (*cleanup)( _Unwind_Reason_Code, struct _Unwind_Exception *); #ifndef HAVE_ARM_EHABI_EXCEPTIONS -# ifndef HAVE_SEH_EXCEPTIONS +# ifndef __SEH__ /* * The Itanium Exception ABI says to have those and never touch * them. */ uint64_t private1, private2; @@ -241,11 +239,11 @@ #ifdef CXX_PERSONALITY static PERSONALITY_FUNC(cxx_personality) OF_WEAK_REF(CXX_PERSONALITY_STR); #endif -#ifdef HAVE_SEH_EXCEPTIONS +#ifdef __SEH__ extern EXCEPTION_DISPOSITION _GCC_specific_handler(PEXCEPTION_RECORD, void *, PCONTEXT, PDISPATCHER_CONTEXT, _Unwind_Reason_Code (*)(int, int, uint64_t, struct _Unwind_Exception *, struct _Unwind_Context *)); #endif @@ -444,11 +442,11 @@ const uint8_t *ptr = LSDA->callsites; *landingpad = 0; *actionRecords = NULL; -#ifndef HAVE_SJLJ_EXCEPTIONS +#ifndef __USING_SJLJ_EXCEPTIONS__ while (ptr < LSDA->actionTable) { uintptr_t callsiteStart, callsiteLength, callsiteLandingpad; uintptr_t callsiteAction; callsiteStart = LSDA->regionStart + @@ -578,11 +576,11 @@ } while (displacement != 0); return 0; } -#ifdef HAVE_SEH_EXCEPTIONS +#ifdef __SEH__ static #endif PERSONALITY_FUNC(PERSONALITY) { #ifdef HAVE_ARM_EHABI_EXCEPTIONS @@ -784,11 +782,11 @@ uncaughtExceptionHandler = handler; return old; } -#ifdef HAVE_SEH_EXCEPTIONS +#ifdef __SEH__ typedef EXCEPTION_DISPOSITION (*seh_personality_fn)(PEXCEPTION_RECORD, void *, PCONTEXT, PDISPATCHER_CONTEXT); static seh_personality_fn __gxx_personality_seh0; OF_CONSTRUCTOR()