• Paul Mackerras's avatar
    [PATCH] Move BUG/BUG_ON/WARN_ON to asm headers · f822f151
    Paul Mackerras authored
    This patch moves the definitions of BUG, BUG_ON and WARN_ON from
    <linux/kernel.h> to <asm/bug.h> (which <linux/kernel.h> includes), and
    supplies a new implementation for PPC which uses a conditional trap
    instruction for BUG_ON and WARN_ON, thus avoiding a conditional
    branch.  This patch trims over 50kB from the size of the kernel that I
    use on powermacs.
    
    With this patch, on PPC we have a __bug_table section in the vmlinux
    binary, and also in modules if they use BUG, BUG_ON or WARN_ON.  The
    __bug_table section has one entry for each BUG/BUG_ON/WARN_ON, giving
    the address of the trap instruction and the corresponding line number,
    filename and function name.  This information is used in the exception
    handler for the exception that the trap instruction produces.  The
    arch-specific module code handles the __bug_table section so that
    BUG/BUG_ON/WARN_ON work correctly in modules.
    
    Several architecture maintainers have acked this change.  It should be
    completely benign for all of the other architectures (though they may
    decide to do something similar if they have a conditional trap
    instruction available).
    f822f151
bug.h 801 Bytes