From e0efe1234cd039fb8fc6b52737fe8a116a40fb56 Mon Sep 17 00:00:00 2001
From: Andre Maroneze <andre.maroneze@cea.fr>
Date: Fri, 3 Jan 2025 17:22:53 +0100
Subject: [PATCH] [Kernel] avoid anonymous struct in machdep

Creating an anonymous struct in the machdep causes an indexing shift for
user-created anonymous structures.
---
 share/machdeps/machdep_avr_16.yaml           |  2 +-
 share/machdeps/machdep_avr_8.yaml            |  2 +-
 share/machdeps/machdep_gcc_x86_16.yaml       |  2 +-
 share/machdeps/machdep_gcc_x86_32.yaml       |  2 +-
 share/machdeps/machdep_x86_16.yaml           |  2 +-
 share/machdeps/machdep_x86_32.yaml           |  2 +-
 tests/syntax/oracle/gnu-asm-aesni.res.oracle | 16 ++++++++--------
 7 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/share/machdeps/machdep_avr_16.yaml b/share/machdeps/machdep_avr_16.yaml
index a5dea0d38f5..4094f23beb8 100644
--- a/share/machdeps/machdep_avr_16.yaml
+++ b/share/machdeps/machdep_avr_16.yaml
@@ -9,7 +9,7 @@ alignof_longlong: 1
 alignof_ptr: 1
 alignof_short: 2
 alignof_str: 1
-max_align_t: struct {int __max_align; } __attribute__ ((aligned (8)))
+max_align_t: struct __machdep_max_align_t { int __max_align; } __attribute__ ((aligned (8)))
 bufsiz: '1024'
 char_is_unsigned: false
 compiler: clang
diff --git a/share/machdeps/machdep_avr_8.yaml b/share/machdeps/machdep_avr_8.yaml
index 3f47f1b4fed..b798abd3b56 100644
--- a/share/machdeps/machdep_avr_8.yaml
+++ b/share/machdeps/machdep_avr_8.yaml
@@ -9,7 +9,7 @@ alignof_longlong: 1
 alignof_ptr: 1
 alignof_short: 2
 alignof_str: 1
-max_align_t: struct {int __max_align; } __attribute__ ((aligned (8)))
+max_align_t: struct __machdep_max_align_t { int __max_align; } __attribute__ ((aligned (8)))
 bufsiz: '1024'
 char_is_unsigned: false
 compiler: clang
diff --git a/share/machdeps/machdep_gcc_x86_16.yaml b/share/machdeps/machdep_gcc_x86_16.yaml
index 8618911f857..40306e9461b 100644
--- a/share/machdeps/machdep_gcc_x86_16.yaml
+++ b/share/machdeps/machdep_gcc_x86_16.yaml
@@ -9,7 +9,7 @@ alignof_longlong: 4
 alignof_ptr: 4
 alignof_short: 2
 alignof_str: 1
-max_align_t: struct {int __max_align; } __attribute__ ((aligned (16)))
+max_align_t: struct __machdep_max_align_t { int __max_align; } __attribute__ ((aligned (16)))
 char_is_unsigned: false
 compiler: gcc
 cpp_arch_flags:
diff --git a/share/machdeps/machdep_gcc_x86_32.yaml b/share/machdeps/machdep_gcc_x86_32.yaml
index 68676919953..1dadf4216ec 100644
--- a/share/machdeps/machdep_gcc_x86_32.yaml
+++ b/share/machdeps/machdep_gcc_x86_32.yaml
@@ -9,7 +9,7 @@ alignof_longlong: 4
 alignof_ptr: 4
 alignof_short: 2
 alignof_str: 1
-max_align_t: struct {int __max_align; } __attribute__ ((aligned (16)))
+max_align_t: struct __machdep_max_align_t { int __max_align; } __attribute__ ((aligned (16)))
 bufsiz: '8192'
 char_is_unsigned: false
 compiler: gcc
diff --git a/share/machdeps/machdep_x86_16.yaml b/share/machdeps/machdep_x86_16.yaml
index 6a11b922978..cb1853dc8aa 100644
--- a/share/machdeps/machdep_x86_16.yaml
+++ b/share/machdeps/machdep_x86_16.yaml
@@ -9,7 +9,7 @@ alignof_longlong: 4
 alignof_ptr: 4
 alignof_short: 2
 alignof_str: 1
-max_align_t: struct {int __max_align; } __attribute__ ((aligned (16)))
+max_align_t: struct __machdep_max_align_t { int __max_align; } __attribute__ ((aligned (16)))
 char_is_unsigned: false
 compiler: generic
 cpp_arch_flags:
diff --git a/share/machdeps/machdep_x86_32.yaml b/share/machdeps/machdep_x86_32.yaml
index cecfb10922e..78c08d4bea0 100644
--- a/share/machdeps/machdep_x86_32.yaml
+++ b/share/machdeps/machdep_x86_32.yaml
@@ -9,7 +9,7 @@ alignof_longlong: 4
 alignof_ptr: 4
 alignof_short: 2
 alignof_str: 1
-max_align_t: struct {int __max_align; } __attribute__ ((aligned (16)))
+max_align_t: struct __machdep_max_align_t { int __max_align; } __attribute__ ((aligned (16)))
 bufsiz: '8192'
 char_is_unsigned: false
 compiler: generic
diff --git a/tests/syntax/oracle/gnu-asm-aesni.res.oracle b/tests/syntax/oracle/gnu-asm-aesni.res.oracle
index 40d08601f2e..b376a0b1bd9 100644
--- a/tests/syntax/oracle/gnu-asm-aesni.res.oracle
+++ b/tests/syntax/oracle/gnu-asm-aesni.res.oracle
@@ -8,7 +8,7 @@
 #include "string.h"
 #include "strings.h"
 typedef unsigned short byte;
-union __anonunion_PROPERLY_ALIGNED_TYPE_2 {
+union __anonunion_PROPERLY_ALIGNED_TYPE_1 {
    int a ;
    short b ;
    char c[1] ;
@@ -16,23 +16,23 @@ union __anonunion_PROPERLY_ALIGNED_TYPE_2 {
    float f ;
    double g ;
 };
-typedef union __anonunion_PROPERLY_ALIGNED_TYPE_2 PROPERLY_ALIGNED_TYPE;
-union __anonunion_u1_4 {
+typedef union __anonunion_PROPERLY_ALIGNED_TYPE_1 PROPERLY_ALIGNED_TYPE;
+union __anonunion_u1_3 {
    PROPERLY_ALIGNED_TYPE dummy ;
    byte keyschedule[14 + 1][4][4] ;
 };
-union __anonunion_u2_5 {
+union __anonunion_u2_4 {
    PROPERLY_ALIGNED_TYPE dummy ;
    byte keyschedule[14 + 1][4][4] ;
 };
-struct __anonstruct_RIJNDAEL_context_3 {
-   union __anonunion_u1_4 u1 ;
-   union __anonunion_u2_5 u2 ;
+struct __anonstruct_RIJNDAEL_context_2 {
+   union __anonunion_u1_3 u1 ;
+   union __anonunion_u2_4 u2 ;
    int rounds ;
    unsigned int decryption_prepared : 1 ;
    unsigned int use_aesni : 1 ;
 };
-typedef struct __anonstruct_RIJNDAEL_context_3 RIJNDAEL_context;
+typedef struct __anonstruct_RIJNDAEL_context_2 RIJNDAEL_context;
 __inline static void do_aesni_enc(RIJNDAEL_context const *ctx,
                                   unsigned char *b, unsigned char const *a)
 {
-- 
GitLab