genode/repos/base-sel4/src/include/base/internal/assert.h

39 lines
948 B
C

/*
* \brief Low-level assert macro
* \author Norman Feske
* \date 2015-05-06
*
* The output of the assert macro is directed to the platform's low-level
* debugging facility.
*/
/*
* Copyright (C) 2015 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2.
*/
#ifndef _BASE__INTERNAL__ASSERT_H_
#define _BASE__INTERNAL__ASSERT_H_
/* Genode includes */
#include <base/snprintf.h>
/* base-internal includes */
#include <base/internal/kernel_debugger.h>
#define ASSERT(e) \
do { if (!(e)) { \
char line_buf[32]; \
snprintf(line_buf, sizeof(line_buf), "%d", __LINE__); \
kernel_debugger_outstring(ESC_ERR "Assertion failed: " #e ESC_END "\n"); \
kernel_debugger_outstring(__FILE__ ":"); \
kernel_debugger_outstring(line_buf); \
kernel_debugger_panic("\n"); \
} \
} while(0)
#else
#endif /* _BASE__INTERNAL__ASSERT_H_ */