From patchwork Tue Dec 11 19:26:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Martin X-Patchwork-Id: 10724551 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 24B6C159A for ; Tue, 11 Dec 2018 19:27:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 160501FFFF for ; Tue, 11 Dec 2018 19:27:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A138284B3; Tue, 11 Dec 2018 19:27:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 970101FFFF for ; Tue, 11 Dec 2018 19:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=vYpINHXNxlnZa47u+dZFkQb3ovijKYAedp/J0DeDDJ4=; b=jP++e1O8UHvZ3vfG++BzkyYENo z1//8og9UsuRTmCGcpn4WwsIXswtWfI1zTYTdqfphH8lIle4+6bU3e+aD3UmwNWl3+3TJR+eKemHI 8E9z51+bPVHpsgBWufzbOURYjEt+cqMAQK7wlngpuskfAvUAqooPQ9m74Bz8oPce9EKVhdAVbIoZL rl8Qa/T8dX0dolb4cRUWrbrdOE7ItMbG3ooKhOPnajfE/qsVW4GsFAuMKf3ygG8eTWrUJmyY6wZmz 9rFuh/PmIj+4C43lUxVAMlhvFfozYOlyxjinSbegaKi7zEoy9YBgxK0qdYEO16KKS4DBUPQw2XdYE P1dlERBQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWngs-0005x3-BL; Tue, 11 Dec 2018 19:27:34 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gWngN-0005SB-8Z for linux-arm-kernel@lists.infradead.org; Tue, 11 Dec 2018 19:27:06 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3878215AB; Tue, 11 Dec 2018 11:26:54 -0800 (PST) Received: from e103592.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 292D53F6A8; Tue, 11 Dec 2018 11:26:53 -0800 (PST) From: Dave Martin To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/3] kbuild: install_headers.sh: Strip _UAPI from #if-defined() guards Date: Tue, 11 Dec 2018 19:26:45 +0000 Message-Id: <1544556407-19897-2-git-send-email-Dave.Martin@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1544556407-19897-1-git-send-email-Dave.Martin@arm.com> References: <1544556407-19897-1-git-send-email-Dave.Martin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181211_112703_371747_EF1C659D X-CRM114-Status: GOOD ( 12.24 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Szabolcs Nagy , Will Deacon , linux-kernel@vger.kernel.org, Alan Hayward MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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"