Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 1 | From 9ca6c6a510bda90954aa2532711200b89dd1df89 Mon Sep 17 00:00:00 2001 |
| 2 | From: Dave Martin <Dave.Martin@arm.com> |
| 3 | Date: Tue, 11 Dec 2018 19:26:45 +0000 |
| 4 | Subject: [PATCH 1/3] kbuild: install_headers.sh: Strip _UAPI from |
| 5 | #if-defined() guards |
| 6 | |
| 7 | install_headers.sh knows how to strip the _UAPI prefix from #ifdef/ |
| 8 | ifndef and #define directives used to guard headers against multiple |
| 9 | or inappropriate inclusion. Currently this does not work for guards |
| 10 | in the "#if defined()" style, which may be needed for non-trivial |
| 11 | cases. |
| 12 | |
| 13 | This patch adds similar logic so that the _UAPI prefix is also |
| 14 | stripped from guard directives written using "#if defined()" etc. |
| 15 | |
| 16 | This is not completely foolproof, but will work for simple cases of |
| 17 | using #if defined() to guard against inappropriate header inclusion. |
| 18 | |
| 19 | Signed-off-by: Dave Martin <Dave.Martin@arm.com> |
| 20 | Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com> |
| 21 | |
| 22 | Upstream-Status: Submitted [https://www.spinics.net/lists/arm-kernel/msg694800.html] |
| 23 | --- |
| 24 | scripts/headers_install.sh | 1 + |
| 25 | 1 file changed, 1 insertion(+) |
| 26 | |
| 27 | diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh |
| 28 | index 593f8879c641..fe1d3fc0d33a 100755 |
| 29 | --- a/scripts/headers_install.sh |
| 30 | +++ b/scripts/headers_install.sh |
| 31 | @@ -38,6 +38,7 @@ do |
| 32 | -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \ |
| 33 | -e 's/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g' \ |
| 34 | -e 's@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @' \ |
| 35 | + -e ':1;s/(#(if|elif)(.*[^A-Za-z0-9_])defined\([[:space:]]*)_UAPI/\1/;t1' \ |
| 36 | "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1 |
| 37 | scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \ |
| 38 | > "$OUTDIR/$FILE" |
| 39 | -- |
| 40 | 2.5.0 |
| 41 | |