openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

assert.c (1146B)


      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 
      8 #include <stdio.h>
      9 #include <stdlib.h>
     10 
     11 
     12 #include <soc/debug.h>
     13 
     14 
     15 #include <sal/core/libc.h>
     16 #include <sal/core/boot.h>
     17 
     18 /*
     19  * Function:
     20  *	_default_assert
     21  * Purpose:
     22  *	Default assertion routine used if not assigned by
     23  *	a call to sal_assert_set().
     24  */
     25 
     26 void
     27 _default_assert(const char *expr, const char *file, int line)
     28 {
     29     printf("ERROR: Assertion failed: (%s) at %s:%d\n",
     30 	   expr, file, line);
     31     abort();
     32 }
     33 
     34 /*
     35  * Function:
     36  *	sal_assert_set
     37  * Purpose:
     38  *	Set new assertion handler routine.
     39  * Parameters:
     40  *	f - assertion handler function
     41  */
     42 
     43 static sal_assert_func_t _assert = _default_assert;
     44 
     45 void
     46 sal_assert_set(sal_assert_func_t f)
     47 {
     48     _assert = (f) ? f : _default_assert;
     49 }
     50 
     51 /*
     52  * Function:
     53  *	_sal_assert
     54  * Purpose:
     55  *	Main assertion routine
     56  * Notes:
     57  *	Normally #define'd to assert().
     58  */
     59 
     60 /* coverity[+kill] */
     61 void
     62 _sal_assert(const char *expr, const char *file, int line)
     63 {
     64     _assert(expr, file, line);
     65 }