mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
added compiler hints for assertions
git-svn-id: https://zerberus.eonerc.rwth-aachen.de:8443/svn/s2ss/trunk@166 8ec27952-4edc-4aab-86aa-e87bb2611832
This commit is contained in:
parent
a628d8bc5c
commit
928af73f23
1 changed files with 7 additions and 1 deletions
|
@ -15,6 +15,12 @@
|
|||
|
||||
#include <sched.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define EXPECT(x, v) __builtin_expect(x, v)
|
||||
#else
|
||||
#define EXPECT(x) (x)
|
||||
#endif
|
||||
|
||||
/* Some color escape codes for pretty log messages */
|
||||
#define RED(str) "\x1B[31m" str "\x1B[0m" /**< Print str in red */
|
||||
#define GRN(str) "\x1B[32m" str "\x1B[0m" /**< Print str in green */
|
||||
|
@ -70,7 +76,7 @@ struct timespec timespec_rate(double rate);
|
|||
|
||||
/** Check assertion and exit if failed. */
|
||||
#define assert(exp) do { \
|
||||
if (!(exp)) { \
|
||||
if (EXPECT(exp, 0)) { \
|
||||
print(ERROR, "Assertion failed: '%s' in %s, %s:%d", \
|
||||
#exp, __FUNCTION__, __BASE_FILE__, __LINE__); \
|
||||
exit(EXIT_FAILURE); \
|
||||
|
|
Loading…
Add table
Reference in a new issue