Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: include/core/SkPostConfig.h

Issue 1610823002: Consolidate SK_CRASH and sk_throw into SK_ABORT (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: windows fix Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/config/SkUserConfig.h ('k') | include/core/SkTArray.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 // IWYU pragma: private, include "SkTypes.h" 8 // IWYU pragma: private, include "SkTypes.h"
9 9
10 #ifndef SkPostConfig_DEFINED 10 #ifndef SkPostConfig_DEFINED
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 # else 96 # else
97 # define SkNO_RETURN_HINT() do {} while (false) 97 # define SkNO_RETURN_HINT() do {} while (false)
98 # endif 98 # endif
99 #endif 99 #endif
100 100
101 /////////////////////////////////////////////////////////////////////////////// 101 ///////////////////////////////////////////////////////////////////////////////
102 102
103 // TODO(mdempsky): Move elsewhere as appropriate. 103 // TODO(mdempsky): Move elsewhere as appropriate.
104 #include <new> 104 #include <new>
105 105
106 #ifndef SK_CRASH
107 # ifdef SK_BUILD_FOR_WIN
108 # define SK_CRASH() __debugbreak()
109 # else
110 # if 1 // set to 0 for infinite loop, which can help connecting gdb
111 # define SK_CRASH() do { SkNO_RETURN_HINT(); *(int *)(uintptr_t)0xbbadbeef = 0; } while (false)
112 # else
113 # define SK_CRASH() do { SkNO_RETURN_HINT(); } while (true)
114 # endif
115 # endif
116 #endif
117 106
118 /////////////////////////////////////////////////////////////////////////////// 107 ///////////////////////////////////////////////////////////////////////////////
119 108
120 #ifdef SK_BUILD_FOR_WIN 109 #ifdef SK_BUILD_FOR_WIN
121 # ifndef WIN32_LEAN_AND_MEAN 110 # ifndef WIN32_LEAN_AND_MEAN
122 # define WIN32_LEAN_AND_MEAN 111 # define WIN32_LEAN_AND_MEAN
123 # define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED 112 # define WIN32_IS_MEAN_WAS_LOCALLY_DEFINED
124 # endif 113 # endif
125 # ifndef NOMINMAX 114 # ifndef NOMINMAX
126 # define NOMINMAX 115 # define NOMINMAX
(...skipping 14 matching lines...) Expand all
141 # ifndef SK_A32_SHIFT 130 # ifndef SK_A32_SHIFT
142 # define SK_A32_SHIFT 24 131 # define SK_A32_SHIFT 24
143 # define SK_R32_SHIFT 16 132 # define SK_R32_SHIFT 16
144 # define SK_G32_SHIFT 8 133 # define SK_G32_SHIFT 8
145 # define SK_B32_SHIFT 0 134 # define SK_B32_SHIFT 0
146 # endif 135 # endif
147 # 136 #
148 #endif 137 #endif
149 138
150 #if defined(GOOGLE3) 139 #if defined(GOOGLE3)
151 // Used as argument to DumpStackTrace in SK_ALWAYSBREAK.
152 void SkDebugfForDumpStackTrace(const char* data, void* unused); 140 void SkDebugfForDumpStackTrace(const char* data, void* unused);
141 void DumpStackTrace(int skip_count, void w(const char*, void*), void* arg);
142 # define SK_DUMP_GOOGLE3_STACK() DumpStackTrace(0, SkDebugfForDumpStackTrace, n ullptr)
143 #else
144 # define SK_DUMP_GOOGLE3_STACK()
153 #endif 145 #endif
154 146
155 #ifndef SK_ALWAYSBREAK 147 #ifndef SK_ABORT
156 # if defined(GOOGLE3) 148 # define SK_ABORT(msg) \
157 void DumpStackTrace(int skip_count, void w(const char*, void*), 149 do { \
158 void* arg); 150 SkNO_RETURN_HINT(); \
159 # define SK_ALWAYSBREAK(cond) do { \ 151 SkDebugf("%s:%d: fatal error: \"%s\"\n", __FILE__, __LINE__, #msg); \
160 if (cond) break; \ 152 SK_DUMP_GOOGLE3_STACK(); \
161 SkNO_RETURN_HINT(); \ 153 sk_abort_no_print(); \
162 SkDebugf("%s:%d: failed assertion \"%s\"\n", __FILE__, __LINE__, # cond); \ 154 } while (false)
163 DumpStackTrace(0, SkDebugfForDumpStackTrace, nullptr); \
164 SK_CRASH(); \
165 } while (false)
166 # elif defined(SK_DEBUG)
167 # define SK_ALWAYSBREAK(cond) do { \
168 if (cond) break; \
169 SkNO_RETURN_HINT(); \
170 SkDebugf("%s:%d: failed assertion \"%s\"\n", __FILE__, __LINE__, # cond); \
171 SK_CRASH(); \
172 } while (false)
173 # else
174 # define SK_ALWAYSBREAK(cond) do { if (cond) break; SK_CRASH(); } while (fals e)
175 # endif
176 #endif 155 #endif
177 156
178 /** 157 /**
179 * We check to see if the SHIFT value has already been defined. 158 * We check to see if the SHIFT value has already been defined.
180 * if not, we define it ourself to some default values. We default to OpenGL 159 * if not, we define it ourself to some default values. We default to OpenGL
181 * order (in memory: r,g,b,a) 160 * order (in memory: r,g,b,a)
182 */ 161 */
183 #ifndef SK_A32_SHIFT 162 #ifndef SK_A32_SHIFT
184 # ifdef SK_CPU_BENDIAN 163 # ifdef SK_CPU_BENDIAN
185 # define SK_R32_SHIFT 24 164 # define SK_R32_SHIFT 24
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 # define SK_GAMMA_EXPONENT (2.2f) 338 # define SK_GAMMA_EXPONENT (2.2f)
360 #endif 339 #endif
361 340
362 ////////////////////////////////////////////////////////////////////// 341 //////////////////////////////////////////////////////////////////////
363 342
364 #ifndef GR_TEST_UTILS 343 #ifndef GR_TEST_UTILS
365 # define GR_TEST_UTILS 1 344 # define GR_TEST_UTILS 1
366 #endif 345 #endif
367 346
368 #endif // SkPostConfig_DEFINED 347 #endif // SkPostConfig_DEFINED
OLDNEW
« no previous file with comments | « include/config/SkUserConfig.h ('k') | include/core/SkTArray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698