Subject: use of variadic macros?
To: None <tech-kern@netbsd.org>
From: David Young <dyoung@pobox.com>
List: tech-kern
Date: 03/02/2004 19:57:55
Are all the ports using the new gcc? If I may, I would like to use C99's
variadic macros to implement two-argument KASSERT. For example,
void __assert1(const char *, const char *, int, const char *)
__attribute__((__noreturn__));
void __assert(const char *, const char *, int, const char *, ...)
__attribute__((__noreturn__));
#define KASSERT1(e) \
(__predict_true((e)) ? (void)0 : \
__assert1("diagnostic ", __FILE__, __LINE__, #e))
#define KASSERT(e, ...) \
(__predict_true((e)) ? (void)0 : \
__assert("diagnostic ", __FILE__, __LINE__, __VA_ARGS__))
Example invocation,
KASSERT(nseg <= ATH_MAX_SCATTER,
"ath_mbuf_load_cb: too many DMA segments %u", nseg);
Dave
--
David Young OJC Technologies
dyoung@ojctech.com Urbana, IL * (217) 278-3933