lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 21 Nov 2023 09:23:08 -0800
From:   Linus Torvalds <torvalds@...ux-foundation.org>
To:     Nick Terrell <nickrterrell@...il.com>
Cc:     linux-kernel@...r.kernel.org, Yann Collet <cyan@...a.com>,
        Nick Terrell <terrelln@...a.com>,
        Kernel Team <Kernel-team@...com>,
        Giovanni Cabiddu <giovanni.cabiddu@...el.com>,
        Nick Terrell <terrelln@...com>
Subject: Re: [PATCH 2/2] zstd: Backport Huffman speed improvement from upstream

On Mon, 20 Nov 2023 at 16:52, Nick Terrell <nickrterrell@...il.com> wrote:
>
> +/* Calls X(N) for each stream 0, 1, 2, 3. */
> +#define HUF_4X_FOR_EACH_STREAM(X) \
> +    {                             \
> +        X(0)                      \
> +        X(1)                      \
> +        X(2)                      \
> +        X(3)                      \
> +    }
> +
> +/* Calls X(N, var) for each stream 0, 1, 2, 3. */
> +#define HUF_4X_FOR_EACH_STREAM_WITH_VAR(X, var) \
> +    {                                           \
> +        X(0, (var))                             \
> +        X(1, (var))                             \
> +        X(2, (var))                             \
> +        X(3, (var))                             \
> +    }
> +

What shitty compilers do you need to be compatible with?

Because at least for Linux, the above is one single #define:

    #define FOUR(X,y...) do { \
        X(0,##y); X(1,##y); X(2,##y); X(3,##y); \
    } while (0)

and it does the right thing for any number of arguments, ie

    FOUR(fn)
    FOUR(fn1,a)
    FOUR(fn2,a,b)

expands to

    do { fn(0); fn(1); fn(2); fn(3); } while (0)
    do { fn1(0,a); fn1(1,a); fn1(2,a); fn1(3,a); } while (0)
    do { fn2(0,a,b); fn2(1,a,b); fn2(2,a,b); fn2(3,a,b); } while (0)

so unless you need to support some completely garbage compiler
upstream, please just do the single #define.

               Linus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