From patchwork Wed Jun 1 16:59:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12867071 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 405B7C433EF for ; Wed, 1 Jun 2022 16:59:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.340582.565656 (Exim 4.92) (envelope-from ) id 1nwRgr-0000Cm-8V; Wed, 01 Jun 2022 16:59:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 340582.565656; Wed, 01 Jun 2022 16:59:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nwRgr-0000Cd-4r; Wed, 01 Jun 2022 16:59:25 +0000 Received: by outflank-mailman (input) for mailman id 340582; Wed, 01 Jun 2022 16:59:24 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nwRgp-0008OC-Qn for xen-devel@lists.xenproject.org; Wed, 01 Jun 2022 16:59:23 +0000 Received: from esa1.hc3370-68.iphmx.com (esa1.hc3370-68.iphmx.com [216.71.145.142]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2f24dd1d-e1cc-11ec-bd2c-47488cf2e6aa; Wed, 01 Jun 2022 18:59:22 +0200 (CEST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2f24dd1d-e1cc-11ec-bd2c-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1654102762; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BlbE29TWg9aEJQUORmjYM/XevnXuD7OicnrE0Ym51MU=; b=JNbjtcqWZFvy6o/cx+wxbv8WVyQvgE/078WIaH18FxC9U/VLJ6hw60nK weZaU77N+UfqGxz+TBZkyjfKPYjq8aJ5a82RQ8S2WgEDJQfrl5XGBU+u8 i+0/Zl5HmaF2TDZrUT1sIDEZXlLe6gViqjcW+DJzg8JeUYawpTV11dE6H w=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 73044234 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:4Bf/a6hDFHPz6eXK7dw3/KJQX161GBAKZh0ujC45NGQN5FlHY01je htvUGrVa/nZZWr9etwlOYi+phxUvJ7Xm9VqSAdp/ixgRCsb9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oDJ9CU6jefSLlbFILas1hpZHGeIcw98z0M68wIFqtQw24LhXVvU4 YiaT/D3YzdJ5RYlagr41IrbwP9flKyaVOQw5wFWiVhj5TcyplFNZH4tDfjZw0jQG+G4KtWSV efbpIxVy0uCl/sb5nFJpZ6gGqECaua60QFjERO6UYD66vRJjnRaPqrWqJPwwKqY4tmEt4kZ9 TlDiXC/YUB0NYTrnMUDaCdnVA1FY4ND5Of7BlHq5KR/z2WeG5ft6/BnDUVwNowE4OdnR2pJ8 JT0KhhUMErF3bjvhuvmFK883azPL+GyVG8bknhm0THeC+dgWZ3ZSr/GzdRZwC0xloZFGvO2i 88xNmE3MEiaOEEn1lE/GdFgnM63v1rFcRpWtw/L+5Y4uTSD5VkkuFTqGIWMIYHbLSlPpW6Dv X7P9Wn9BhAcNfScxCCD/3bqgfXA9QvkXKoCGbv+8eRl6HWR22gSBRs+RVa95/6jhSaWS99Zb kAZ5Ccqhawz71CwCMnwWQWip3yJtQJaXMBfe8U44gyQzqvf4y6CG3MJCDVGbbQbWNQeHGJwk AXTxpWwWGIp4Ob9pW+hGqm86m65EA8RDHE5WxBDYTBbzdz/+L0Up0eaJjp8K5JZnuEZCBmpn W3W9HRh2e5D5SIY//7lpA6a2lpAsrCMF1dovVuPAwpJ+ysjPOaYi5qUBU83BBqqBKKQVRG/s XcNgKByB8heXMjWxERhrAjgdYxFBspp0xWG2DaD57F7q1yQF4eLJOi8Gg1WKkZzKdojcjT0e kLVsg45zMYNYSfyN/UvPNzuUp1CIU3c+TPND6m8UzazSsIpKF/vEN9GPiZ8IFwBYGBzyPpia P93gO6nDGoACLQP8Qdas9w1iOdxrghnnDu7bcmik3yPjOvFDFbIGOhtDbd7Rr1ghE9yiF6No 4g32grj40g3bdASlQGNrtBDdgBRdydlbX00wuQOHtO+zsNdMDlJI5fsLXkJJ+SJQ4w9ej/0w 0yA IronPort-HdrOrdr: A9a23:Q9G4GanUo5GsybFcLBXDDE/knLfpDfIU3DAbv31ZSRFFG/Fxl6 iV8sjzsiWE7gr5OUtQ4exoV5PhfZqxz/JICMwqTNKftWrdyQyVxeNZnOjfKlTbckWUnINgPO VbAsxD4bXLfCFHZK3BgTVQfexO/DD+ytHLudvj X-IronPort-AV: E=Sophos;i="5.91,269,1647316800"; d="scan'208";a="73044234" From: Anthony PERARD To: CC: Anthony PERARD , Andrew Cooper , George Dunlap , "Jan Beulich" , Julien Grall , "Stefano Stabellini" , Wei Liu Subject: [XEN PATCH 1/4] build: xen/include: use if_changed Date: Wed, 1 Jun 2022 17:59:06 +0100 Message-ID: <20220601165909.46588-2-anthony.perard@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220601165909.46588-1-anthony.perard@citrix.com> References: <20220601165909.46588-1-anthony.perard@citrix.com> MIME-Version: 1.0 Use "define" for the headers*_chk commands as otherwise the "#" is interpreted as a comment and make can't find the end of $(foreach,). Adding several .PRECIOUS as without them `make` deletes the intermediate targets. This is an issue because the macro $(if_changed,) check if the target exist in order to decide whether to recreate the target. Removing the call to `mkdir` from the commands. Those aren't needed anymore because a rune in Rules.mk creates the directory for each $(targets). Remove "export PYTHON" as it is already exported. Signed-off-by: Anthony PERARD Acked-by: Jan Beulich Reported-by: Bertrand Marquis Signed-off-by: Anthony PERARD Reviewed-by: Bertrand Marquis --- xen/include/Makefile | 108 ++++++++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 32 deletions(-) diff --git a/xen/include/Makefile b/xen/include/Makefile index 03baf10efb..6d9bcc19b0 100644 --- a/xen/include/Makefile +++ b/xen/include/Makefile @@ -45,38 +45,65 @@ public-$(CONFIG_ARM) := $(wildcard $(srcdir)/public/arch-arm/*.h $(srcdir)/publi .PHONY: all all: $(addprefix $(obj)/,$(headers-y)) -$(obj)/compat/%.h: $(obj)/compat/%.i $(srcdir)/Makefile $(srctree)/tools/compat-build-header.py - $(PYTHON) $(srctree)/tools/compat-build-header.py <$< $(patsubst $(obj)/%,%,$@) >>$@.new; \ - mv -f $@.new $@ - -$(obj)/compat/%.i: $(obj)/compat/%.c $(srcdir)/Makefile - $(CPP) $(filter-out -Wa$(comma)% -include %/include/xen/config.h,$(XEN_CFLAGS)) $(cppflags-y) -o $@ $< - -$(obj)/compat/%.c: $(src)/public/%.h $(srcdir)/xlat.lst $(srcdir)/Makefile $(srctree)/tools/compat-build-source.py - mkdir -p $(@D) - $(PYTHON) $(srctree)/tools/compat-build-source.py $(srcdir)/xlat.lst <$< >$@.new - mv -f $@.new $@ - -$(obj)/compat/.xlat/%.h: $(obj)/compat/%.h $(obj)/compat/.xlat/%.lst $(srctree)/tools/get-fields.sh $(srcdir)/Makefile - export PYTHON=$(PYTHON); \ - while read what name; do \ - $(SHELL) $(srctree)/tools/get-fields.sh "$$what" compat_$$name $< || exit $$?; \ - done <$(patsubst $(obj)/compat/%,$(obj)/compat/.xlat/%,$(basename $<)).lst >$@.new - mv -f $@.new $@ +quiet_cmd_compat_h = GEN $@ +cmd_compat_h = \ + $(PYTHON) $(srctree)/tools/compat-build-header.py <$< $(patsubst $(obj)/%,%,$@) >>$@.new; \ + mv -f $@.new $@ + +quiet_cmd_compat_i = CPP $@ +cmd_compat_i = $(CPP) $(filter-out -Wa$(comma)% -include %/include/xen/config.h,$(XEN_CFLAGS)) $(cppflags-y) -o $@ $< + +quiet_cmd_compat_c = GEN $@ +cmd_compat_c = \ + $(PYTHON) $(srctree)/tools/compat-build-source.py $(srcdir)/xlat.lst <$< >$@.new; \ + mv -f $@.new $@ + +quiet_cmd_xlat_headers = GEN $@ +cmd_xlat_headers = \ + while read what name; do \ + $(SHELL) $(srctree)/tools/get-fields.sh "$$what" compat_$$name $< || exit $$?; \ + done <$(patsubst $(obj)/compat/%,$(obj)/compat/.xlat/%,$(basename $<)).lst >$@.new; \ + mv -f $@.new $@ + +targets += $(headers-y) +$(obj)/compat/%.h: $(obj)/compat/%.i $(srctree)/tools/compat-build-header.py FORCE + $(call if_changed,compat_h) + +.PRECIOUS: $(obj)/compat/%.i +targets += $(patsubst %.h, %.i, $(headers-y)) +$(obj)/compat/%.i: $(obj)/compat/%.c FORCE + $(call if_changed,compat_i) + +.PRECIOUS: $(obj)/compat/%.c +targets += $(patsubst %.h, %.c, $(headers-y)) +$(obj)/compat/%.c: $(src)/public/%.h $(srcdir)/xlat.lst $(srctree)/tools/compat-build-source.py FORCE + $(call if_changed,compat_c) + +targets += $(patsubst compat/%, compat/.xlat/%, $(headers-y)) +$(obj)/compat/.xlat/%.h: $(obj)/compat/%.h $(obj)/compat/.xlat/%.lst $(srctree)/tools/get-fields.sh FORCE + $(call if_changed,xlat_headers) + +quiet_cmd_xlat_lst = GEN $@ +cmd_xlat_lst = \ + grep -v '^[[:blank:]]*$(pound)' $< | sed -ne 's,@arch@,$(compat-arch-y),g' -re 's,[[:blank:]]+$*\.h[[:blank:]]*$$,,p' >$@.new; \ + $(call move-if-changed,$@.new,$@) .PRECIOUS: $(obj)/compat/.xlat/%.lst -$(obj)/compat/.xlat/%.lst: $(srcdir)/xlat.lst $(srcdir)/Makefile - mkdir -p $(@D) - grep -v '^[[:blank:]]*#' $< | sed -ne 's,@arch@,$(compat-arch-y),g' -re 's,[[:blank:]]+$*\.h[[:blank:]]*$$,,p' >$@.new - $(call move-if-changed,$@.new,$@) +targets += $(patsubst compat/%.h, compat/.xlat/%.lst, $(headers-y)) +$(obj)/compat/.xlat/%.lst: $(srcdir)/xlat.lst FORCE + $(call if_changed,xlat_lst) xlat-y := $(shell sed -ne 's,@arch@,$(compat-arch-y),g' -re 's,^[?!][[:blank:]]+[^[:blank:]]+[[:blank:]]+,,p' $(srcdir)/xlat.lst | uniq) xlat-y := $(filter $(patsubst compat/%,%,$(headers-y)),$(xlat-y)) -$(obj)/compat/xlat.h: $(addprefix $(obj)/compat/.xlat/,$(xlat-y)) $(obj)/config/auto.conf $(srcdir)/Makefile - cat $(filter %.h,$^) >$@.new +quiet_cmd_xlat_h = GEN $@ +cmd_xlat_h = \ + cat $(filter %.h,$^) >$@.new; \ mv -f $@.new $@ +$(obj)/compat/xlat.h: $(addprefix $(obj)/compat/.xlat/,$(xlat-y)) $(obj)/config/auto.conf FORCE + $(call if_changed,xlat_h) + ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH)) all: $(obj)/headers.chk $(obj)/headers99.chk $(obj)/headers++.chk @@ -102,27 +129,31 @@ PUBLIC_C99_HEADERS := $(call public-filter-headers,public-c99-headers) $(src)/public/io/9pfs.h-prereq := string $(src)/public/io/pvcalls.h-prereq := string -$(obj)/headers.chk: $(PUBLIC_ANSI_HEADERS) $(srcdir)/Makefile +quiet_cmd_header_chk = CHK $@ +cmd_header_chk = \ for i in $(filter %.h,$^); do \ $(CC) -x c -ansi -Wall -Werror -include stdint.h \ -S -o /dev/null $$i || exit 1; \ echo $$i; \ - done >$@.new + done >$@.new; \ mv $@.new $@ -$(obj)/headers99.chk: $(PUBLIC_C99_HEADERS) $(srcdir)/Makefile - rm -f $@.new +quiet_cmd_headers99_chk = CHK $@ +define cmd_headers99_chk + rm -f $@.new; \ $(foreach i, $(filter %.h,$^), \ echo "#include "\"$(i)\" \ | $(CC) -x c -std=c99 -Wall -Werror \ -include stdint.h \ $(foreach j, $($(patsubst $(srctree)/%,%,$i)-prereq), -include $(j).h) \ -S -o /dev/null - \ - || exit $$?; echo $(i) >> $@.new;) + || exit $$?; echo $(i) >> $@.new;) \ mv $@.new $@ +endef -$(obj)/headers++.chk: $(PUBLIC_HEADERS) $(srcdir)/Makefile - rm -f $@.new +quiet_cmd_headerscxx_chk = CHK $@ +define cmd_headerscxx_chk + rm -f $@.new; \ if ! $(CXX) -v >/dev/null 2>&1; then \ touch $@.new; \ exit 0; \ @@ -133,8 +164,21 @@ $(obj)/headers++.chk: $(PUBLIC_HEADERS) $(srcdir)/Makefile -include stdint.h -include $(srcdir)/public/xen.h \ $(foreach j, $($(patsubst $(srctree)/%,%,$i)-prereq), -include c$(j)) \ -S -o /dev/null - \ - || exit $$?; echo $(i) >> $@.new;) + || exit $$?; echo $(i) >> $@.new;) \ mv $@.new $@ +endef + +targets += headers.chk +$(obj)/headers.chk: $(PUBLIC_ANSI_HEADERS) FORCE + $(call if_changed,header_chk) + +targets += headers99.chk +$(obj)/headers99.chk: $(PUBLIC_C99_HEADERS) FORCE + $(call if_changed,headers99_chk) + +targets += headers++.chk +$(obj)/headers++.chk: $(PUBLIC_HEADERS) FORCE + $(call if_changed,headerscxx_chk) endif From patchwork Wed Jun 1 16:59:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12867073 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B102C43334 for ; Wed, 1 Jun 2022 16:59:43 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.340584.565672 (Exim 4.92) (envelope-from ) id 1nwRh0-0000c4-0K; Wed, 01 Jun 2022 16:59:34 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 340584.565672; Wed, 01 Jun 2022 16:59:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nwRgz-0000ah-RH; Wed, 01 Jun 2022 16:59:33 +0000 Received: by outflank-mailman (input) for mailman id 340584; Wed, 01 Jun 2022 16:59:32 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nwRgy-0000Xw-Rb for xen-devel@lists.xenproject.org; Wed, 01 Jun 2022 16:59:32 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3355f586-e1cc-11ec-837f-e5687231ffcc; Wed, 01 Jun 2022 18:59:31 +0200 (CEST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3355f586-e1cc-11ec-837f-e5687231ffcc DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1654102771; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XFVVIbvewXpq18wLagkSmqKQFGebkO+PaAyJtLO/9K8=; b=VF+AqHuON8WHLriyTwRdVXR3ra0uqaQ0z3ibpz++GYpR2cB6LM4Gk1DB zjpUn7xWn4u1O/qg8rRb5OS0SlST6OKjC8BZc7AfNnxlBckTHdh2EaQQo W3r6FT1c+YcGR0hcfvTDyp44iz5CRYKE4ic3HxmXpQMJFhDeSNsBurloC s=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 72494142 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:OoSqwqinvuCJ3pRVzKHD4FDgX161GBAKZh0ujC45NGQN5FlHY01je htvXTyCb/qMYDSgf4wgO4+3p0oC75DQnYRqT1dtq3o3QyMb9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oDJ9CU6jefSLlbFILas1hpZHGeIcw98z0M68wIFqtQw24LhXVvU4 YiaT/D3YzdJ5RYlagr41IrbwP9flKyaVOQw5wFWiVhj5TcyplFNZH4tDfjZw0jQG+G4KtWSV efbpIxVy0uCl/sb5nFJpZ6gGqECaua60QFjERO6UYD66vRJjnRaPqrWqJPwwKqY4tmEt4kZ9 TlDiXC/YT41MbzJwuMcb0RJCjw5J/JKwpvsGVHq5KR/z2WeG5ft6/BnDUVwNowE4OdnR2pJ8 JT0KhhUMErF3bjvhuvmFK883azPL+GyVG8bknhm0THeC+dgWZ3ZSr/GzdRZwC0xloZFGvO2i 88xNmAzPUiZP0cn1lE/Uss/uP+miUvEbzBXk1KcpKkdyHeM01kkuFTqGIWMIYHbLSlPpW6Dv X7P9Wn9BhAcNfScxCCD/3bqgfXA9QvkXKoCGbv+8eRl6HWR22gSBRs+RVa95/6jhSaWS99Zb kAZ5Ccqhawz71CwCMnwWQWip3yJtQJaXMBfe8U44gyQzqvf4y6CG3MJCDVGbbQbWNQeHGJwk AXTxpWwWGIp4Ob9pW+hGqm8lC+9KC1PKm4+OD4dUEwfvNXZhKoLp0eaJjp8K5JZnuEZCBmpn W3W9HRh2e5D5SIY//7lpA6a2lpAsrCMF1dovVuPAwpJ+ysjPOaYi5qUBU83BBqqBKKQVRG/s XcNgKByB8heXMjWxERhrAjgdYxFBspp0xWG2DaD57F7q1yQF4eLJOi8Gg1WKkZzKdojcjT0e kLVsg45zMYNYSfyN/UvPNzuUp1CIU3c+TPND6m8UzazSsIpKF/vEN9GPiZ8IFwBYGBzyPpia P93gO6nDGoACLQP8Qdas9w1iOdxrghnnDu7bcmik3yPjOvFDFbIGOhtDbd7Rr1ghE9yiF6No 4g32grj40g3bdASlQGNrtBDdgBRdydlbX00wuQOHtO+zsNdMDlJI5fsLXkJIuSJQ4w9ej/0w 0yA IronPort-HdrOrdr: A9a23:8BwDfamrKb54aO+kaqExKfY52i/pDfIq3DAbv31ZSRFFG/Fxl6 iV88jzsiWE7wr5OUtQ4OxoV5PgfZqxz/NICMwqTNWftWrdyQ+VxeNZjbcKqgeIc0aVygce79 YET0EXMqyXMbEQt6jHCWeDf+rIuOP3k5yVuQ== X-IronPort-AV: E=Sophos;i="5.91,269,1647316800"; d="scan'208";a="72494142" From: Anthony PERARD To: CC: Anthony PERARD , Andrew Cooper , George Dunlap , "Jan Beulich" , Julien Grall , "Stefano Stabellini" , Wei Liu Subject: [XEN PATCH 2/4] build: set PERL Date: Wed, 1 Jun 2022 17:59:07 +0100 Message-ID: <20220601165909.46588-3-anthony.perard@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220601165909.46588-1-anthony.perard@citrix.com> References: <20220601165909.46588-1-anthony.perard@citrix.com> MIME-Version: 1.0 We are going to use it in a moment. Signed-off-by: Anthony PERARD --- xen/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/Makefile b/xen/Makefile index 82f5310b12..a6650a2acc 100644 --- a/xen/Makefile +++ b/xen/Makefile @@ -22,6 +22,7 @@ PYTHON_INTERPRETER := $(word 1,$(shell which python3 python python2 2>/dev/null) export PYTHON ?= $(PYTHON_INTERPRETER) export CHECKPOLICY ?= checkpolicy +export PERL ?= perl $(if $(filter __%, $(MAKECMDGOALS)), \ $(error targets prefixed with '__' are only for internal use)) From patchwork Wed Jun 1 16:59:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12867074 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A92BBC433EF for ; Wed, 1 Jun 2022 16:59:49 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.340585.565689 (Exim 4.92) (envelope-from ) id 1nwRh3-00019Z-EW; Wed, 01 Jun 2022 16:59:37 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 340585.565689; Wed, 01 Jun 2022 16:59:37 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nwRh3-00019G-7p; Wed, 01 Jun 2022 16:59:37 +0000 Received: by outflank-mailman (input) for mailman id 340585; Wed, 01 Jun 2022 16:59:35 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nwRh0-0000Xw-V5 for xen-devel@lists.xenproject.org; Wed, 01 Jun 2022 16:59:35 +0000 Received: from esa6.hc3370-68.iphmx.com (esa6.hc3370-68.iphmx.com [216.71.155.175]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 3519baf0-e1cc-11ec-837f-e5687231ffcc; Wed, 01 Jun 2022 18:59:32 +0200 (CEST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3519baf0-e1cc-11ec-837f-e5687231ffcc DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1654102772; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WoBfmEao3DrJCNeVSjlgM3yjFCOP00okKErgLU5uy7I=; b=AYkU6r0jO3EA+mYR3hGMK0uv7pgVFrJ9sCZDMFNx0HxbVvIbtlXEoz6s QTgWcPYEZ9gTYj1JzrCXtMY2Ttjbq7gjejF6g1qPId+nJHVFajDdFtk0U md4zn9e/Cn0axz3zfCJG5U7DmlfcKO3+OidxK6qLTzj2sMVbOAfnCaMse g=; Authentication-Results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 72494147 X-Ironport-Server: esa6.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:kdaoo6gzNzeu5lB46qQf42AJX161GBAKZh0ujC45NGQN5FlHY01je htvX2qEbPaOY2rxKIpyOt62oR8D75DcmoNiG1NupH83RSIb9cadCdqndUqhZCn6wu8v7a5EA 2fyTvGacajYm1eF/k/F3oDJ9CU6jefSLlbFILas1hpZHGeIcw98z0M68wIFqtQw24LhXVvU4 YiaT/D3YzdJ5RYlagr41IrbwP9flKyaVOQw5wFWiVhj5TcyplFNZH4tDfjZw0jQG+G4KtWSV efbpIxVy0uCl/sb5nFJpZ6gGqECaua60QFjERO6UYD66vRJjnRaPqrWqJPwwKqY4tmEt4kZ9 TlDiXC/YV91B6jNpr8waAhBGgBwMvFI27bee1Hq5KR/z2WeG5ft6/BnDUVwNowE4OdnR2pJ8 JT0KhhUMErF3bjvhuvmFK883azPL+GyVG8bknhm0THeC+dgWZ3ZSr/GzdRZwC0xloZFGvO2i 88xNmAzPUiZP0In1lE/S5IdxNnvhVfGLwJFrkyp/roQynHOw1kkuFTqGIWMIYHbLSlPpW6Dv X7P9Wn9BhAcNfScxCCD/3bqgfXA9QvkXKoCGbv+8eRl6HWR22gSBRs+RVa95/6jhSaWS99Zb kAZ5Ccqhawz71CwCMnwWQWip3yJtQJaXMBfe8U44gyQzqvf4y6CG3MJCDVGbbQbWNQeHGJwk AXTxpWwWGIp4Ob9pW+hGqm89W+LPCkrdkI5dDYNbAUKv9fAqZhpp0eaJjp8K5JZnuEZCBmpn W3W9HRh2e5D5SIY//7lpA6a2lpAsrCMF1dovVuPAwpJ+ysjPOaYi5qUBU83BBqqBKKQVRG/s XcNgKByB8heXMjWxERhrAjgdYxFBspp0xWG2DaD57F7q1yQF4eLJOi8Gg1WKkZzKdojcjT0e kLVsg45zMYNYSfyN/UvPNzuUp1CIU3c+TPND6m8UzazSsIpKF/vEN9GPiZ8IFwBYGBzyPpia P93gO6nDGoACLQP8Qdas9w1iOdxrghnnDu7bcmik3yPjOvFDFbIGOhtDbd7Rr1ghE9yiF6No 4g32grj40g3bdASlQGNrtBDdgBRdydlbX00wuQOHtO+zsNdMDlJI5fsLXkJIeSJQ4w9ej/0w 0yA IronPort-HdrOrdr: A9a23:stiJ9ajJ1cONnIsbnYiNyk0MPHBQXtwji2hC6mlwRA09TySZ// rAoB19726StN9xYgBYpTnuAsi9qB/nmKKdpLNhX4tKPzOW3FdATrsD0WKK+VSJcEfDH6xmpM JdmsBFebvN5DNB4/oSjjPVLz9Z+qjlzJyV X-IronPort-AV: E=Sophos;i="5.91,269,1647316800"; d="scan'208";a="72494147" From: Anthony PERARD To: CC: Anthony PERARD , Andrew Cooper , George Dunlap , "Jan Beulich" , Julien Grall , "Stefano Stabellini" , Wei Liu Subject: [XEN PATCH 3/4] build: replace get-fields.sh by a perl script Date: Wed, 1 Jun 2022 17:59:08 +0100 Message-ID: <20220601165909.46588-4-anthony.perard@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220601165909.46588-1-anthony.perard@citrix.com> References: <20220601165909.46588-1-anthony.perard@citrix.com> MIME-Version: 1.0 The get-fields.sh which generate all the include/compat/.xlat/*.h headers is quite slow. It takes for example nearly 3 seconds to generate platform.h on a recent machine, or 2.3 seconds for memory.h. Since it's only text processing, rewriting the mix of shell/sed/python into a single perl script make the generation of those file a lot faster. I tried to keep a similar look for the code, to keep the code similar between the shell and perl, and to ease review. So some code in perl might look weird or could be written better. Signed-off-by: Anthony PERARD --- xen/include/Makefile | 6 +- xen/tools/compat-xlat-header | 539 +++++++++++++++++++++++++++++++++++ xen/tools/get-fields.sh | 528 ---------------------------------- 3 files changed, 541 insertions(+), 532 deletions(-) create mode 100755 xen/tools/compat-xlat-header delete mode 100644 xen/tools/get-fields.sh diff --git a/xen/include/Makefile b/xen/include/Makefile index 6d9bcc19b0..b7e7148665 100644 --- a/xen/include/Makefile +++ b/xen/include/Makefile @@ -60,9 +60,7 @@ cmd_compat_c = \ quiet_cmd_xlat_headers = GEN $@ cmd_xlat_headers = \ - while read what name; do \ - $(SHELL) $(srctree)/tools/get-fields.sh "$$what" compat_$$name $< || exit $$?; \ - done <$(patsubst $(obj)/compat/%,$(obj)/compat/.xlat/%,$(basename $<)).lst >$@.new; \ + $(PERL) $(srctree)/tools/compat-xlat-header $< $(patsubst $(obj)/compat/%,$(obj)/compat/.xlat/%,$(basename $<)).lst > $@.new; \ mv -f $@.new $@ targets += $(headers-y) @@ -80,7 +78,7 @@ $(obj)/compat/%.c: $(src)/public/%.h $(srcdir)/xlat.lst $(srctree)/tools/compat- $(call if_changed,compat_c) targets += $(patsubst compat/%, compat/.xlat/%, $(headers-y)) -$(obj)/compat/.xlat/%.h: $(obj)/compat/%.h $(obj)/compat/.xlat/%.lst $(srctree)/tools/get-fields.sh FORCE +$(obj)/compat/.xlat/%.h: $(obj)/compat/%.h $(obj)/compat/.xlat/%.lst $(srctree)/tools/compat-xlat-header FORCE $(call if_changed,xlat_headers) quiet_cmd_xlat_lst = GEN $@ diff --git a/xen/tools/compat-xlat-header b/xen/tools/compat-xlat-header new file mode 100755 index 0000000000..f1f42a9dde --- /dev/null +++ b/xen/tools/compat-xlat-header @@ -0,0 +1,539 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; + +open COMPAT_LIST, "<$ARGV[1]" or die "can't open $ARGV[1], $!"; +open HEADER, "<$ARGV[0]" or die "can't open $ARGV[0], $!"; + +my @typedefs; + +my @header_tokens; +while (
) { + next if m/^\s*#.*/; + s/([\]\[,;:{}])/ $1 /g; + s/^\s+//; + push(@header_tokens, split(/\s+/)); +} + +sub get_fields { + my ($looking_for) = @_; + my $level = 1; + my $aggr = 0; + my ($name, @fields); + + foreach (@header_tokens) { + if (/^(struct|union)$/) { + unless ($level != 1) { + $aggr = 1; + @fields = (); + $name = ''; + } + } elsif ($_ eq '{') { + $level++; + } elsif ($_ eq '}') { + $level--; + if ($level == 1 and $name eq $looking_for) { + push (@fields, $_); + return @fields; + } + } elsif (/^[a-zA-Z_].*/) { + unless ($aggr == 0 or $name ne "") { + $name = $_; + } + } + unless ($aggr == 0) { + push (@fields, $_); + } + } + return (); +} + +sub get_typedefs { + my $level = 1; + my $state = 0; + my @typedefs; + foreach (@_) { + if ($_ eq 'typedef') { + unless ($level != 1) { + $state = 1; + } + } elsif (m/^COMPAT_HANDLE\(.*\)$/) { + unless ($level != 1 or $state != 1) { + $state = 2; + } + } elsif (m/^[\[\{]$/) { + $level++; + } elsif (m/^[\]\}]$/) { + $level--; + } elsif ($_ eq ';') { + unless ($level != 1) { + $state = 0; + } + } elsif (m/^[a-zA-Z_].*$/) { + unless ($level != 1 or $state != 2) { + push (@typedefs, $_); + } + } + } + return @typedefs; +} + +sub build_enums { + my ($name, @tokens) = @_; + + my $level = 1; + my $kind = ''; + my $named = ''; + my (@fields, @members, $id); + + foreach (@tokens) { + if (m/^(struct|union)$/) { + unless ($level != 2) { + @fields = (''); + } + $kind="$_;$kind"; + } elsif ($_ eq '{') { + $level++; + } elsif ($_ eq '}') { + $level--; + if ($level == 1) { + my $subkind = $kind; + $subkind =~ s/;.*//; + if ($subkind eq 'union') { + print "\nenum XLAT_$name {\n"; + foreach (@members) { + print " XLAT_${name}_$_,\n"; + } + print "};\n"; + } + return; + } elsif ($level == 2) { + $named = '?'; + } + } elsif (/^[a-zA-Z_].*$/) { + $id = $_; + my $k = $kind; + $k =~ s/.*?;//; + if ($named ne '' and $k ne '') { + shift @fields if @fields > 0 and $fields[0] eq ''; + build_enums("${name}_$_", @fields); + $named = '!'; + } + } elsif ($_ eq ',') { + unless ($level != 2) { + push (@members, $id); + } + } elsif ($_ eq ';') { + unless ($level != 2) { + push (@members, $id); + } + unless ($named eq '') { + $kind =~ s/.*?;//; + } + $named = ''; + } + unless (@fields == 0) { + push (@fields, $_); + } + } +} + +sub handle_field { + my ($prefix, $name, $id, $type, @fields) = @_; + + if (@fields == 0) { + print " \\\n"; + if ($type eq '') { + print "$prefix\(_d_)->$id = (_s_)->$id;" + } else { + my $k = $id; + $k =~ s/\./_/g; + print "${prefix}XLAT_${name}_HNDL_${k}(_d_, _s_);"; + } + } elsif ("@fields" !~ m/[{}]/) { + my $tag = "@fields"; + $tag =~ s/\s*(struct|union)\s+(compat_)?(\w+)\s.*/$3/; + print " \\\n"; + print "${prefix}XLAT_$tag(&(_d_)->$id, &(_s_)->$id);" + } else { + my $func_id = $id; + my @func_tokens = @fields; + my $kind = ''; + my $array = ""; + my $level = 1; + my $arrlvl = 1; + my $array_type = ''; + my $id = ''; + my $type = ''; + @fields = (); + foreach (@func_tokens) { + if (/^(struct|union)$/) { + unless ($level != 2) { + @fields = (''); + } + if ($level == 1) { + $kind = $_; + if ($kind eq 'union') { + my $tmp = $func_id; + $tmp =~ s/\./_/g; + print " \\\n"; + print "${prefix}switch ($tmp) {" + } + } + } elsif ($_ eq '{') { + $level++; + $id = ''; + } elsif ($_ eq '}') { + $level--; + $id = ''; + if ($level == 1 and $kind eq 'union') { + print " \\\n"; + print "$prefix}" + } + } elsif ($_ eq '[') { + if ($level != 2 or $arrlvl != 1) { + # skip + } elsif ($array eq '') { + $array = ' '; + } else { + $array = "$array;"; + } + $arrlvl++; + } elsif ($_ eq ']') { + $arrlvl--; + } elsif (m/^COMPAT_HANDLE\((.*)\)$/) { + if ($level == 2 and $id eq '') { + $type = $1; + $type =~ s/^compat_//; + } + } elsif ($_ eq "compat_domain_handle_t") { + if ($level == 2 and $id eq '') { + $array_type = $_; + } + } elsif (m/^[a-zA-Z_].*$/) { + if ($id eq '' and $type eq '' and $array_type eq '') { + foreach $id (@typedefs) { + unless ($id ne $_) { + $type = $id; + } + } + if ($type eq '') { + $id = $_; + } else { + $id = ''; + } + } else { + $id = $_; + } + } elsif (m/^[,;]$/) { + if ($level == 2 and $id !~ /^_pad\d*$/) { + if ($kind eq 'union') { + my $tmp = "$func_id.$id"; + $tmp =~ s/\./_/g; + print " \\\n"; + print "${prefix}case XLAT_${name}_$tmp:"; + shift @fields if @fields > 0 and $fields[0] eq ''; + handle_field("$prefix ", $name, "$func_id.$id", $type, @fields); + } elsif ($array eq '' and $array_type eq '') { + shift @fields if @fields > 0 and $fields[0] eq ''; + handle_field($prefix, $name, "$func_id.$id", $type, @fields); + } elsif ($array eq '') { + copy_array(" ", "$func_id.$id"); + } else { + $array =~ s/^.*?;//; + shift @fields if @fields > 0 and $fields[0] eq ''; + handle_array($prefix, $name, "$func_id.$id", $array, $type, @fields); + } + unless ($_ ne ';') { + @fields = (); + $id = ''; + $type = ''; + } + $array = ''; + if ($kind eq 'union') { + print " \\\n"; + print "$prefix break;"; + } + } + } else { + if ($array ne '') { + $array = "$array $_"; + } + } + unless (@fields == 0) { + push (@fields, $_); + } + } + } +} + +sub copy_array { + my ($prefix, $id) = @_; + + print " \\\n"; + print "${prefix}if ((_d_)->$id != (_s_)->$id) \\\n"; + print "$prefix memcpy((_d_)->$id, (_s_)->$id, sizeof((_d_)->$id));"; +} + +sub handle_array { + my ($prefix, $name, $id, $array, $type, @fields) = @_; + + my $i = $array; + $i =~ s/[^;]//g; + $i = length($i); + $i = "i$i"; + + print " \\\n"; + print "$prefix\{ \\\n"; + print "$prefix unsigned int $i; \\\n"; + my $tmp = $array; + $tmp =~ s/;.*$//; + $tmp =~ s/^\s*(.*)\s*$/$1/; + print "$prefix for ($i = 0; $i < $tmp; ++$i) {"; + if ($array !~ m/^.*?;/) { + handle_field("$prefix ", $name, "$id\[$i]", $type, @fields); + } else { + handle_array("$prefix " ,$name, "$id\[$i]", $', $type, @fields); + } + print " \\\n"; + print "$prefix } \\\n"; + print "$prefix\}"; +} + +sub build_body { + my ($name, @tokens) = @_; + my $level = 1; + my $id = ''; + my $array = ''; + my $arrlvl = 1; + my $array_type = ''; + my $type = ''; + my @fields; + + printf "\n#define XLAT_$name(_d_, _s_) do {"; + + foreach (@tokens) { + if (/^(struct|union)$/) { + unless ($level != 2) { + @fields = (''); + } + } elsif ($_ eq '{') { + $level++; + $id = ''; + } elsif ($_ eq '}') { + $level--; + $id = ''; + } elsif ($_ eq '[') { + if ($level != 2 or $arrlvl != 1) { + # skip + } elsif ($array eq '') { + $array = ' '; + } else { + $array = "$array;"; + } + $arrlvl++; + } elsif ($_ eq ']') { + $arrlvl--; + } elsif (m/^COMPAT_HANDLE\((.*)\)$/) { + if ($level == 2 and $id eq '') { + $type = $1; + $type =~ s/^compat_//; + } + } elsif ($_ eq "compat_domain_handle_t") { + if ($level == 2 and $id eq '') { + $array_type = $_; + } + } elsif (m/^[a-zA-Z_].*$/) { + if ($array ne '') { + $array = "$array $_"; + } elsif ($id eq '' and $type eq '' and $array_type eq '') { + foreach $id (@typedefs) { + unless ($id eq $_) { + $type = $id; + } + } + if ($type eq '') { + $id = $_; + } else { + $id = ''; + } + } else { + $id = $_; + } + } elsif (m/^[,;]$/) { + if ($level == 2 and $id !~ /^_pad\d*$/) { + if ($array eq '' and $array_type eq '') { + shift @fields if @fields > 0 and $fields[0] eq ''; + handle_field(" ", $name, $id, $type, @fields); + } elsif ($array eq '') { + copy_array(" ", $id); + } else { + my $tmp = $array; + $tmp =~ s/^.*?;//; + shift @fields if @fields > 0 and $fields[0] eq ''; + handle_array(" ", $name, $id, $tmp, $type, @fields); + } + unless ($_ ne ';') { + @fields = (); + $id = ''; + $type = ''; + } + $array = ''; + } + } else { + if ($array ne '') { + $array = "$array $_"; + } + } + unless (@fields == 0) { + push (@fields, $_); + } + } + print " \\\n} while (0)\n"; +} + +sub check_field { + my ($kind, $name, $field, @extrafields) = @_; + + if ("@extrafields" !~ m/[{}]/) { + print "; \\\n"; + if (@extrafields != 0) { + foreach (@extrafields) { + if (m/^(struct|union)$/) { + # skip + } elsif (m/^[a-zA-Z_].*/) { + s/^xen_//; + print " CHECK_$_"; + last; + } else { + die "Malformed compound declaration: '$_'"; + } + } + } elsif ($field !~ m/\./) { + print " CHECK_FIELD_($kind, $name, $field)"; + } else { + my $n = $field =~ s/\./, /g; + print " CHECK_SUBFIELD_${n}_($kind, $name, $field)"; + } + } else { + my $level = 1; + my @fields = (); + my $id = ''; + + foreach (@extrafields) { + if (m/^(struct|union)$/) { + unless ($level != 2) { + @fields = (''); + } + } elsif ($_ eq '{') { + $level++; + $id = ''; + } elsif ($_ eq '}') { + $level--; + $id = ''; + } elsif (/^compat_.*_t$/) { + if ($level == 2) { + @fields = (''); + s/_t$//; + s/^compat_//; + } + } elsif (/^evtchn_.*_compat_t$/) { + if ($level == 2 and $_ ne "evtchn_port_compat_t") { + @fields = (''); + s/_compat_t$//; + } + } elsif (/^[a-zA-Z_].*$/) { + $id = $_; + } elsif (/^[,;]$/) { + if ($level == 2 and $id !~ /^_pad\d*$/) { + shift @fields if @fields > 0 and $fields[0] eq ''; + check_field($kind, $name, "$field.$id", @fields); + unless ($_ ne ";") { + @fields = (); + $id = ''; + } + } + } + unless (@fields == 0) { + push (@fields, $_); + } + } + } +} + +sub build_check { + my ($name, @tokens) = @_; + my $level = 1; + my (@fields, $kind, $id); + my $arrlvl = 1; + + print "\n"; + print "#define CHECK_$name \\\n"; + + foreach (@tokens) { + if (/^(struct|union)$/) { + if ($level == 1) { + $kind = $_; + print " CHECK_SIZE_($kind, $name)"; + } elsif ($level == 2) { + @fields = (''); + } + } elsif ($_ eq '{') { + $level++; + $id = ''; + } elsif ($_ eq '}') { + $level--; + $id = ''; + } elsif ($_ eq '[') { + $arrlvl++; + } elsif ($_ eq ']') { + $arrlvl--; + } elsif (/^compat_.*_t$/) { + if ($level == 2 and $_ ne "compat_argo_port_t") { + @fields = (''); + s/_t$//; + s/^compat_//; + } + } elsif (/^[a-zA-Z_].*$/) { + unless ($level != 2 or $arrlvl != 1) { + $id = $_; + } + } elsif (/^[,;]$/) { + if ($level == 2 and $id !~ /^_pad\d*$/) { + shift @fields if @fields > 0 and $fields[0] eq ''; + check_field($kind, $name, $id, @fields); + unless ($_ ne ";") { + @fields = (); + $id = ''; + } + } + } + + unless (@fields == 0) { + push (@fields, $_); + } + } + print "\n"; +} + +@typedefs = get_typedefs(@header_tokens); + +while () { + my ($what, $name) = split(/\s+/, $_); + $name =~ s/^xen//; + + my @fields = get_fields("compat_$name"); + if (@fields == 0) { + die "Fields of 'compat_$name' not found in '$ARGV[1]'"; + } + + if ($what eq "!") { + build_enums($name, @fields); + build_body($name, @fields); + } elsif ($what eq "?") { + build_check($name, @fields); + } else { + die "Invalid translation indicator: '$what'"; + } +} diff --git a/xen/tools/get-fields.sh b/xen/tools/get-fields.sh deleted file mode 100644 index 002db2093f..0000000000 --- a/xen/tools/get-fields.sh +++ /dev/null @@ -1,528 +0,0 @@ -test -n "$1" -a -n "$2" -a -n "$3" -set -ef - -SED=sed -if test -x /usr/xpg4/bin/sed; then - SED=/usr/xpg4/bin/sed -fi -if test -z ${PYTHON}; then - PYTHON=`/usr/bin/env python` -fi -if test -z ${PYTHON}; then - echo "Python not found" - exit 1 -fi - -get_fields () -{ - local level=1 aggr=0 name= fields= - for token in $2 - do - case "$token" in - struct|union) - test $level != 1 || aggr=1 fields= name= - ;; - "{") - level=$(expr $level + 1) - ;; - "}") - level=$(expr $level - 1) - if [ $level = 1 -a $name = $1 ] - then - echo "$fields }" - return 0 - fi - ;; - [a-zA-Z_]*) - test $aggr = 0 -o -n "$name" || name="$token" - ;; - esac - test $aggr = 0 || fields="$fields $token" - done -} - -get_typedefs () -{ - local level=1 state= - for token in $1 - do - case "$token" in - typedef) - test $level != 1 || state=1 - ;; - COMPAT_HANDLE\(*\)) - test $level != 1 -o "$state" != 1 || state=2 - ;; - [\{\[]) - level=$(expr $level + 1) - ;; - [\}\]]) - level=$(expr $level - 1) - ;; - ";") - test $level != 1 || state= - ;; - [a-zA-Z_]*) - test $level != 1 -o "$state" != 2 || echo "$token" - ;; - esac - done -} - -build_enums () -{ - local level=1 kind= fields= members= named= id= token - for token in $2 - do - case "$token" in - struct|union) - test $level != 2 || fields=" " - kind="$token;$kind" - ;; - "{") - level=$(expr $level + 1) - ;; - "}") - level=$(expr $level - 1) - if [ $level = 1 ] - then - if [ "${kind%%;*}" = union ] - then - echo - echo "enum XLAT_$1 {" - for m in $members - do - echo " XLAT_${1}_$m," - done - echo "};" - fi - return 0 - elif [ $level = 2 ] - then - named='?' - fi - ;; - [a-zA-Z]*) - id=$token - if [ -n "$named" -a -n "${kind#*;}" ] - then - build_enums ${1}_$token "$fields" - named='!' - fi - ;; - ",") - test $level != 2 || members="$members $id" - ;; - ";") - test $level != 2 || members="$members $id" - test -z "$named" || kind=${kind#*;} - named= - ;; - esac - test -z "$fields" || fields="$fields $token" - done -} - -handle_field () -{ - if [ -z "$5" ] - then - echo " \\" - if [ -z "$4" ] - then - printf %s "$1(_d_)->$3 = (_s_)->$3;" - else - printf %s "$1XLAT_${2}_HNDL_$(echo $3 | $SED 's,\.,_,g')(_d_, _s_);" - fi - elif [ -z "$(echo "$5" | $SED 's,[^{}],,g')" ] - then - local tag=$(echo "$5" | ${PYTHON} -c ' -import re,sys -for line in sys.stdin.readlines(): - sys.stdout.write(re.subn(r"\s*(struct|union)\s+(compat_)?(\w+)\s.*", r"\3", line)[0].rstrip() + "\n") -') - echo " \\" - printf %s "${1}XLAT_$tag(&(_d_)->$3, &(_s_)->$3);" - else - local level=1 kind= fields= id= array= arrlvl=1 array_type= type= token - for token in $5 - do - case "$token" in - struct|union) - test $level != 2 || fields=" " - if [ $level = 1 ] - then - kind=$token - if [ $kind = union ] - then - echo " \\" - printf %s "${1}switch ($(echo $3 | $SED 's,\.,_,g')) {" - fi - fi - ;; - "{") - level=$(expr $level + 1) id= - ;; - "}") - level=$(expr $level - 1) id= - if [ $level = 1 -a $kind = union ] - then - echo " \\" - printf %s "$1}" - fi - ;; - "[") - if [ $level != 2 -o $arrlvl != 1 ] - then - : - elif [ -z "$array" ] - then - array=" " - else - array="$array;" - fi - arrlvl=$(expr $arrlvl + 1) - ;; - "]") - arrlvl=$(expr $arrlvl - 1) - ;; - COMPAT_HANDLE\(*\)) - if [ $level = 2 -a -z "$id" ] - then - type=${token#COMPAT_HANDLE?} - type=${type%?} - type=${type#compat_} - fi - ;; - compat_domain_handle_t) - if [ $level = 2 -a -z "$id" ] - then - array_type=$token - fi - ;; - [a-zA-Z]*) - if [ -z "$id" -a -z "$type" -a -z "$array_type" ] - then - for id in $typedefs - do - test $id != "$token" || type=$id - done - if [ -z "$type" ] - then - id=$token - else - id= - fi - else - id=$token - fi - ;; - [\,\;]) - if [ $level = 2 -a -n "$(echo $id | $SED 's,^_pad[[:digit:]]*,,')" ] - then - if [ $kind = union ] - then - echo " \\" - printf %s "${1}case XLAT_${2}_$(echo $3.$id | $SED 's,\.,_,g'):" - handle_field "$1 " $2 $3.$id "$type" "$fields" - elif [ -z "$array" -a -z "$array_type" ] - then - handle_field "$1" $2 $3.$id "$type" "$fields" - elif [ -z "$array" ] - then - copy_array " " $3.$id - else - handle_array "$1" $2 $3.$id "${array#*;}" "$type" "$fields" - fi - test "$token" != ";" || fields= id= type= - array= - if [ $kind = union ] - then - echo " \\" - printf %s "$1 break;" - fi - fi - ;; - *) - if [ -n "$array" ] - then - array="$array $token" - fi - ;; - esac - test -z "$fields" || fields="$fields $token" - done - fi -} - -copy_array () -{ - echo " \\" - echo "${1}if ((_d_)->$2 != (_s_)->$2) \\" - printf %s "$1 memcpy((_d_)->$2, (_s_)->$2, sizeof((_d_)->$2));" -} - -handle_array () -{ - local i="i$(echo $4 | $SED 's,[^;], ,g' | wc -w | $SED 's,[[:space:]]*,,g')" - echo " \\" - echo "$1{ \\" - echo "$1 unsigned int $i; \\" - printf %s "$1 for ($i = 0; $i < "${4%%;*}"; ++$i) {" - if [ "$4" = "${4#*;}" ] - then - handle_field "$1 " $2 $3[$i] "$5" "$6" - else - handle_array "$1 " $2 $3[$i] "${4#*;}" "$5" "$6" - fi - echo " \\" - echo "$1 } \\" - printf %s "$1}" -} - -build_body () -{ - echo - printf %s "#define XLAT_$1(_d_, _s_) do {" - local level=1 fields= id= array= arrlvl=1 array_type= type= token - for token in $2 - do - case "$token" in - struct|union) - test $level != 2 || fields=" " - ;; - "{") - level=$(expr $level + 1) id= - ;; - "}") - level=$(expr $level - 1) id= - ;; - "[") - if [ $level != 2 -o $arrlvl != 1 ] - then - : - elif [ -z "$array" ] - then - array=" " - else - array="$array;" - fi - arrlvl=$(expr $arrlvl + 1) - ;; - "]") - arrlvl=$(expr $arrlvl - 1) - ;; - COMPAT_HANDLE\(*\)) - if [ $level = 2 -a -z "$id" ] - then - type=${token#COMPAT_HANDLE?} - type=${type%?} - type=${type#compat_} - fi - ;; - compat_domain_handle_t) - if [ $level = 2 -a -z "$id" ] - then - array_type=$token - fi - ;; - [a-zA-Z_]*) - if [ -n "$array" ] - then - array="$array $token" - elif [ -z "$id" -a -z "$type" -a -z "$array_type" ] - then - for id in $typedefs - do - test $id != "$token" || type=$id - done - if [ -z "$type" ] - then - id=$token - else - id= - fi - else - id=$token - fi - ;; - [\,\;]) - if [ $level = 2 -a -n "$(echo $id | $SED 's,^_pad[[:digit:]]*,,')" ] - then - if [ -z "$array" -a -z "$array_type" ] - then - handle_field " " $1 $id "$type" "$fields" - elif [ -z "$array" ] - then - copy_array " " $id - else - handle_array " " $1 $id "${array#*;}" "$type" "$fields" - fi - test "$token" != ";" || fields= id= type= - array= - fi - ;; - *) - if [ -n "$array" ] - then - array="$array $token" - fi - ;; - esac - test -z "$fields" || fields="$fields $token" - done - echo " \\" - echo "} while (0)" -} - -check_field () -{ - if [ -z "$(echo "$4" | $SED 's,[^{}],,g')" ] - then - echo "; \\" - local n=$(echo $3 | $SED 's,[^.], ,g' | wc -w | $SED 's,[[:space:]]*,,g') - if [ -n "$4" ] - then - for n in $4 - do - case $n in - struct|union) - ;; - [a-zA-Z_]*) - printf %s " CHECK_${n#xen_}" - break - ;; - *) - echo "Malformed compound declaration: '$n'" >&2 - exit 1 - ;; - esac - done - elif [ $n = 0 ] - then - printf %s " CHECK_FIELD_($1, $2, $3)" - else - printf %s " CHECK_SUBFIELD_${n}_($1, $2, $(echo $3 | $SED 's!\.!, !g'))" - fi - else - local level=1 fields= id= token - for token in $4 - do - case "$token" in - struct|union) - test $level != 2 || fields=" " - ;; - "{") - level=$(expr $level + 1) id= - ;; - "}") - level=$(expr $level - 1) id= - ;; - compat_*_t) - if [ $level = 2 ] - then - fields=" " - token="${token%_t}" - token="${token#compat_}" - fi - ;; - evtchn_*_compat_t) - if [ $level = 2 -a $token != evtchn_port_compat_t ] - then - fields=" " - token="${token%_compat_t}" - fi - ;; - [a-zA-Z]*) - id=$token - ;; - [\,\;]) - if [ $level = 2 -a -n "$(echo $id | $SED 's,^_pad[[:digit:]]*,,')" ] - then - check_field $1 $2 $3.$id "$fields" - test "$token" != ";" || fields= id= - fi - ;; - esac - test -z "$fields" || fields="$fields $token" - done - fi -} - -build_check () -{ - echo - echo "#define CHECK_$1 \\" - local level=1 fields= kind= id= arrlvl=1 token - for token in $2 - do - case "$token" in - struct|union) - if [ $level = 1 ] - then - kind=$token - printf %s " CHECK_SIZE_($kind, $1)" - elif [ $level = 2 ] - then - fields=" " - fi - ;; - "{") - level=$(expr $level + 1) id= - ;; - "}") - level=$(expr $level - 1) id= - ;; - "[") - arrlvl=$(expr $arrlvl + 1) - ;; - "]") - arrlvl=$(expr $arrlvl - 1) - ;; - compat_*_t) - if [ $level = 2 -a $token != compat_argo_port_t ] - then - fields=" " - token="${token%_t}" - token="${token#compat_}" - fi - ;; - [a-zA-Z_]*) - test $level != 2 -o $arrlvl != 1 || id=$token - ;; - [\,\;]) - if [ $level = 2 -a -n "$(echo $id | $SED 's,^_pad[[:digit:]]*,,')" ] - then - check_field $kind $1 $id "$fields" - test "$token" != ";" || fields= id= - fi - ;; - esac - test -z "$fields" || fields="$fields $token" - done - echo "" -} - -list="$($SED -e 's,^[[:space:]]#.*,,' -e 's!\([]\[,;:{}]\)! \1 !g' $3)" -fields="$(get_fields $(echo $2 | $SED 's,^compat_xen,compat_,') "$list")" -if [ -z "$fields" ] -then - echo "Fields of '$2' not found in '$3'" >&2 - exit 1 -fi -name=${2#compat_} -name=${name#xen} -case "$1" in -"!") - typedefs="$(get_typedefs "$list")" - build_enums $name "$fields" - build_body $name "$fields" - ;; -"?") - build_check $name "$fields" - ;; -*) - echo "Invalid translation indicator: '$1'" >&2 - exit 1 - ;; -esac From patchwork Wed Jun 1 16:59:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony PERARD X-Patchwork-Id: 12867072 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CAB77C433EF for ; Wed, 1 Jun 2022 16:59:42 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.340583.565667 (Exim 4.92) (envelope-from ) id 1nwRgz-0000Yv-ME; Wed, 01 Jun 2022 16:59:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 340583.565667; Wed, 01 Jun 2022 16:59:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nwRgz-0000Yo-JF; Wed, 01 Jun 2022 16:59:33 +0000 Received: by outflank-mailman (input) for mailman id 340583; Wed, 01 Jun 2022 16:59:32 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1nwRgy-0008OC-J8 for xen-devel@lists.xenproject.org; Wed, 01 Jun 2022 16:59:32 +0000 Received: from esa2.hc3370-68.iphmx.com (esa2.hc3370-68.iphmx.com [216.71.145.153]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3345643a-e1cc-11ec-bd2c-47488cf2e6aa; Wed, 01 Jun 2022 18:59:31 +0200 (CEST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3345643a-e1cc-11ec-bd2c-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1654102770; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lTcMhdu7U3PbutCiovcP5+LL1tCro+vwpmFhh06+tHU=; b=HDHkZMN6n30hVAZN2MKH+LXvMUEx0ozJUY54MirDnBYAKWcf5VAK5MzC Lz/DzZr4ocTHPOpoLs1zK8CyGYLFHocWT+6Uwnj/W+DFhg0xsrphq8vrz PVA6SgWsFp30PJj2wHF2LFlFz2nA0kO7agoBNxorV7ORhH0ZfsXw29zmh w=; Authentication-Results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 5.1 X-MesageID: 72647996 X-Ironport-Server: esa2.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:fC3eBqL6t0KeJT3uFE+RqZUlxSXFcZb7ZxGr2PjKsXjdYENS3jwEm mcaWW7SaPyDZWr8eIhxYIq2oE5SvZHSn9RjTAdlqX01Q3x08seUXt7xwmUcns+xwm8vaGo9s q3yv/GZdJhcokf0/0vrav67xZVF/fngqoDUUYYoAQgsA149IMsdoUg7wbRh3NYx2YLR7z6l4 rseneWOYDdJ5BYsWo4kw/rrRMRH5amaVJsw5zTSVNgT1LPsvyB94KE3fMldG0DQUIhMdtNWc s6YpF2PEsE1yD92Yj+tuu6TnkTn2dc+NyDW4pZdc/DKbhSvOkXee0v0XRYRQR4/ttmHozx+4 OdKrbH3FyZyBbHzttQ9Sz0GNnxHYoQTrdcrIVDn2SCS50jPcn+qyPRyFkAme4Yf/46bA0kXq 6ZecmpUKEne2aTmm9pXScE17ignBMDtIIMYvGAm1TzDBOwqaZvCX7/L9ZlT2zJYasVmQqyAO 5VIOGQHgBLoQxlEJ04dT6kCpMS0vFXZbQMDkXeHqv9ii4TU5FMoi+W8WDbPQfSRXtlclEuco mPA/kz6DwscOdjZziCKmlqzgsffkCW9X5gdfJW66/prjVu71mEVThoMWjOTsfS/z0KzRd9bA 0gV4TY167g/8lSxSdvwVAH+p2SL1jYeUddNF+wx6CmW17HZpQ2eAwA5oiVpMYJ88pVsHHpzi wHPz4iB6SFTXKO9e3WF2/DKjGiJJRc7HU8aQXEhEDJayoy2yG0stS4jXuqPAYbs0ICpQW2vn WvaxMQtr+5N1JBWjs1X6XiC2mvx/caRE2bZ8y2NBgqYAhVFiJlJjmBCwXzS9r5+IYmQVTFtV 1BUypHFvIji4Xxg/RFhodnh/5nzvp5pyBWG3TZS82AJrlxBAUKLc4FK+y1ZL0x0KMsCcjKBS BaN5F8JvsULYyX1NPYfj2eN5yMClPGIKDgYfqqMMoomjmZZL2drAx2ClWbPhjuwwSDAYIk0O IuBcNbEMEv2/Z9PlWLsL89EiOdD7nlnmQv7GMGgpzz6gOX2WZJgYepcWLd4RrthvP3sTcS82 4s3CvZmPD0FD7OuOXmMq9FNRb3IRFBiba3LRwVsXrbrCmJb9KsJUJc9HZtJl1RZoplo IronPort-HdrOrdr: A9a23:xdWcsqHGaflyk95hpLqE0MeALOsnbusQ8zAXP0AYc3Jom6uj5q aTdZUgpGfJYVkqOE3I9ertBEDEewK4yXcX2/h3AV7BZniEhILAFugLhuGO/9SjIVybygc079 YYT0EUMrzN5DZB4voSmDPIceod/A== X-IronPort-AV: E=Sophos;i="5.91,268,1647316800"; d="scan'208";a="72647996" From: Anthony PERARD To: CC: Anthony PERARD , Andrew Cooper , George Dunlap , "Jan Beulich" , Julien Grall , "Stefano Stabellini" , Wei Liu Subject: [XEN PATCH 4/4] build: remove auto.conf prerequisite from compat/xlat.h target Date: Wed, 1 Jun 2022 17:59:09 +0100 Message-ID: <20220601165909.46588-5-anthony.perard@citrix.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220601165909.46588-1-anthony.perard@citrix.com> References: <20220601165909.46588-1-anthony.perard@citrix.com> MIME-Version: 1.0 Now that the command line generating "xlat.h" is check on rebuild, the header will be regenerated whenever the list of xlat headers changes due to change in ".config". We don't need to force a regeneration for every changes in ".config". Signed-off-by: Anthony PERARD Acked-by: Jan Beulich --- xen/include/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/include/Makefile b/xen/include/Makefile index b7e7148665..937a8bc884 100644 --- a/xen/include/Makefile +++ b/xen/include/Makefile @@ -99,7 +99,7 @@ cmd_xlat_h = \ cat $(filter %.h,$^) >$@.new; \ mv -f $@.new $@ -$(obj)/compat/xlat.h: $(addprefix $(obj)/compat/.xlat/,$(xlat-y)) $(obj)/config/auto.conf FORCE +$(obj)/compat/xlat.h: $(addprefix $(obj)/compat/.xlat/,$(xlat-y)) FORCE $(call if_changed,xlat_h) ifeq ($(XEN_TARGET_ARCH),$(XEN_COMPILE_ARCH))