All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Martin <Dave.Martin@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, Will Deacon <will.deacon@arm.com>,
	Alan Hayward <alan.hayward@arm.com>,
	Szabolcs Nagy <szabolcs.nagy@arm.com>
Subject: [PATCH 1/3] kbuild: install_headers.sh: Strip _UAPI from #if-defined() guards
Date: Tue, 11 Dec 2018 19:26:45 +0000	[thread overview]
Message-ID: <1544556407-19897-2-git-send-email-Dave.Martin@arm.com> (raw)
In-Reply-To: <1544556407-19897-1-git-send-email-Dave.Martin@arm.com>

install_headers.sh knows how to strip the _UAPI prefix from #ifdef/
ifndef and #define directives used to guard headers against multiple
or inappropriate inclusion.  Currently this does not work for guards
in the "#if defined()" style, which may be needed for non-trivial
cases.

This patch adds similar logic so that the _UAPI prefix is also
stripped from guard directives written using "#if defined()" etc.

This is not completely foolproof, but will work for simple cases of
using #if defined() to guard against inappropriate header inclusion.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
---
 scripts/headers_install.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
index 593f8879..fe1d3fc 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -38,6 +38,7 @@ do
 		-e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
 		-e 's/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g' \
 		-e 's@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @' \
+		-e ':1;s/(#(if|elif)(.*[^A-Za-z0-9_])defined\([[:space:]]*)_UAPI/\1/;t1' \
 		"$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1
 	scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \
 		> "$OUTDIR/$FILE"
-- 
2.1.4


WARNING: multiple messages have this Message-ID (diff)
From: Dave Martin <Dave.Martin@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: Szabolcs Nagy <szabolcs.nagy@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	linux-kernel@vger.kernel.org, Alan Hayward <alan.hayward@arm.com>
Subject: [PATCH 1/3] kbuild: install_headers.sh: Strip _UAPI from #if-defined() guards
Date: Tue, 11 Dec 2018 19:26:45 +0000	[thread overview]
Message-ID: <1544556407-19897-2-git-send-email-Dave.Martin@arm.com> (raw)
In-Reply-To: <1544556407-19897-1-git-send-email-Dave.Martin@arm.com>

install_headers.sh knows how to strip the _UAPI prefix from #ifdef/
ifndef and #define directives used to guard headers against multiple
or inappropriate inclusion.  Currently this does not work for guards
in the "#if defined()" style, which may be needed for non-trivial
cases.

This patch adds similar logic so that the _UAPI prefix is also
stripped from guard directives written using "#if defined()" etc.

This is not completely foolproof, but will work for simple cases of
using #if defined() to guard against inappropriate header inclusion.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
---
 scripts/headers_install.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
index 593f8879..fe1d3fc 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -38,6 +38,7 @@ do
 		-e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
 		-e 's/(^|[[:space:](])(inline|asm|volatile)([[:space:](]|$)/\1__\2__\3/g' \
 		-e 's@#(ifndef|define|endif[[:space:]]*/[*])[[:space:]]*_UAPI@#\1 @' \
+		-e ':1;s/(#(if|elif)(.*[^A-Za-z0-9_])defined\([[:space:]]*)_UAPI/\1/;t1' \
 		"$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1
 	scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \
 		> "$OUTDIR/$FILE"
-- 
2.1.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2018-12-11 19:26 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11 19:26 [PATCH 0/3] arm64/sve: UAPI: Disentangle ptrace.h from sigcontext.h Dave Martin
2018-12-11 19:26 ` Dave Martin
2018-12-11 19:26 ` Dave Martin [this message]
2018-12-11 19:26   ` [PATCH 1/3] kbuild: install_headers.sh: Strip _UAPI from #if-defined() guards Dave Martin
2018-12-11 19:26 ` [PATCH 2/3] arm64/sve: ptrace: Fix SVE_PT_REGS_OFFSET definition Dave Martin
2018-12-11 19:26   ` Dave Martin
2018-12-11 19:26 ` [PATCH 3/3] arm64/sve: Disentangle <uapi/asm/ptrace.h> from <uapi/asm/sigcontext.h> Dave Martin
2018-12-11 19:26   ` Dave Martin
2018-12-15  9:20   ` kbuild test robot
2018-12-15  9:20     ` kbuild test robot
2018-12-18 12:14     ` Dave Martin
2018-12-18 12:14       ` Dave Martin
2018-12-19 15:11       ` Szabolcs Nagy
2018-12-19 15:11         ` Szabolcs Nagy
2018-12-19 15:23         ` Dave Martin
2018-12-19 15:23           ` Dave Martin
2018-12-19 15:26           ` Szabolcs Nagy
2018-12-19 15:26             ` Szabolcs Nagy
2018-12-14 18:13 ` [PATCH 0/3] arm64/sve: UAPI: Disentangle ptrace.h from sigcontext.h Szabolcs Nagy
2018-12-14 18:13   ` Szabolcs Nagy
2018-12-14 18:25   ` Dave Martin
2018-12-14 18:25     ` Dave Martin
2018-12-14 19:00     ` Szabolcs Nagy
2018-12-14 19:00       ` Szabolcs Nagy
2018-12-14 19:28       ` Dave P Martin
2018-12-14 19:28         ` Dave P Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1544556407-19897-2-git-send-email-Dave.Martin@arm.com \
    --to=dave.martin@arm.com \
    --cc=alan.hayward@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=szabolcs.nagy@arm.com \
    --cc=will.deacon@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.