diff mbox series

[2/6] scripts/update-linux-headers: Handle __aligned_u64

Message ID 20180525132755.21839-3-peter.maydell@linaro.org
State Superseded
Headers show
Series Update Linux headers to 4.17-rc6 | expand

Commit Message

Peter Maydell May 25, 2018, 1:27 p.m. UTC
We'll currently replace any 'u64' with a 'uint64_t' including when
it's embedded in an '__aligned_u64', creating a '__aligned_uint64_t'
which doesn't exist. We need to instead expand out the kernel's
definition of __aligned_u64:
   #define __aligned_u64 __u64 __attribute__((aligned(8)))
before we convert the __u64 to uint64_t.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
 scripts/update-linux-headers.sh | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.17.0

Comments

Richard Henderson May 25, 2018, 2:55 p.m. UTC | #1
On 05/25/2018 06:27 AM, Peter Maydell wrote:
> We'll currently replace any 'u64' with a 'uint64_t' including when

> it's embedded in an '__aligned_u64', creating a '__aligned_uint64_t'

> which doesn't exist. We need to instead expand out the kernel's

> definition of __aligned_u64:

>    #define __aligned_u64 __u64 __attribute__((aligned(8)))

> before we convert the __u64 to uint64_t.


Wow.  I did not believe that would work.  I expected that you'd need to define
a typedef, or somehow sort the attribute after the identifier to which it applies.

However

typedef unsigned long uint64_t;
uint64_t __attribute__((aligned(16))) a;
struct bar { uint64_t __attribute__((aligned(16))) foo; } b;

produces the expected alignments with both gcc(8) and clang(6).

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>



r~
Peter Maydell May 25, 2018, 2:59 p.m. UTC | #2
On 25 May 2018 at 15:55, Richard Henderson <richard.henderson@linaro.org> wrote:
> On 05/25/2018 06:27 AM, Peter Maydell wrote:

>> We'll currently replace any 'u64' with a 'uint64_t' including when

>> it's embedded in an '__aligned_u64', creating a '__aligned_uint64_t'

>> which doesn't exist. We need to instead expand out the kernel's

>> definition of __aligned_u64:

>>    #define __aligned_u64 __u64 __attribute__((aligned(8)))

>> before we convert the __u64 to uint64_t.

>

> Wow.  I did not believe that would work.  I expected that you'd need to define

> a typedef, or somehow sort the attribute after the identifier to which it applies.


In the kernel it's a #define, not a typedef, so logically if the
kernel compiles then doing the textual-substitution here with sed
must also work...

thanks
-- PMM
diff mbox series

Patch

diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers.sh
index 947dec2852..1fe54f8ab1 100755
--- a/scripts/update-linux-headers.sh
+++ b/scripts/update-linux-headers.sh
@@ -51,7 +51,8 @@  cp_portable() {
     fi
 
     header=$(basename "$f");
-    sed -e 's/__u\([0-9][0-9]*\)/uint\1_t/g' \
+    sed -e 's/__aligned_u64/__u64 __attribute__((aligned(8)))/g' \
+        -e 's/__u\([0-9][0-9]*\)/uint\1_t/g' \
         -e 's/u\([0-9][0-9]*\)/uint\1_t/g' \
         -e 's/__s\([0-9][0-9]*\)/int\1_t/g' \
         -e 's/__le\([0-9][0-9]*\)/uint\1_t/g' \