git: <sys/malloc.h>: Avoid self referencing macros.
zrj at crater.dragonflybsd.org
Sat Nov 2 15:47:55 PDT 2019
Author: zrj <rimvydas.jasinskas at gmail.com>
Date: Fri Oct 25 21:05:10 2019 +0300
<sys/malloc.h>: Avoid self referencing macros.
It was reported that previous kmalloc() implementation at header level
is breaking tools like Coccinelle and likely others. Since this header
now has implicit requirement on other headers only for using the
MALLOC_DEFINE() macro (<sys/kernel.h> must be included before), it is
possible to safely use inline functions. Inline function does not have
flexibility limitations like preprocessor macro and expands to much
nicer line in compiler intermediates while allowing to easily make
future adjustments when needed. Also we should be able to no longer
avoid using kmalloc*() calls directly in other kernel headers.
The LINT64 builds with SLAB_DEBUG option enabled are not affected by
this change, but for consistency add alias for _kmalloc() too.
Move in the "#if 1" into the _kmalloc() body, this allows compiler to
perform additional optimizations for non __builtin_constant_p() cases.
As a benefit if during compilation the -O0 is used, compiler disables
optimized paths in inline functions.
Compared with -save-temps on GENERIC without debug enabled.
Summary of changes:
sys/sys/malloc.h | 39 +++++++++++++++++++++------------------
1 file changed, 21 insertions(+), 18 deletions(-)
DragonFly BSD source repository
More information about the Commits