From: Peter Collingbourne Date: Wed, 28 Aug 2013 23:16:49 +0000 (+0000) Subject: Add missing definitions to unwind.h. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7dc8e8175a3a1d4e40819932165e26b01091541e;p=clang Add missing definitions to unwind.h. Original patch by Charles Davis. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189535 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Headers/unwind.h b/lib/Headers/unwind.h index e94fd70900..6212805609 100644 --- a/lib/Headers/unwind.h +++ b/lib/Headers/unwind.h @@ -27,8 +27,8 @@ #define __CLANG_UNWIND_H #if __has_include_next() -/* Darwin and libunwind provide an unwind.h. If that's available, use - * it. libunwind wraps some of its definitions in #ifdef _GNU_SOURCE, +/* Darwin (from 11.x on) and libunwind provide an unwind.h. If that's available, + * use it. libunwind wraps some of its definitions in #ifdef _GNU_SOURCE, * so define that around the include.*/ # ifndef _GNU_SOURCE # define _SHOULD_UNDEFINE_GNU_SOURCE @@ -66,7 +66,14 @@ extern "C" { #pragma GCC visibility push(default) #endif +typedef uintptr_t _Unwind_Word; +typedef intptr_t _Unwind_Sword; +typedef uintptr_t _Unwind_Ptr; +typedef uintptr_t _Unwind_Internal_Ptr; +typedef uint64_t _Unwind_Exception_Class; + struct _Unwind_Context; +struct _Unwind_Exception; typedef enum { _URC_NO_REASON = 0, _URC_FOREIGN_EXCEPTION_CAUGHT = 1, @@ -81,6 +88,41 @@ typedef enum { _URC_CONTINUE_UNWIND = 8 } _Unwind_Reason_Code; +typedef enum { + _UA_SEARCH_PHASE = 1, + _UA_CLEANUP_PHASE = 2, + + _UA_HANDLER_FRAME = 4, + _UA_FORCE_UNWIND = 8, + _UA_END_OF_STACK = 16 /* gcc extension to C++ ABI */ +} _Unwind_Action; + +typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code, + struct _Unwind_Exception *); + +struct _Unwind_Exception { + _Unwind_Exception_Class exception_class; + _Unwind_Exception_Cleanup_Fn exception_cleanup; + _Unwind_Word private_1; + _Unwind_Word private_2; + /* The Itanium ABI requires that _Unwind_Exception objects are "double-word + * aligned". GCC has interpreted this to mean "use the maximum useful + * alignment for the target"; so do we. */ +} __attribute__((__aligned__)); + +typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)(int, _Unwind_Action, + _Unwind_Exception_Class, + struct _Unwind_Exception *, + struct _Unwind_Context *, + void *); + +typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(int, _Unwind_Action, + _Unwind_Exception_Class, + struct _Unwind_Exception *, + struct _Unwind_Context *); +typedef _Unwind_Personality_Fn __personality_routine; + +typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context *, void *); #ifdef __arm__ @@ -111,14 +153,81 @@ _Unwind_VRS_Result _Unwind_VRS_Get(struct _Unwind_Context *__context, _Unwind_VRS_DataRepresentation __representation, void *__valuep); +#endif + +_Unwind_Word _Unwind_GetGR(struct _Unwind_Context *, int); +void _Unwind_SetGR(struct _Unwind_Context *, int, _Unwind_Word); + +_Unwind_Word _Unwind_GetIP(struct _Unwind_Context *); +_Unwind_Word _Unwind_GetIPInfo(struct _Unwind_Context *, int *); +void _Unwind_SetIP(struct _Unwind_Context *, _Unwind_Word); + +_Unwind_Word _Unwind_GetCFA(struct _Unwind_Context *); + +void *_Unwind_GetLanguageSpecificData(struct _Unwind_Context *); + +_Unwind_Ptr _Unwind_GetRegionStart(struct _Unwind_Context *); + +/* DWARF EH functions; currently not available on Darwin/ARM */ +#if !defined(__APPLE__) || !defined(__arm__) + +_Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception *); +_Unwind_Reason_Code _Unwind_ForcedUnwind(struct _Unwind_Exception *, _Unwind_Stop_Fn, + void *); +void _Unwind_DeleteException(struct _Unwind_Exception *); +void _Unwind_Resume(struct _Unwind_Exception *); +_Unwind_Reason_Code _Unwind_Resume_or_Rethrow(struct _Unwind_Exception *); + +#endif + +_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void *); + +/* setjmp(3)/longjmp(3) stuff */ +typedef struct SjLj_Function_Context *_Unwind_FunctionContext_t; + +void _Unwind_SjLj_Register(_Unwind_FunctionContext_t); +void _Unwind_SjLj_Unregister(_Unwind_FunctionContext_t); +_Unwind_Reason_Code _Unwind_SjLj_RaiseException(struct _Unwind_Exception *); +_Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind(struct _Unwind_Exception *, _Unwind_Stop_Fn, + void *); +void _Unwind_SjLj_Resume(struct _Unwind_Exception *); +_Unwind_Reason_Code _Unwind_SjLj_Resume_or_Rethrow(struct _Unwind_Exception *); + +void *_Unwind_FindEnclosingFunction(void *); + +#ifdef __APPLE__ + +_Unwind_Ptr _Unwind_GetDataRelBase(struct _Unwind_Context *) __attribute__((unavailable)); +_Unwind_Ptr _Unwind_GetTextRelBase(struct _Unwind_Context *) __attribute__((unavailable)); + +/* Darwin-specific functions */ +void __register_frame(const void *); +void __deregister_frame(const void *); + +struct dwarf_eh_bases { + uintptr_t tbase; + uintptr_t dbase; + uintptr_t func; +}; +void *_Unwind_Find_FDE(const void *, struct dwarf_eh_bases *); + +void __register_frame_info_bases(const void *, void *, void *, void *) + __attribute__((unavailable)); +void __register_frame_info(const void *, void *) __attribute__((unavailable)); +void __register_frame_info_table_bases(const void *, void*, void *, void *) + __attribute__((unavailable)); +void __register_frame_info_table(const void *, void *) __attribute__((unavailable)); +void __register_frame_table(const void *) __attribute__((unavailable)); +void __deregister_frame_info(const void *) __attribute__((unavailable)); +void __deregister_frame_info_bases(const void *)__attribute__((unavailable)); + #else -uintptr_t _Unwind_GetIP(struct _Unwind_Context* __context); +_Unwind_Ptr _Unwind_GetDataRelBase(struct _Unwind_Context *); +_Unwind_Ptr _Unwind_GetTextRelBase(struct _Unwind_Context *); #endif -typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context*, void*); -_Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void*); #ifndef HIDE_EXPORTS #pragma GCC visibility pop diff --git a/test/Headers/Inputs/include/stdint.h b/test/Headers/Inputs/include/stdint.h index 7a1fddef82..5bf26a7b67 100644 --- a/test/Headers/Inputs/include/stdint.h +++ b/test/Headers/Inputs/include/stdint.h @@ -10,6 +10,7 @@ typedef unsigned __INT64_TYPE__ uint64_t; #endif #ifdef __INTPTR_TYPE__ +typedef __INTPTR_TYPE__ intptr_t; typedef unsigned __INTPTR_TYPE__ uintptr_t; #else #error Every target should have __INTPTR_TYPE__