1 /* |
1 /* |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
223 void report_unimplemented(const char* file, int line); |
223 void report_unimplemented(const char* file, int line); |
224 void report_untested(const char* file, int line, const char* message); |
224 void report_untested(const char* file, int line, const char* message); |
225 |
225 |
226 void warning(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); |
226 void warning(const char* format, ...) ATTRIBUTE_PRINTF(1, 2); |
227 |
227 |
228 #ifdef ASSERT |
228 // Compile-time asserts. Cond must be a compile-time constant expression that |
229 // Compile-time asserts. |
229 // is convertible to bool. STATIC_ASSERT() can be used anywhere a declaration |
230 template <bool> struct StaticAssert; |
230 // may appear. |
231 template <> struct StaticAssert<true> {}; |
231 // |
232 |
232 // Implementation Note: STATIC_ASSERT_FAILURE<true> provides a value member |
233 // Only StaticAssert<true> is defined, so if cond evaluates to false we get |
233 // rather than type member that could be used directly in the typedef, because |
234 // a compile time exception when trying to use StaticAssert<false>. |
234 // a type member would require conditional use of "typename", depending on |
235 #define STATIC_ASSERT(cond) \ |
235 // whether Cond is dependent or not. The use of a value member leads to the |
236 do { \ |
236 // use of an array type. |
237 StaticAssert<(cond)> DUMMY_STATIC_ASSERT; \ |
237 |
238 (void)DUMMY_STATIC_ASSERT; /* ignore */ \ |
238 template<bool x> struct STATIC_ASSERT_FAILURE; |
239 } while (false) |
239 template<> struct STATIC_ASSERT_FAILURE<true> { enum { value = 1 }; }; |
240 #else |
240 |
241 #define STATIC_ASSERT(cond) |
241 #define STATIC_ASSERT(Cond) \ |
242 #endif |
242 typedef char STATIC_ASSERT_FAILURE_ ## __LINE__ [ \ |
|
243 STATIC_ASSERT_FAILURE< (Cond) >::value ] |
243 |
244 |
244 // out of shared space reporting |
245 // out of shared space reporting |
245 enum SharedSpaceType { |
246 enum SharedSpaceType { |
246 SharedReadOnly, |
247 SharedReadOnly, |
247 SharedReadWrite, |
248 SharedReadWrite, |