Index: sys/cdefs.h =================================================================== RCS file: /home/apb/netbsd/REPO/cvsmirror/cvsroot/src/sys/sys/cdefs.h,v retrieving revision 1.113 diff -d -p -u -r1.113 cdefs.h --- sys/cdefs.h 16 Oct 2013 19:31:43 -0000 1.113 +++ sys/cdefs.h 24 Oct 2013 15:10:15 -0000 @@ -250,18 +250,65 @@ #define __noclone /* nothing */ #endif +/* + * __unused: Note that variable might be unused. + * Do not warn if variable is unused. + */ #if __GNUC_PREREQ__(2, 7) #define __unused __attribute__((__unused__)) #else #define __unused /* delete */ #endif +/* + * __used: Note that variable is needed, even if it appears to be unused. + * Valid only for static variables. Do not optimise variable away. + * Do not warn if variable is unused. + */ #if __GNUC_PREREQ__(3, 1) #define __used __attribute__((__used__)) #else #define __used __unused #endif +/* + * __diagused: Note that variable is used in diagnostic code, but may be + * unused in non-diagnostic code. + * + * In the kernel, variables that are used when DIAGNOSTIC is defined, + * but unused when DIAGNOSTIC is not defined, may be declared with + * __diagused. In userland, variables that are used when NDEBUG is not + * defined, but unused when NDEBUG is defined, may be declared with + * __diagused. + * + * Variables used only in assert(3) or KASSERT(9) macros are likely + * candidates for being declared with __diagused. + */ +#if (defined(_KERNEL) && defined(DIAGNOSTIC)) \ + || (!defined(_KERNEL) && !defined(NDEBUG)) +#define __diagused /* empty */ +#else +#define __diagused __unused +#endif + +/* + * __debugused: Note that variable is used in debug code, but may be + * unused in non-debug code. + * + * In either the kernel or userland, variables that are used when DEBUG + * is defined, but unused when DEBUG is not defined, may be marked with + * __debugused. + * + * In the kernel, variables used only in KDASSERT(9) macros are likely + * candidates for being declared with __debugused. There is no + * established convention for the use of DEBUG in userland code. + */ +#if defined(DEBUG) +#define __debugused /* empty */ +#else +#define __debugused __unused +#endif + #if __GNUC_PREREQ__(3, 1) #define __noprofile __attribute__((__no_instrument_function__)) #else