Skip to contentSkip to conversation

headers_install.sh: Support __aligned(x) for uAPI headers

PATCH RESEND In review Sakari Ailus 2 participants 5 messages Feb 21, 2019 – Mar 6, 2019

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 headers_install.sh: Support __aligned(x) for uAPI headers

The headers-install.sh already supports __packed conversion to __attribute__((packed)) for uAPI headers but it does not support similar __aligned(x) conversion.

Add support for __aligned(x).

---
 scripts/headers_install.sh | 1 +
 1 file changed, 1 insertion(+)
scripts/headers_install.sh +1 -0
index 593f8879c641..9ed490f33a3a 100755
@@ -36,6 +36,7 @@ do
 		-e 's/__attribute_const__([[:space:]]|$)/\1/g' \
 		-e 's@^#include <linux/compiler(|_types).h>@@' \
 		-e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
+		-e 's/(^|[^a-zA-Z0-9])__aligned(\([0-9 ]*\))([^a-zA-Z0-9_]|$)/\1__attribute__((aligned\2))\3/g' \
 		-e 's/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g' \
 		-e 's@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @' \
 		"$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1
Signature · 1 line
2.11.0
#1 lore raw
Quoted 6 lines · Sakari Ailus

The headers-install.sh already supports __packed conversion to __attribute__((packed)) for uAPI headers but it does not support similar __aligned(x) conversion.

Add support for __aligned(x).

I am not a big fan of sed scripting in headers_install.sh

