assert.h (959B)
1 /* 2 * 3 * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 4 * 5 * Copyright 2007-2019 Broadcom Inc. All rights reserved. 6 * 7 * This version of assert.h should appear in the compiler include path 8 * ahead of any other version of assert.h to ensure that _sal_assert is 9 * used for all assertion failures. 10 */ 11 12 #ifndef _ASSERT_H 13 #define _ASSERT_H 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 #if defined(__STDC__) || defined(__BORLAND__) 20 extern void _sal_assert(const char *, const char *, int); 21 #else 22 extern void _sal_assert(); 23 #endif 24 25 #ifdef __cplusplus 26 } 27 #endif 28 29 #endif /* _ASSERT_H */ 30 31 #undef assert 32 33 #ifdef NDEBUG 34 35 #define assert(EX) ((void)0) 36 37 #else 38 39 #if defined(__STDC__) 40 #define assert(EX) (void)((EX) || (_sal_assert(#EX, __FILE__, __LINE__), 0)) 41 #else 42 #define assert(EX) (void)((EX) || (_sal_assert("EX", __FILE__, __LINE__), 0)) 43 #endif /* __STDC__ */ 44 45 #endif /* NDEBUG */