[PATCH] modutils: fix config options dependency (2)

Kang-Che Sung explorer09 at gmail.com
Tue Feb 7 03:38:23 UTC 2017


On Tue, Feb 7, 2017 at 4:56 AM, Denys Vlasenko <vda.linux at googlemail.com> wrote:
> On Mon, Feb 6, 2017 at 4:38 AM, Kang-Che Sung <explorer09 at gmail.com> wrote:
>> Thank you, but I hope you understand why I propose the not-so-simple route in
>> the patch. Especially regarding the use of is_depmod_or_modprobe macro.
>
> Not really. If you would explain it, it might increase chances of it
> being accepted. Since I had to guess, I guessed "it probably saves a few bytes
> of code at the cost of many more #ifdefs.

Yes, it's to save a few bytes in the generated machine code.
(Although I think of this later I might be putting to many #ifdefs
than necessary.)

Here this is sufficient:

    #define is_depmod_or_modprobe \
    ((ENABLE_MODPROBE || ENABLE_DEPMOD) \
    && ((!ENABLE_INSMOD && !ENABLE_RMMOD) \
    || (!ENABLE_MODPROBE && is_depmod) \
    || ((applet_name[0] & '\x04') != 0)))

With comments:

    #define is_depmod_or_modprobe \
    /* If neither modprobe or depmod are configured, false */ \
    ((ENABLE_MODPROBE || ENABLE_DEPMOD) \
    /* If there's nothing but modprobe or depmod, true */ \
    && ((!ENABLE_INSMOD && !ENABLE_RMMOD) \
    /* This helps compiler to merge the block with is_depmod one below */ \
    || (!ENABLE_MODPROBE && is_depmod) \
    /* Otherwise determine 'd' or 'm' using ASCII and bitwise trick */ \
    /* ("and" and "je" in x86/x64, same size as "cmp" and "je" in binary; */
    /* it's smaller than two "cmp"s and "je"s) */ \
    || ((applet_name[0] & '\x4') != 0)))


More information about the busybox mailing list