67 lines
2.5 KiB
Diff
67 lines
2.5 KiB
Diff
|
From 8bfe49d79c1b7ae1aa4b7b22b627afa40a4a08d2 Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Jan=20Pokorn=C3=BD?= <jpokorny@redhat.com>
|
||
|
Date: Fri, 6 Oct 2017 17:17:26 +0200
|
||
|
Subject: [PATCH 1/6] Med: qblog.h: better explanation + behaviour of
|
||
|
QB_LOG_INIT_DATA
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
Based on better understanding how link-time callsite collection works,
|
||
|
put a better description for the macro. Also based on poor user
|
||
|
experience in case that feature does not work well, say because
|
||
|
the linker deliberately changes the previously settled visibility
|
||
|
of the section boundary symbols (happened in ld from binutils-2.29,
|
||
|
fix is forthcoming), tweak the assertion message a bit:
|
||
|
|
||
|
- use case:
|
||
|
/usr/sbin/pacemakerd --features
|
||
|
|
||
|
- before:
|
||
|
pacemakerd: utils.c:69: common:
|
||
|
Assertion `0' failed
|
||
|
|
||
|
- after:
|
||
|
pacemakerd: utils.c:69: common:
|
||
|
Assertion `("non-empty callsite section", QB_ATTR_SECTION_START != QB_ATTR_SECTION_STOP)' failed.
|
||
|
|
||
|
Inspired by the suggestion of Ferenc Wágner (for the subsequent
|
||
|
commit, actually).
|
||
|
|
||
|
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
|
||
|
---
|
||
|
include/qb/qblog.h | 17 ++++++++++++-----
|
||
|
1 file changed, 12 insertions(+), 5 deletions(-)
|
||
|
|
||
|
diff --git a/include/qb/qblog.h b/include/qb/qblog.h
|
||
|
index 3cb4eef..d38449d 100644
|
||
|
--- a/include/qb/qblog.h
|
||
|
+++ b/include/qb/qblog.h
|
||
|
@@ -268,11 +268,18 @@ typedef void (*qb_log_filter_fn)(struct qb_log_callsite * cs);
|
||
|
extern struct qb_log_callsite QB_ATTR_SECTION_START[];
|
||
|
extern struct qb_log_callsite QB_ATTR_SECTION_STOP[];
|
||
|
|
||
|
-/* mere linker sanity check, possible future extension for internal purposes */
|
||
|
-#define QB_LOG_INIT_DATA(name) \
|
||
|
- void name(void); \
|
||
|
- void name(void) \
|
||
|
- { if (QB_ATTR_SECTION_START == QB_ATTR_SECTION_STOP) assert(0); } \
|
||
|
+/* optional on-demand self-check of (1) toolchain sanity and (2) non-void
|
||
|
+ * (implied by the justifying existence of at least a single logging callsite
|
||
|
+ * ~ qb_logt invocation) employment of logging subsystem in the target binary,
|
||
|
+ * which is presumably assured by it's author as of relying on this macro;
|
||
|
+ * only effective when link-time ("run-time amortizing") callsite collection
|
||
|
+ * is available and may be extended in future for more in-depth self-validation
|
||
|
+ */
|
||
|
+#define QB_LOG_INIT_DATA(name) \
|
||
|
+ void name(void); \
|
||
|
+ void name(void) \
|
||
|
+ { assert(("non-empty callsite section", \
|
||
|
+ QB_ATTR_SECTION_START != QB_ATTR_SECTION_STOP)); } \
|
||
|
void __attribute__ ((constructor)) name(void);
|
||
|
#else
|
||
|
#define QB_LOG_INIT_DATA(name)
|
||
|
--
|
||
|
2.14.2
|
||
|
|