Rafael Espindola | d85c1e9 | 2011-12-08 05:01:39 +0000 | [diff] [blame] | 1 | /*===---- unwind.h - Stack unwinding ----------------------------------------=== |
| 2 | * |
| 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 | * of this software and associated documentation files (the "Software"), to deal |
| 5 | * in the Software without restriction, including without limitation the rights |
| 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 | * copies of the Software, and to permit persons to whom the Software is |
| 8 | * furnished to do so, subject to the following conditions: |
| 9 | * |
| 10 | * The above copyright notice and this permission notice shall be included in |
| 11 | * all copies or substantial portions of the Software. |
| 12 | * |
| 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 19 | * THE SOFTWARE. |
| 20 | * |
| 21 | *===-----------------------------------------------------------------------=== |
| 22 | */ |
| 23 | |
| 24 | /* See "Data Definitions for libgcc_s" in the Linux Standard Base.*/ |
| 25 | |
Joerg Sonnenberger | f84d560 | 2012-01-03 19:22:38 +0000 | [diff] [blame] | 26 | #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \ |
| 27 | __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1070 |
Rafael Espindola | d85c1e9 | 2011-12-08 05:01:39 +0000 | [diff] [blame] | 28 | /* Starting in OS X Lion the SDK includes a unwind.h. We should just use it. */ |
| 29 | #include_next <unwind.h> |
| 30 | #else |
| 31 | |
| 32 | #include <stdint.h> |
| 33 | |
| 34 | #ifdef __cplusplus |
| 35 | extern "C" { |
| 36 | #endif |
| 37 | |
Rafael Espindola | 9b7568d | 2011-12-09 00:08:01 +0000 | [diff] [blame] | 38 | /* It is a bit strange for a header to play with the visibility of the |
| 39 | symbols it declares, but this matches gcc's behavior and some programs |
| 40 | depend on it */ |
| 41 | #pragma GCC visibility push(default) |
| 42 | |
Rafael Espindola | d85c1e9 | 2011-12-08 05:01:39 +0000 | [diff] [blame] | 43 | struct _Unwind_Context; |
| 44 | typedef enum { |
| 45 | _URC_NO_REASON = 0, |
| 46 | _URC_FOREIGN_EXCEPTION_CAUGHT = 1, |
| 47 | |
| 48 | _URC_FATAL_PHASE2_ERROR = 2, |
| 49 | _URC_FATAL_PHASE1_ERROR = 3, |
| 50 | _URC_NORMAL_STOP = 4, |
| 51 | |
| 52 | _URC_END_OF_STACK = 5, |
| 53 | _URC_HANDLER_FOUND = 6, |
| 54 | _URC_INSTALL_CONTEXT = 7, |
| 55 | _URC_CONTINUE_UNWIND = 8 |
| 56 | } _Unwind_Reason_Code; |
| 57 | |
| 58 | uintptr_t _Unwind_GetIP(struct _Unwind_Context* context); |
| 59 | typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)(struct _Unwind_Context*, void*); |
| 60 | _Unwind_Reason_Code _Unwind_Backtrace(_Unwind_Trace_Fn, void*); |
| 61 | |
Rafael Espindola | 9b7568d | 2011-12-09 00:08:01 +0000 | [diff] [blame] | 62 | #pragma GCC visibility pop |
| 63 | |
Rafael Espindola | d85c1e9 | 2011-12-08 05:01:39 +0000 | [diff] [blame] | 64 | #ifdef __cplusplus |
| 65 | } |
| 66 | #endif |
| 67 | |
| 68 | #endif |