|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2] xen: Use auto as per C23
On 2025-08-15 00:25, Andrew Cooper wrote: In macros it is common to declare local variables using typeof(param) in order to ensure that side effects are only evaluated once. A consequence of this is double textural expansion of the parameter, which can get out of hand veryquickly with nested macros. In C23, the auto keyword has been repurposed to perform type inference.A GCC extension, __auto_type, is now avaialble in the new toolchain baselineand avoids the double textural expansion. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Reviewed-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx> with a nit below: --- CC: Anthony PERARD <anthony.perard@xxxxxxxxxx> CC: Michal Orzel <michal.orzel@xxxxxxx> CC: Jan Beulich <jbeulich@xxxxxxxx> CC: Julien Grall <julien@xxxxxxx> CC: Roger Pau Monné <roger.pau@xxxxxxxxxx> CC: Stefano Stabellini <sstabellini@xxxxxxxxxx> CC: Roberto Bagnara <roberto.bagnara@xxxxxxxxxxx> CC: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx> CC: consulting@xxxxxxxxxxx <consulting@xxxxxxxxxxx> The resulting build is identical. v2: * Use auto directly * Eclair configuration https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1985289434 --- automation/eclair_analysis/ECLAIR/toolchain.ecl | 11 +++++++++-- docs/misra/C-language-toolchain.rst | 2 ++ xen/include/xen/compiler.h | 14 ++++++++++++++ xen/include/xen/macros.h | 14 +++++++------- 4 files changed, 32 insertions(+), 9 deletions(-)diff --git a/automation/eclair_analysis/ECLAIR/toolchain.ecl b/automation/eclair_analysis/ECLAIR/toolchain.eclindex 842f8377e561..125f99a06583 100644 --- a/automation/eclair_analysis/ECLAIR/toolchain.ecl +++ b/automation/eclair_analysis/ECLAIR/toolchain.ecl @@ -15,6 +15,7 @@__alignof__, __alignof: see Sections \"6.48 Alternate Keywords\" and \"6.44 Determining the Alignment of Functions, Types or Variables\" of "GCC_MANUAL". asm, __asm__: see Sections \"6.48 Alternate Keywords\" and \"6.47 How to Use Inline Assembly Language in C Code\" of "GCC_MANUAL". __attribute__: see Section \"6.39 Attribute Syntax\" of "GCC_MANUAL". + __auto_type: see Section \"6.7 Referring to a Type with typeof\" of "GCC_MANUAL". __builtin_offsetof: see Section \"6.53 Support for offsetof\" of "GCC_MANUAL". __builtin_types_compatible_p: see Section \"6.59 Other Built-in Functions Provided by GCC\" of "GCC_MANUAL". A more detailed explanation should live in deviations.rst under this bullet point * - R20.4- The override of the keyword \"inline\" in xen/compiler.h is present so that section contents checks pass when the compiler chooses not to
inline a particular function.
- Comment-based deviation.
as described in the SAF entry:
{
"id": "SAF-3-safe",
"analyser": {
"eclair": "MC3A2.R20.4"
},
"name": "MC3A2.R20.4: allow the definition of a macro with
the same name as a keyword in some special cases",
"text": "The definition of a macro with the same name as a
keyword can be useful in certain configurations to improve the
guarantees that can be provided by Xen. See docs/misra/deviations.rst
for a precise rationale for all such cases."
},
-- Nicola Vetrini, B.Sc. Software Engineer BUGSENG (https://bugseng.com) LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |