diff options
author | Monte Copeland <copelanm@us.ibm.com> | 2011-08-11 15:57:40 -0500 |
---|---|---|
committer | Monte K. Copeland <copelanm@us.ibm.com> | 2011-08-16 13:24:44 -0500 |
commit | f24bf89ab0cb82fee8ab80ed6f5aa8142e3db462 (patch) | |
tree | 8647432fc82bbd34becc2ebcd7f50f2fccd469b8 /src/include/assert.h | |
parent | 802274b948ef4a52deb4285368a086f669d3913b (diff) | |
download | talos-hostboot-f24bf89ab0cb82fee8ab80ed6f5aa8142e3db462.tar.gz talos-hostboot-f24bf89ab0cb82fee8ab80ed6f5aa8142e3db462.zip |
Changes to errl to commit error logs to L3 RAM 7
Change-Id: Ic058a5b9ea6f8f1d79fc0ff30097cc32f18423bd
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/221
Reviewed-by: Monte K. Copeland <copelanm@us.ibm.com>
Tested-by: Jenkins Server
Diffstat (limited to 'src/include/assert.h')
-rw-r--r-- | src/include/assert.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/include/assert.h b/src/include/assert.h index a8f3fb664..1abeb5e2a 100644 --- a/src/include/assert.h +++ b/src/include/assert.h @@ -156,6 +156,27 @@ void __assert(AssertBehavior i_assertb, int i_line); #define crit_assert(expr,...) { } #endif + + +/** @brief Make an assertion at compile time. If Boolean expression exp + * is false, then the compile will stop with an error. Example usage: + * CPPASSERT( 2 == sizeof(compId_t)); + * which would be used in front of errl flattening code that assumes + * compId_t is 2 bytes in size. Also with the use of -f short-enums + * compiler switch, one could assert + * CPPASSERT( 1 == sizeof(errlEventType_t)); + * If the assertion fails, it will be a wakeup call that the errlEventType_t + * enum has grown larger than a byte in size. The mechanism to abend the + * compile when the expression is false is to cause a typedef of a char array + * that is -1 bytes in size. + * + * Similar: #define CHECK_SIZE(DATA, EXPECTED_SIZE)\ + * typedef char CHECKSIZEVAR[(EXPECTED_SIZE == sizeof(DATA)) -1] + * + */ +#define CPPASSERT(exp) typedef char compile_time_assert_failed[2*((exp)!=0)-1] + + #ifdef __cplusplus }; #endif |