Skip to content

Commit

Permalink
Low: explain mysterious lines in a public header (qblog.h)
Browse files Browse the repository at this point in the history
Also fix the previous inversion of the expression that in fact did not
use to check for anything (for "assert(1)" being a NOOP).
  • Loading branch information
jnpkrn committed Mar 4, 2016
1 parent 043cebb commit c148444
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions include/qb/qblog.h
Expand Up @@ -253,14 +253,17 @@ struct qb_log_callsite {

typedef void (*qb_log_filter_fn)(struct qb_log_callsite * cs);

/* will be assigned by ld linker magic */
/* will be assigned by linker magic (assuming linker supports that):
* https://sourceware.org/binutils/docs/ld/Orphan-Sections.html
*/
#ifdef QB_HAVE_ATTRIBUTE_SECTION
extern struct qb_log_callsite __start___verbose[];
extern struct qb_log_callsite __stop___verbose[];

#define QB_LOG_INIT_DATA(name) \
void name(void); \
void name(void) { if (__start___verbose != __stop___verbose) {assert(1);} } \
/* mere linker sanity check, possible future extension for internal purposes */
#define QB_LOG_INIT_DATA(name) \
void name(void); \
void name(void) { if (__start___verbose == __stop___verbose) assert(0); } \
void __attribute__ ((constructor)) name(void);
#else
#define QB_LOG_INIT_DATA(name)
Expand Down

0 comments on commit c148444

Please sign in to comment.