ATTRIBUTE(3) | Library Functions Manual | ATTRIBUTE(3) |
__dead
__pure
__constfunc
__noinline
__unused
__used
__diagused
__debugused
__packed
__aligned(x);
__section(section);
__read_mostly
__cacheline_aligned
__predict_true(exp);
__predict_false(exp);
NetBSD code should usually avoid direct use of the __attribute__ or similar syntax provided by specific compilers. Instead, NetBSD's <sys/cdefs.h> header file provides several attribute macros in a namespace reserved for the implementation (beginning with ‘__
’), that expand to the appropriate syntax for the compiler that is in use.
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.
In either the kernel or userland, variables that are used when DEBUG is defined, but unused when DEBUG is not defined, may be declared 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.
Note that when used with functions, structures, or structure members, __aligned() can only be used to increase the alignment. If the macro is however used as part of a typedef, the alignment can both increase and decrease. Otherwise it is only possible to decrease the alignment for variables and fields by using the __packed macro. The effectiveness of __aligned() is largely dependent on the linker. The __alignof__(3) operator can be used to examine the alignment.
The macros __predict_true() and __predict_false() annotate the likelihood of whether a branch will evaluate to true or false. The rationale is to improve instruction pipelining. Semantically __predict_true expects that the integral expression exp yields nonzero.
October 25, 2013 | NetBSD 7.2 |