From 9077299d06defd23eb0ee589f1f3e7bcf2fdf725 Mon Sep 17 00:00:00 2001 From: Martine Lenders Date: Wed, 11 Feb 2015 18:24:24 +0100 Subject: [PATCH] msp430: add assert header --- cpu/msp430-common/include/assert.h | 69 ++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 cpu/msp430-common/include/assert.h diff --git a/cpu/msp430-common/include/assert.h b/cpu/msp430-common/include/assert.h new file mode 100644 index 0000000000..8c5c0d1c7c --- /dev/null +++ b/cpu/msp430-common/include/assert.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2015 Martine Lenders + * + * This file is subject to the terms and conditions of the GNU Lesser General + * Public License v2.1. See the file LICENSE in the top level directory for + * more details. + */ + +/** + * @ingroup msp430 + * @{ + * + * @file + * @brief assert.h for msp430 + * @see http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/assert.h.html + * + * @author Martine Lenders + */ + + +#ifndef ASSERT_H_ +#define ASSERT_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @def ASSERT_FUNC + * + * @brief Contains the function name if given compiler supports it. + * Otherwise it is an empty string. + */ +# if defined(__cplusplus) && defined(__GNUC__) +# define ASSERT_FUNC __PRETTY_FUNCTION__ +# elif __STDC_VERSION__ >= 199901L +# define ASSERT_FUNC __func__ +# elif __GNUC__ >= 2 +# define ASSERT_FUNC __FUNCTION__ +# else +# define ASSERT_FUNC "" +# endif + +/** + * @def assert + * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/assert.html + */ +#ifndef NDEBUG +# define assert(assertion) \ + if (!(assertion)) { \ + printf("%s:%d: %s: Assertion '%s' failed", __FILE__, __LINE__, \ + ASSERT_FUNC, #assertion); \ + abort(); \ + } +#else +# define assert(assertion) ((void) 0) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ASSERT_H_ */ +/** + * @} + */