[cfe-commits] [PATCH] Add missing definitions to unwind.h

Alex Rosenberg alexr at leftfield.org
Thu Dec 20 14:51:27 PST 2012


On Dec 19, 2012, at 7:39 PM, Charles Davis wrote:

> Hi,
> 
> This patch adds a bunch of missing definitions to unwind.h. It's needed at least to compile libc++abi on Mac OS X 10.6.
> 
> OK to commit?
> 
> Chip

This probably needs a rubber stamp from somebody at Apple. Just a reminder to those folks that 10.6 was the last release that supported PPC execution, so some of us still use it. This patch is one of many needed to bootstrap Clang and thus  lld.

> Index: lib/Headers/unwind.h
> ===================================================================
> --- lib/Headers/unwind.h	(revision 170631)
> +++ lib/Headers/unwind.h	(working copy)
> @@ -24,7 +24,7 @@
>  /* See "Data Definitions for libgcc_s" in the Linux Standard Base.*/
>  
>  #if __has_include_next(<unwind.h>)
> -/* Darwin and libunwind provide an unwind.h. If that's available, use
> +/* Darwin (from 11.x on) and libunwind provide an unwind.h. If that's available, use

Over 80 columns, also several spots below.

>   * it. libunwind wraps some of its definitions in #ifdef _GNU_SOURCE,
>   * so define that around the include.*/
>  # ifndef _GNU_SOURCE
> @@ -50,6 +50,9 @@
>  # endif
>  #else
>  
> +#ifndef _UNWIND_H
> +#define _UNWIND_H
> +

Other Clang headers are double underscore like __UNWIND_H. This also appears below.

>  #include <stdint.h>
>  
>  #ifdef __cplusplus
> @@ -61,7 +64,14 @@
>     depend on it */
>  #pragma GCC visibility push(default)
>  
> +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,
> @@ -76,7 +86,42 @@
>    _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;
> +#ifndef __LP64__
> +  uint32_t reserved[3];
> +#endif

This padding probably needs a comment.

> +};
> +
> +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__
>  
>  typedef enum {
> @@ -106,14 +151,81 @@
>    _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__)

Where else has this patch been used?

> +
> +_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*);
>  
>  #pragma GCC visibility pop
>  
> @@ -122,3 +234,5 @@
>  #endif
>  
>  #endif
> +
> +#endif /* _UNWIND_H */
> 

Alex



More information about the cfe-commits mailing list