From: Liu Yuan <liuy...@cmss.chinamobile.com> This is a preparation patch for shared lib. shared lib can't call sd logger.
Signed-off-by: Liu Yuan <liuy...@cmss.chinamobile.com> --- dog/dog.h | 1 + dog/treeview.c | 1 + include/fec.h | 1 + include/logger.h | 6 ------ include/sheep.h | 1 + include/util.h | 20 +++++++++++++++++++- include/work.h | 1 + lib/event.c | 1 + lib/fec.c | 1 + lib/logger.c | 1 + 10 files changed, 27 insertions(+), 7 deletions(-) diff --git a/dog/dog.h b/dog/dog.h index 707f31b..d603328 100644 --- a/dog/dog.h +++ b/dog/dog.h @@ -26,6 +26,7 @@ #include "event.h" #include "config.h" #include "common.h" +#include "logger.h" #define CMD_NEED_NODELIST (1 << 0) #define CMD_NEED_ARG (1 << 1) diff --git a/dog/treeview.c b/dog/treeview.c index b22ec15..072eee9 100644 --- a/dog/treeview.c +++ b/dog/treeview.c @@ -14,6 +14,7 @@ #include <stdint.h> #include "util.h" +#include "logger.h" #include "treeview.h" #ifndef MAX_DEPTH diff --git a/include/fec.h b/include/fec.h index b3ef8d8..690a775 100644 --- a/include/fec.h +++ b/include/fec.h @@ -63,6 +63,7 @@ #include <stdint.h> #include "util.h" +#include "logger.h" #include "sheepdog_proto.h" #include "../lib/isa-l/include/erasure_code.h" diff --git a/include/logger.h b/include/logger.h index df69faf..d3900c8 100644 --- a/include/logger.h +++ b/include/logger.h @@ -88,12 +88,6 @@ void sd_backtrace(void); log_write(SDOG_DEBUG, __func__, __LINE__, fmt, ##args); \ }) -#define panic(fmt, args...) \ -({ \ - sd_emerg("PANIC: " fmt, ##args); \ - abort(); \ -}) - #define sd_assert(expr) \ ({ \ if (!(expr)) { \ diff --git a/include/sheep.h b/include/sheep.h index fe6f066..ebd4143 100644 --- a/include/sheep.h +++ b/include/sheep.h @@ -14,6 +14,7 @@ #include <stdint.h> #include "internal_proto.h" +#include "logger.h" #include "util.h" #include "bitops.h" #include "list.h" diff --git a/include/util.h b/include/util.h index 6c11b54..2b2f34b 100644 --- a/include/util.h +++ b/include/util.h @@ -15,7 +15,6 @@ #include <sys/param.h> #include <assert.h> -#include "logger.h" #include "list.h" #include "compiler.h" @@ -45,6 +44,25 @@ #define uninitialized_var(x) x = x +#ifndef NO_SHEEPDOG_LOGGER + +#include "logger.h" +#define panic(fmt, args...) \ +({ \ + sd_emerg("PANIC: " fmt, ##args); \ + abort(); \ +}) + +#else + +#define panic(fmt, args...) \ +({ \ + fprintf(stderr, "PANIC: " fmt, ##args); \ + abort(); \ +}) + +#endif + static inline int before(uint32_t seq1, uint32_t seq2) { return (int32_t)(seq1 - seq2) < 0; diff --git a/include/work.h b/include/work.h index c2008ba..eb103a5 100644 --- a/include/work.h +++ b/include/work.h @@ -5,6 +5,7 @@ #include "list.h" #include "util.h" +#include "logger.h" struct work; diff --git a/lib/event.c b/lib/event.c index 3a0f968..04518cb 100644 --- a/lib/event.c +++ b/lib/event.c @@ -16,6 +16,7 @@ #include <sys/epoll.h> #include "rbtree.h" +#include "logger.h" #include "util.h" #include "event.h" diff --git a/lib/fec.c b/lib/fec.c index 268bce6..e0908bc 100644 --- a/lib/fec.c +++ b/lib/fec.c @@ -60,6 +60,7 @@ #include <string.h> #include "fec.h" +#include "logger.h" #include "util.h" /* diff --git a/lib/logger.c b/lib/logger.c index ffe84fc..386b949 100644 --- a/lib/logger.c +++ b/lib/logger.c @@ -37,6 +37,7 @@ #include "util.h" #include "common.h" +#include "logger.h" static bool colorize; static const char * const log_color[] = { -- 1.9.1 -- sheepdog mailing list sheepdog@lists.wpkg.org https://lists.wpkg.org/mailman/listinfo/sheepdog