mss_assert.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*******************************************************************************
  2. * (c) Copyright 2009-2013 Microsemi SoC Products Group. All rights reserved.
  3. *
  4. * Assertion implementation.
  5. *
  6. * This file provides the implementation of the ASSERT macro. This file can be
  7. * modified to cater for project specific requirements regarding the way
  8. * assertions are handled.
  9. *
  10. * SVN $Revision: 6422 $
  11. * SVN $Date: 2014-05-14 14:37:56 +0100 (Wed, 14 May 2014) $
  12. */
  13. #ifndef __MSS_ASSERT_H_
  14. #define __MSS_ASSERT_H_
  15. #if defined(NDEBUG)
  16. #define ASSERT(CHECK)
  17. #else /* NDEBUG */
  18. #include <assert.h>
  19. #if defined ( __GNUC__ )
  20. /*
  21. * SoftConsole assertion handling
  22. */
  23. #define ASSERT(CHECK) \
  24. do { \
  25. if (!(CHECK)) \
  26. { \
  27. __asm volatile ("BKPT\n\t"); \
  28. } \
  29. } while (0);
  30. #elif defined ( __ICCARM__ )
  31. /*
  32. * IAR Embedded Workbench assertion handling.
  33. * Call C library assert function which should result in error message
  34. * displayed in debugger.
  35. */
  36. #define ASSERT(X) assert(X)
  37. #else
  38. /*
  39. * Keil assertion handling.
  40. * Call C library assert function which should result in error message
  41. * displayed in debugger.
  42. */
  43. #ifndef __MICROLIB
  44. #define ASSERT(X) assert(X)
  45. #else
  46. #define ASSERT(X)
  47. #endif
  48. #endif /* Tool Chain */
  49. #endif /* NDEBUG */
  50. #endif /* __MSS_ASSERT_H_ */