diff options
Diffstat (limited to 'platform/include/chre/platform/assert.h')
-rw-r--r-- | platform/include/chre/platform/assert.h | 53 |
1 files changed, 13 insertions, 40 deletions
diff --git a/platform/include/chre/platform/assert.h b/platform/include/chre/platform/assert.h index c5b404a4..7cdc3064 100644 --- a/platform/include/chre/platform/assert.h +++ b/platform/include/chre/platform/assert.h @@ -21,19 +21,23 @@ /** * @file - * Defines the CHRE_ASSERT and CHRE_ASSERT_LOG macros for CHRE platforms. - * Platforms must supply an implementation for assertCondition or use the shared - * implementation. + * Includes the platform-specific header file that supplies an assertion macro. + * The platform header must supply the following symbol as a macro or free + * function: + * + * CHRE_ASSERT(scalar expression) + * + * Where expression will be checked to be false (ie: compares equal to zero) and + * terminate the program if found to be the case. */ #if defined(CHRE_ASSERTIONS_ENABLED) -#define CHRE_ASSERT(condition) \ - do { \ - if (!(condition)) { \ - chre::doAssert(CHRE_FILENAME, __LINE__); \ - } \ - } while (0) +#include "chre/target_platform/assert.h" + +#ifndef CHRE_ASSERT +#error "CHRE_ASSERT must be defined by the target platform's assert.h" +#endif // CHRE_ASSERT #elif defined(CHRE_ASSERTIONS_DISABLED) @@ -43,12 +47,6 @@ #error "CHRE_ASSERTIONS_ENABLED or CHRE_ASSERTIONS_DISABLED must be defined" #endif // CHRE_ASSERTIONS_ENABLED -#ifdef __cplusplus -#define CHRE_ASSERT_NOT_NULL(ptr) CHRE_ASSERT((ptr) != nullptr) -#else -#define CHRE_ASSERT_NOT_NULL(ptr) CHRE_ASSERT((ptr) != NULL) -#endif - /** * Combination macro that always logs an error message if the condition * evaluates to false. @@ -68,29 +66,4 @@ } \ } while (0) -/** - * Defines "if not test" macros that allow code to not assert when running - * on-device unit tests if the assertion isn't useful during testing. - */ -#ifdef CHRE_ON_DEVICE_TESTS_ENABLED -#define CHRE_ASSERT_LOG_IF_NOT_TEST(condition, fmt, ...) -#define CHRE_ASSERT_IF_NOT_TEST(condition) ((void)(condition)) -#else -#define CHRE_ASSERT_LOG_IF_NOT_TEST(condition, fmt, ...) \ - CHRE_ASSERT_LOG(condition, fmt, ##__VA_ARGS__) -#define CHRE_ASSERT_IF_NOT_TEST(condition) CHRE_ASSERT(condition) -#endif - -namespace chre { - -/** - * Performs assertion while logging the filename and line provided. - * - * @param filename The filename containing the assertion being fired. - * @param line The line that contains the assertion being fired. - */ -void doAssert(const char *filename, size_t line); - -} // namespace chre - #endif // CHRE_PLATFORM_ASSERT_H_ |