]>
Commit | Line | Data |
---|---|---|
afe874b1 A |
1 | /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*- |
2 | * | |
3 | * Copyright (c) 2008 Apple Inc. All rights reserved. | |
4 | * | |
5 | * @APPLE_LICENSE_HEADER_START@ | |
6 | * | |
7 | * This file contains Original Code and/or Modifications of Original Code | |
8 | * as defined in and that are subject to the Apple Public Source License | |
9 | * Version 2.0 (the 'License'). You may not use this file except in | |
10 | * compliance with the License. Please obtain a copy of the License at | |
11 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
12 | * file. | |
13 | * | |
14 | * The Original Code and all software distributed under the License are | |
15 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
18 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. | |
19 | * Please see the License for the specific language governing rights and | |
20 | * limitations under the License. | |
21 | * | |
22 | * @APPLE_LICENSE_HEADER_END@ | |
23 | */ | |
24 | ||
25 | ||
26 | ||
27 | #ifndef INTERNAL_MACROS_H | |
28 | #define INTERNAL_MACROS_H | |
29 | ||
30 | #include <assert.h> | |
31 | ||
32 | #ifdef __cplusplus | |
33 | extern "C" { | |
34 | #endif | |
35 | extern void __assert_rtn(const char *, const char *, int, const char *) __attribute__((noreturn)); | |
36 | #ifdef __cplusplus | |
37 | } | |
38 | #endif | |
39 | ||
40 | #define UNW_STEP_SUCCESS 1 | |
41 | #define UNW_STEP_END 0 | |
42 | ||
43 | ||
44 | struct v128 { unsigned int vec[4]; }; | |
45 | ||
46 | ||
47 | #define EXPORT __attribute__((visibility("default"))) | |
48 | ||
49 | #define COMPILE_TIME_ASSERT( expr ) \ | |
50 | extern int compile_time_assert_failed[ ( expr ) ? 1 : -1 ] __attribute__( ( unused ) ); | |
51 | ||
52 | #define ABORT(msg) __assert_rtn(__func__, __FILE__, __LINE__, msg) | |
53 | ||
54 | #if NDEBUG | |
55 | #define DEBUG_MESSAGE(msg, ...) | |
56 | #define DEBUG_PRINT_API(msg, ...) | |
57 | #define DEBUG_PRINT_UNWINDING_TEST 0 | |
58 | #define DEBUG_PRINT_UNWINDING(msg, ...) | |
59 | #define DEBUG_LOG_NON_ZERO(x) x; | |
60 | #define INITIALIZE_DEBUG_PRINT_API | |
61 | #define INITIALIZE_DEBUG_PRINT_UNWINDING | |
62 | #else | |
63 | #define DEBUG_MESSAGE(msg, ...) fprintf(stderr, "libuwind: " msg, __VA_ARGS__) | |
64 | #ifdef __cplusplus | |
65 | extern "C" { | |
66 | #endif | |
67 | extern bool logAPIs(); | |
68 | extern bool logUnwinding(); | |
69 | #ifdef __cplusplus | |
70 | } | |
71 | #endif | |
72 | #define DEBUG_LOG_NON_ZERO(x) { int _err = x; if ( _err != 0 ) fprintf(stderr, "libuwind: " #x "=%d in %s", _err, __FUNCTION__); } | |
73 | #define DEBUG_PRINT_API(msg, ...) do { if ( logAPIs() ) fprintf(stderr, msg, __VA_ARGS__); } while(0) | |
74 | #define DEBUG_PRINT_UNWINDING(msg, ...) do { if ( logUnwinding() ) fprintf(stderr, msg, __VA_ARGS__); } while(0) | |
75 | #define DEBUG_PRINT_UNWINDING_TEST logUnwinding() | |
76 | #define INITIALIZE_DEBUG_PRINT_API bool logAPIs() { static bool log = (getenv("LIBUNWIND_PRINT_APIS") != NULL); return log; } | |
77 | #define INITIALIZE_DEBUG_PRINT_UNWINDING bool logUnwinding() { static bool log = (getenv("LIBUNWIND_PRINT_UNWINDING") != NULL); return log; } | |
78 | #endif | |
79 | ||
80 | ||
81 | // note hack for <rdar://problem/6175741> | |
82 | // Once libgcc_s.dylib vectors to libSystem, then we can remove the $ld$hide$os10.6$ lines | |
83 | #if __ppc__ | |
84 | #define NOT_HERE_BEFORE_10_6(sym) \ | |
85 | extern const char sym##_tmp3 __asm("$ld$hide$os10.3$_" #sym ); __attribute__((visibility("default"))) const char sym##_tmp3 = 0; \ | |
86 | extern const char sym##_tmp4 __asm("$ld$hide$os10.4$_" #sym ); __attribute__((visibility("default"))) const char sym##_tmp4 = 0; \ | |
87 | extern const char sym##_tmp5 __asm("$ld$hide$os10.5$_" #sym ); __attribute__((visibility("default"))) const char sym##_tmp5 = 0; | |
88 | #define NEVER_HERE(sym) \ | |
89 | extern const char sym##_tmp3 __asm("$ld$hide$os10.3$_" #sym ); __attribute__((visibility("default"))) const char sym##_tmp3 = 0; \ | |
90 | extern const char sym##_tmp4 __asm("$ld$hide$os10.4$_" #sym ); __attribute__((visibility("default"))) const char sym##_tmp4 = 0; \ | |
91 | extern const char sym##_tmp5 __asm("$ld$hide$os10.5$_" #sym ); __attribute__((visibility("default"))) const char sym##_tmp5 = 0; \ | |
92 | extern const char sym##_tmp6 __asm("$ld$hide$os10.6$_" #sym ); __attribute__((visibility("default"))) const char sym##_tmp6 = 0; | |
93 | #else | |
94 | #define NOT_HERE_BEFORE_10_6(sym) \ | |
95 | extern const char sym##_tmp4 __asm("$ld$hide$os10.4$_" #sym ); __attribute__((visibility("default"))) const char sym##_tmp4 = 0; \ | |
96 | extern const char sym##_tmp5 __asm("$ld$hide$os10.5$_" #sym ); __attribute__((visibility("default"))) const char sym##_tmp5 = 0; | |
97 | #define NEVER_HERE(sym) \ | |
98 | extern const char sym##_tmp4 __asm("$ld$hide$os10.4$_" #sym ); __attribute__((visibility("default"))) const char sym##_tmp4 = 0; \ | |
99 | extern const char sym##_tmp5 __asm("$ld$hide$os10.5$_" #sym ); __attribute__((visibility("default"))) const char sym##_tmp5 = 0; \ | |
100 | extern const char sym##_tmp6 __asm("$ld$hide$os10.6$_" #sym ); __attribute__((visibility("default"))) const char sym##_tmp6 = 0; | |
101 | #endif | |
102 | ||
103 | ||
104 | ||
105 | #endif // INTERNAL_MACROS_H |