tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Convenience macros to help linting the kernel



On Sun, Jul 20, 2008 at 06:46:50AM +0400, Valeriy E. Ushakov wrote:
 > PS: I would dearly love a variadic __USED(), so that instead of 
 > 
 > #define KERNEL_UNLOCK(all, lwp, ptr)                 \
 >      do {                                            \
 >              __USED(all); __USED(lwp); __USED(ptr);  \
 >      } while (/* CONSTCOND */ 0)
 > 
 > one could write just
 > 
 > #define KERNEL_UNLOCK(all, lwp, ptr) __USED(all, lwp, ptr)
 > 
 > but as far as I can tell it's impossible to write.

Never say impossible :-)

static __inline void __use(int x, ...) { /* LINTED */ (void)x; }
#define __USED(...) __use(0, __VA_ARGS__);

works with both lint and gcc, and doesn't generate any code with -O
and higher, either.

However, we already have a different form of __unused in cdefs.h...

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index