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

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

Issue 1620333002: Revert of Consolidate SK_CRASH and sk_throw into SK_ABORT (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/core/SkTArray.h ('k') | src/core/SkPath.cpp » ('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 #ifndef SkTypes_DEFINED 8 #ifndef SkTypes_DEFINED
9 #define SkTypes_DEFINED 9 #define SkTypes_DEFINED
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 */ 60 */
61 61
62 /** Called internally if we run out of memory. The platform implementation must 62 /** Called internally if we run out of memory. The platform implementation must
63 not return, but should either throw an exception or otherwise exit. 63 not return, but should either throw an exception or otherwise exit.
64 */ 64 */
65 SK_API extern void sk_out_of_memory(void); 65 SK_API extern void sk_out_of_memory(void);
66 /** Called internally if we hit an unrecoverable error. 66 /** Called internally if we hit an unrecoverable error.
67 The platform implementation must not return, but should either throw 67 The platform implementation must not return, but should either throw
68 an exception or otherwise exit. 68 an exception or otherwise exit.
69 */ 69 */
70 SK_API extern void sk_abort_no_print(void); 70 SK_API extern void sk_throw(void);
71 71
72 enum { 72 enum {
73 SK_MALLOC_TEMP = 0x01, //!< hint to sk_malloc that the requested memory wil l be freed in the scope of the stack frame 73 SK_MALLOC_TEMP = 0x01, //!< hint to sk_malloc that the requested memory wil l be freed in the scope of the stack frame
74 SK_MALLOC_THROW = 0x02 //!< instructs sk_malloc to call sk_throw if the mem ory cannot be allocated. 74 SK_MALLOC_THROW = 0x02 //!< instructs sk_malloc to call sk_throw if the mem ory cannot be allocated.
75 }; 75 };
76 /** Return a block of memory (at least 4-byte aligned) of at least the 76 /** Return a block of memory (at least 4-byte aligned) of at least the
77 specified size. If the requested memory cannot be returned, either 77 specified size. If the requested memory cannot be returned, either
78 return null (if SK_MALLOC_TEMP bit is clear) or throw an exception 78 return null (if SK_MALLOC_TEMP bit is clear) or throw an exception
79 (if SK_MALLOC_TEMP bit is set). To free the memory, call sk_free(). 79 (if SK_MALLOC_TEMP bit is set). To free the memory, call sk_free().
80 */ 80 */
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 #endif 121 #endif
122 122
123 /////////////////////////////////////////////////////////////////////////////// 123 ///////////////////////////////////////////////////////////////////////////////
124 124
125 #define SK_INIT_TO_AVOID_WARNING = 0 125 #define SK_INIT_TO_AVOID_WARNING = 0
126 126
127 #ifndef SkDebugf 127 #ifndef SkDebugf
128 SK_API void SkDebugf(const char format[], ...); 128 SK_API void SkDebugf(const char format[], ...);
129 #endif 129 #endif
130 130
131 #define SkASSERT_RELEASE(cond) if(!(cond)) { SK_ABORT(#cond); }
132
133 #ifdef SK_DEBUG 131 #ifdef SK_DEBUG
134 #define SkASSERT(cond) SkASSERT_RELEASE(cond) 132 #define SkASSERT(cond) SK_ALWAYSBREAK(cond)
135 #define SkDEBUGFAIL(message) SkASSERT(false && message) 133 #define SkDEBUGFAIL(message) SkASSERT(false && message)
136 #define SkDEBUGFAILF(fmt, ...) SkASSERTF(false, fmt, ##__VA_ARGS__) 134 #define SkDEBUGFAILF(fmt, ...) SkASSERTF(false, fmt, ##__VA_ARGS__)
137 #define SkDEBUGCODE(code) code 135 #define SkDEBUGCODE(code) code
138 #define SkDECLAREPARAM(type, var) , type var 136 #define SkDECLAREPARAM(type, var) , type var
139 #define SkPARAM(var) , var 137 #define SkPARAM(var) , var
140 // #define SkDEBUGF(args ) SkDebugf##args 138 // #define SkDEBUGF(args ) SkDebugf##args
141 #define SkDEBUGF(args ) SkDebugf args 139 #define SkDEBUGF(args ) SkDebugf args
142 #define SkAssertResult(cond) SkASSERT(cond) 140 #define SkAssertResult(cond) SkASSERT(cond)
143 #else 141 #else
144 #define SkASSERT(cond) 142 #define SkASSERT(cond)
145 #define SkDEBUGFAIL(message) 143 #define SkDEBUGFAIL(message)
146 #define SkDEBUGCODE(code) 144 #define SkDEBUGCODE(code)
147 #define SkDEBUGF(args) 145 #define SkDEBUGF(args)
148 #define SkDECLAREPARAM(type, var) 146 #define SkDECLAREPARAM(type, var)
149 #define SkPARAM(var) 147 #define SkPARAM(var)
150 148
151 // unlike SkASSERT, this guy executes its condition in the non-debug build 149 // unlike SkASSERT, this guy executes its condition in the non-debug build
152 #define SkAssertResult(cond) cond 150 #define SkAssertResult(cond) cond
153 #endif 151 #endif
154 152
155 // Legacy macro names for SK_ABORT 153 #define SkFAIL(message) SK_ALWAYSBREAK(false && message)
156 #define SkFAIL(message) SK_ABORT(message)
157 #define sk_throw() SK_ABORT("sk_throw")
158 154
159 // We want to evaluate cond only once, and inside the SkASSERT somewhere so we s ee its string form. 155 // We want to evaluate cond only once, and inside the SkASSERT somewhere so we s ee its string form.
160 // So we use the comma operator to make an SkDebugf that always returns false: w e'll evaluate cond, 156 // So we use the comma operator to make an SkDebugf that always returns false: w e'll evaluate cond,
161 // and if it's true the assert passes; if it's false, we'll print the message an d the assert fails. 157 // and if it's true the assert passes; if it's false, we'll print the message an d the assert fails.
162 #define SkASSERTF(cond, fmt, ...) SkASSERT((cond) || (SkDebugf(fmt"\n", __ VA_ARGS__), false)) 158 #define SkASSERTF(cond, fmt, ...) SkASSERT((cond) || (SkDebugf(fmt"\n", __ VA_ARGS__), false))
163 159
164 #ifdef SK_DEVELOPER 160 #ifdef SK_DEVELOPER
165 #define SkDEVCODE(code) code 161 #define SkDEVCODE(code) code
166 #else 162 #else
167 #define SkDEVCODE(code) 163 #define SkDEVCODE(code)
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 private: 684 private:
689 void* fPtr; 685 void* fPtr;
690 size_t fSize; // can be larger than the requested size (see kReuse) 686 size_t fSize; // can be larger than the requested size (see kReuse)
691 uint32_t fStorage[(kSize + 3) >> 2]; 687 uint32_t fStorage[(kSize + 3) >> 2];
692 }; 688 };
693 // Can't guard the constructor because it's a template class. 689 // Can't guard the constructor because it's a template class.
694 690
695 #endif /* C++ */ 691 #endif /* C++ */
696 692
697 #endif 693 #endif
OLDNEW
« no previous file with comments | « include/core/SkTArray.h ('k') | src/core/SkPath.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698