Is it a problem to write __attribute__((aligned(x)) in UAPI headers?

Quoted 20 lines
---
 scripts/headers_install.sh | 1 +
 1 file changed, 1 insertion(+)
scripts/headers_install.sh +1 -1
index 593f8879c641..9ed490f33a3a 100755
@@ -36,6 +36,7 @@ do
                -e 's/__attribute_const__([[:space:]]|$)/\1/g' \
                -e 's@^#include <linux/compiler(|_types).h>@@' \
                -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
+               -e 's/(^|[^a-zA-Z0-9])__aligned(\([0-9 ]*\))([^a-zA-Z0-9_]|$)/\1__attribute__((aligned\2))\3/g' \
                -e 's/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g' \
                -e 's@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @' \
                "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1
--

2.11.0

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw

Hi Yamada-san,

Quoted 7 lines · Masahiro Yamada
Quoted 5 lines · Sakari Ailus

The headers-install.sh already supports __packed conversion to __attribute__((packed)) for uAPI headers but it does not support similar __aligned(x) conversion.

Quoted 6 lines
Quoted 1 line

Add support for __aligned(x).

I am not a big fan of sed scripting in headers_install.sh

Is it a problem to write __attribute__((aligned(x)) in UAPI headers?

Not really as such. __packed is supported in uAPI headers so I thought __aligned should probably be as well. One factor here would seem to be that __packed is way more common than __aligned is.

FWIW, a corresponding change has been done to scripts/kernel-doc; see commit 3d9bfb19bd705f503ac7afc2776d5d56dab88858 so kerneldoc does correctly handle that now.

Cc Jonathan.

Quoted 28 lines
Quoted 23 lines
---
 scripts/headers_install.sh | 1 +
 1 file changed, 1 insertion(+)
scripts/headers_install.sh +1 -1
index 593f8879c641..9ed490f33a3a 100755
@@ -36,6 +36,7 @@ do
                -e 's/__attribute_const__([[:space:]]|$)/\1/g' \
                -e 's@^#include <linux/compiler(|_types).h>@@' \
                -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
+               -e 's/(^|[^a-zA-Z0-9])__aligned(\([0-9 ]*\))([^a-zA-Z0-9_]|$)/\1__attribute__((aligned\2))\3/g' \
                -e 's/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g' \
                -e 's@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @' \
                "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1
--

2.11.0

Signature · 2 lines
Best Regards
Masahiro Yamada
Signature · 2 lines
Sakari Ailus
[email protected]
#3 lore raw
Quoted 18 lines · Sakari Ailus

Hi Yamada-san,

Quoted 7 lines · Masahiro Yamada
Quoted 5 lines · Sakari Ailus

The headers-install.sh already supports __packed conversion to __attribute__((packed)) for uAPI headers but it does not support similar __aligned(x) conversion.

Quoted 6 lines
Quoted 1 line

Add support for __aligned(x).

I am not a big fan of sed scripting in headers_install.sh

Is it a problem to write __attribute__((aligned(x)) in UAPI headers?

Quoted 7 lines

Not really as such. __packed is supported in uAPI headers so I thought __aligned should probably be as well. One factor here would seem to be that __packed is way more common than __aligned is.

FWIW, a corresponding change has been done to scripts/kernel-doc; see commit 3d9bfb19bd705f503ac7afc2776d5d56dab88858 so kerneldoc does correctly handle that now.

I am fine with using __aligned(x) shorthand for kernel-space code.

For UAPI headers, we get it back to __attribute__(aligned(x)) anyway, and I'd like to minimize the complex text processing.

Since __aligned(x) takes an argument,
this is not feasible to process it by sed.

For example, please see
include/uapi/linux/netfilter_bridge/ebtables.h

If

__attribute__ ((aligned (__alignof__(struct ebt_replace))));

is converted into

__aligned(__alignof__(struct ebt_replace))

it would be difficult to revert it by sed

Quoted 31 lines

Cc Jonathan.

Quoted 20 lines
Quoted 20 lines
---
 scripts/headers_install.sh | 1 +
 1 file changed, 1 insertion(+)
scripts/headers_install.sh +1 -0
index 593f8879c641..9ed490f33a3a 100755
@@ -36,6 +36,7 @@ do
                -e 's/__attribute_const__([[:space:]]|$)/\1/g' \
                -e 's@^#include <linux/compiler(|_types).h>@@' \
                -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
+               -e 's/(^|[^a-zA-Z0-9])__aligned(\([0-9 ]*\))([^a-zA-Z0-9_]|$)/\1__attribute__((aligned\2))\3/g' \
                -e 's/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g' \
                -e 's@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @' \
                "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1
Quoted 8 lines
Quoted 3 lines

--
2.11.0

--
Best Regards
Masahiro Yamada

Quoted 3 lines

--
Sakari Ailus
[email protected]

--
Best Regards
Masahiro Yamada

#4 lore raw
Quoted 45 lines · Masahiro Yamada
Quoted 18 lines · Sakari Ailus

Hi Yamada-san,

Quoted 7 lines · Masahiro Yamada
Quoted 5 lines · Sakari Ailus

The headers-install.sh already supports __packed conversion to __attribute__((packed)) for uAPI headers but it does not support similar __aligned(x) conversion.

Quoted 6 lines
Quoted 1 line

Add support for __aligned(x).

I am not a big fan of sed scripting in headers_install.sh

Is it a problem to write __attribute__((aligned(x)) in UAPI headers?

Quoted 7 lines

Not really as such. __packed is supported in uAPI headers so I thought __aligned should probably be as well. One factor here would seem to be that __packed is way more common than __aligned is.

FWIW, a corresponding change has been done to scripts/kernel-doc; see commit 3d9bfb19bd705f503ac7afc2776d5d56dab88858 so kerneldoc does correctly handle that now.

I am fine with using __aligned(x) shorthand for kernel-space code.

For UAPI headers, we get it back to __attribute__(aligned(x)) anyway, and I'd like to minimize the complex text processing.

Since __aligned(x) takes an argument,
this is not feasible to process it by sed.

For example, please see
include/uapi/linux/netfilter_bridge/ebtables.h

If

Quoted 8 lines

__attribute__ ((aligned (__alignof__(struct ebt_replace))));

is converted into

__aligned(__alignof__(struct ebt_replace))

it would be difficult to revert it by sed

Fair enough. Sed doesn't really bend for that too well indeed. I can submit a patch to remove the similar conversion from the kernel-doc as well based on this discussion.

Signature · 2 lines
Sakari Ailus
[email protected]