mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-14 13:20:34 +08:00
err/px4_log: switch everything to static function
Instead of having separate log functions for NuttX and POSIX, this now switches everything to px4_log.h and PX4_INFO/WARN/ERR/DEBUG. Also, the call mostly used is now a static inline function instead of a macro which lead to a big increase in flash size for STM32.
This commit is contained in:
@@ -60,6 +60,8 @@ extern int lib_lowvprintf(const char *fmt, va_list ap);
|
||||
# warning Cannot output without one of CONFIG_NFILE_STREAMS or CONFIG_ARCH_LOWPUTC
|
||||
#endif
|
||||
|
||||
// XXX not used anymore
|
||||
#if 0
|
||||
const char *
|
||||
getprogname(void)
|
||||
{
|
||||
@@ -201,3 +203,4 @@ vwarnx(const char *fmt, va_list args)
|
||||
{
|
||||
warnerr_core(NOCODE, fmt, args);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -67,23 +67,33 @@
|
||||
|
||||
#include <px4_log.h>
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include "visibility.h"
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
__EXPORT const char *getprogname(void);
|
||||
|
||||
#ifdef __PX4_POSIX
|
||||
|
||||
#include <errno.h>
|
||||
#include <px4_tasks.h>
|
||||
#define err(eval, ...) do { PX4_ERR(__VA_ARGS__); PX4_ERR("Task exited with errno=%i\n", errno); \
|
||||
px4_task_exit(eval); } while(0)
|
||||
#define errx(eval, ...) do { PX4_ERR(__VA_ARGS__); px4_task_exit(eval); } while(0)
|
||||
#define warn(...) PX4_WARN(__VA_ARGS__)
|
||||
#define warnx(...) PX4_WARN(__VA_ARGS__)
|
||||
|
||||
#else
|
||||
#define err(eval, ...) do { \
|
||||
PX4_ERR(__VA_ARGS__); \
|
||||
PX4_ERR("Task exited with errno=%i\n", errno); \
|
||||
px4_task_exit(eval); } \
|
||||
while(0)
|
||||
|
||||
#define errx(eval, ...) do { \
|
||||
PX4_ERR(__VA_ARGS__); \
|
||||
px4_task_exit(eval); \
|
||||
} while(0)
|
||||
|
||||
#define warn(...) PX4_WARN(__VA_ARGS__)
|
||||
#define warnx(...) PX4_WARN(__VA_ARGS__)
|
||||
|
||||
// XXX not used anymore
|
||||
#if 0
|
||||
__EXPORT void err(int eval, const char *fmt, ...) __attribute__((noreturn, format(printf, 2, 3)));
|
||||
__EXPORT void verr(int eval, const char *fmt, va_list) __attribute__((noreturn, format(printf, 2, 0)));
|
||||
__EXPORT void errc(int eval, int code, const char *fmt, ...) __attribute__((noreturn, format(printf, 3, 4)));
|
||||
|
||||
Reference in New Issue
Block a user