mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #3881 from geky/log-no-io
Remove debug links to printf/exit in NDEBUG buildspull/4252/merge
commit
7ace0cbb14
|
@ -18,49 +18,49 @@
|
||||||
*/
|
*/
|
||||||
#ifndef MBED_DEBUG_H
|
#ifndef MBED_DEBUG_H
|
||||||
#define MBED_DEBUG_H
|
#define MBED_DEBUG_H
|
||||||
#include "device.h"
|
#if DEVICE_STDIO_MESSAGES
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DEVICE_STDIO_MESSAGES
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
|
|
||||||
/** Output a debug message
|
/** Output a debug message
|
||||||
*
|
*
|
||||||
* @param format printf-style format string, followed by variables
|
* @param format printf-style format string, followed by variables
|
||||||
*/
|
*/
|
||||||
static inline void debug(const char *format, ...) {
|
static inline void debug(const char *format, ...) {
|
||||||
|
#if DEVICE_STDIO_MESSAGES && !defined(NDEBUG)
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vfprintf(stderr, format, args);
|
vfprintf(stderr, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Conditionally output a debug message
|
/** Conditionally output a debug message
|
||||||
*
|
*
|
||||||
* NOTE: If the condition is constant false (!= 1) and the compiler optimization
|
* NOTE: If the condition is constant false (== 0) and the compiler optimization
|
||||||
* level is greater than 0, then the whole function will be compiled away.
|
* level is greater than 0, then the whole function will be compiled away.
|
||||||
*
|
*
|
||||||
* @param condition output only if condition is true (== 1)
|
* @param condition output only if condition is true (!= 0)
|
||||||
* @param format printf-style format string, followed by variables
|
* @param format printf-style format string, followed by variables
|
||||||
*/
|
*/
|
||||||
static inline void debug_if(int condition, const char *format, ...) {
|
static inline void debug_if(int condition, const char *format, ...) {
|
||||||
if (condition == 1) {
|
#if DEVICE_STDIO_MESSAGES && !defined(NDEBUG)
|
||||||
|
if (condition) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
vfprintf(stderr, format, args);
|
vfprintf(stderr, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
|
||||||
static inline void debug(const char *format, ...) {}
|
|
||||||
static inline void debug_if(int condition, const char *format, ...) {}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
|
#include "mbed_error.h"
|
||||||
|
|
||||||
|
|
||||||
/*----------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------
|
||||||
|
@ -244,7 +245,6 @@ void os_idle_demon (void) {
|
||||||
/*----------------------------------------------------------------------------
|
/*----------------------------------------------------------------------------
|
||||||
* RTX Errors
|
* RTX Errors
|
||||||
*---------------------------------------------------------------------------*/
|
*---------------------------------------------------------------------------*/
|
||||||
extern void error(const char* format, ...);
|
|
||||||
extern osThreadId svcThreadGetId (void);
|
extern osThreadId svcThreadGetId (void);
|
||||||
|
|
||||||
void os_error (uint32_t err_code) {
|
void os_error (uint32_t err_code) {
|
||||||
|
|
Loading…
Reference in New Issue