Skip to content

Commit

Permalink
debug: Make DEBUGF more platform-independent
Browse files Browse the repository at this point in the history
  • Loading branch information
miri64 committed Feb 12, 2015
1 parent c6777ff commit da10435
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions core/include/debug.h
Expand Up @@ -13,7 +13,7 @@
* @file debug.h
* @brief Debug-header
*
* @details If ENABLE_DEBUG is set, before this header is included,
* @details If ENABLE_DEBUG is set, before this header is included,
* ::DEBUG will print out to stdout, otherwise do nothing
*
* @author Kaspar Schleiser <kaspar@schleiser.de>
Expand Down Expand Up @@ -70,12 +70,29 @@
*/
#if ENABLE_DEBUG
#include "tcb.h"

/**
* @def DEBUG_FUNC
*
* @brief Contains the function name if given compiler supports it.
* Otherwise it is an empty string.
*/
# if defined(__cplusplus) && defined(__GNUC__)
# define DEBUG_FUNC __PRETTY_FUNCTION__
# elif __STDC_VERSION__ >= 199901L
# define DEBUG_FUNC __func__
# elif __GNUC__ >= 2
# define DEBUG_FUNC __FUNCTION__
# else
# define DEBUF_FUNC ""
# endif

#define DEBUG(...) DEBUG_PRINT(__VA_ARGS__)
#define DEBUGF(...) \
do { \
DEBUG_PRINT("DEBUG(%s): %s:%d in %s: ", \
sched_active_thread ? sched_active_thread->name : "NO THREAD", \
__FILE__, __LINE__, __func__); \
__FILE__, __LINE__, DEBUG_FUNC); \
DEBUG_PRINT(__VA_ARGS__); \
} while (0)
#else
Expand Down

0 comments on commit da10435

Please sign in to comment.