git: <sys/malloc.h>: Avoid self referencing macros.

Rimvydas Jasinskas zrj at crater.dragonflybsd.org
Sat Nov 2 15:47:55 PDT 2019


commit 87ae77ceaae95efa241e0df4940f000b1eca77f3
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(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/87ae77ceaae95efa241e0df4940f000b1eca77f3


-- 
DragonFly BSD source repository



More information about the Commits mailing list