[PATCH] D33878: Handle NetBSD specific _Unwind_Ptr

Kamil Rytarowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jun 4 08:27:19 PDT 2017


krytarowski created this revision.

NetBSD declares _Unwind_Ptr as void* which is not compatible
without explicit cast with the compiler-rt version uintptr_t.

Sponsored by <The NetBSD Foundation>


Repository:
  rL LLVM

https://reviews.llvm.org/D33878

Files:
  lib/builtins/gcc_personality_v0.c


Index: lib/builtins/gcc_personality_v0.c
===================================================================
--- lib/builtins/gcc_personality_v0.c
+++ lib/builtins/gcc_personality_v0.c
@@ -24,6 +24,12 @@
 #include "unwind-ehabi-helpers.h"
 #endif
 
+#if defined(__NetBSD__)
+#define TYPE_UNWIND_PTR void*
+#else
+#define TYPE_UNWIND_PTR uintptr_t
+#endif
+
 /*
  * Pointer encodings documented at:
  *   http://refspecs.freestandards.org/LSB_1.3.0/gLSB/gLSB/ehframehdr.html
@@ -206,8 +212,8 @@
     if ( lsda == (uint8_t*) 0 )
         return continueUnwind(exceptionObject, context);
 
-    uintptr_t pc = _Unwind_GetIP(context)-1;
-    uintptr_t funcStart = _Unwind_GetRegionStart(context);
+    uintptr_t pc = (uintptr_t)_Unwind_GetIP(context) - 1;
+    uintptr_t funcStart = (uintptr_t)_Unwind_GetRegionStart(context);
     uintptr_t pcOffset = pc - funcStart;
 
     /* Parse LSDA header. */
@@ -239,14 +245,13 @@
              * to take two parameters in registers.
              */
             _Unwind_SetGR(context, __builtin_eh_return_data_regno(0),
-                          (uintptr_t)exceptionObject);
+                          (TYPE_UNWIND_PTR)exceptionObject);
             _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), 0);
-            _Unwind_SetIP(context, (funcStart + landingPad));
+            _Unwind_SetIP(context, (TYPE_UNWIND_PTR)(funcStart + landingPad));
             return _URC_INSTALL_CONTEXT;
         }
     }
 
     /* No landing pad found, continue unwinding. */
     return continueUnwind(exceptionObject, context);
 }
-


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33878.101354.patch
Type: text/x-patch
Size: 1570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170604/131140e7/attachment.bin>


More information about the llvm-commits mailing list