qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH] docs: add some details about compilation units to coding


From: Alessandro Di Federico
Subject: Re: [RFC PATCH] docs: add some details about compilation units to coding style
Date: Tue, 3 Jan 2023 16:35:42 +0100

Makes sense to me.

Reviewed-by: Alessandro Di Federico <ale@rev.ng>

On Tue,  3 Jan 2023 10:47:58 +0000
Alex Bennée <alex.bennee@linaro.org> wrote:

> +"Templates" and generated code
> +==============================
> +
> +We make heavy use of C's macro facilities combined with multiple
> +inclusion to generate code. This tends to use header files (usually
> +with the .inc suffix) with different #define'd constants. While the
> +use of C11's _Generic keyword has improved things a bit this
> technique +is still best suited to repetitive boiler plate code. If
> more complex +code generation is required consider using a script to
> generate it, +see for example the decodetree and qapi header scripts.

Consider adding reference to an example to make the situation more
explicit and less scary.

Here's an example that hopefully won't become outdated within yesterday:

    $ git grep -B10 '#include.*\.inc'
    fpu/softfloat.c-#define N 64
    fpu/softfloat.c-#define W 128
    fpu/softfloat.c-
    fpu/softfloat.c:#include "softfloat-parts-addsub.c.inc"
    fpu/softfloat.c:#include "softfloat-parts.c.inc"
    fpu/softfloat.c-
    fpu/softfloat.c-#undef  N
    fpu/softfloat.c-#undef  W
    fpu/softfloat.c-#define N 128
    fpu/softfloat.c-#define W 256
    fpu/softfloat.c-
    fpu/softfloat.c:#include "softfloat-parts-addsub.c.inc"
    fpu/softfloat.c:#include "softfloat-parts.c.inc"

-- 
Alessandro Di Federico
rev.ng Labs



reply via email to

[Prev in Thread] Current Thread [Next in Thread]