From patchwork Fri Dec 27 13:42:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 11311173 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E861C14DB for ; Fri, 27 Dec 2019 13:43:46 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id C395F20882 for ; Fri, 27 Dec 2019 13:43:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=citrix.com header.i=@citrix.com header.b="A2hWZmbx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C395F20882 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=citrix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ikpt6-0003AL-2R; Fri, 27 Dec 2019 13:42:44 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ikpt4-0003AG-Mj for xen-devel@lists.xenproject.org; Fri, 27 Dec 2019 13:42:42 +0000 X-Inumbo-ID: c0b93876-28ae-11ea-9c08-12813bfff9fa Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c0b93876-28ae-11ea-9c08-12813bfff9fa; Fri, 27 Dec 2019 13:42:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1577454161; h=from:to:cc:subject:date:message-id:mime-version; bh=SrW7uG5mOIvJQxTTZgyE+7Erxi2kx5cJv8pzzuddk2s=; b=A2hWZmbxV1GjtxGJOgr9GnrfjSaLahU604daaS4dwmWJe3DM88bZIr5S bV3EELmYx3cLIRWnAjubrk9IvXpQZYZoOeNRAcX6K614EXZ1N0OLfo5I/ lqJwY9jv+VQgvJJ7qCUx27YmmKErvyrX6faTPoqTNtxrREGQZ6RdhvA6T 8=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@citrix.com; spf=Pass smtp.mailfrom=Andrew.Cooper3@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of andrew.cooper3@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="andrew.cooper3@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of Andrew.Cooper3@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="Andrew.Cooper3@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="Andrew.Cooper3@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: aNmjRBvUO3OkY1dqFm5xZb4z6uz3Xmy/kf51BsEHWGeYErKXqNXDAMK6aKcA5AK+gNDANRwRuY uJhdSPD8BmTgHUtfeOfvkIr0nB36maJnavBO/64iGX+fFWg56hJBhR7Svy0TV4owqeVudBwiI8 dY8uF57WkPxgy/iYsCQWKzl8P+zPfa3vRnbPDtqwMfVRSKuysgommHDxjqQKgUnOHuj5+soDGD 5opJuV+ouxDgiGCz7u9I2pc5VObC1mMOUqQ3onzhdHg0+C6QsjjuZhmHyTGqV+4yGerXwWGoLV K/I= X-SBRS: 2.7 X-MesageID: 10345413 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,363,1571716800"; d="scan'208";a="10345413" From: Andrew Cooper To: Xen-devel Date: Fri, 27 Dec 2019 13:42:37 +0000 Message-ID: <20191227134237.12530-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Subject: [Xen-devel] [PATCH] tools/libxl: Code-gen improvements for libxl_save_msgs_gen.pl X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Anthony Perard , Andrew Cooper , Wei Liu , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" our @msgs() is an array of $msginfo's where the first element is a unique number. The $msgnum_used check ensures they are unique. Instead if specifying them explicitly, generate msgnum locally. This reduces the diff necessary to edit the middle of the @msgs() array. All other hunks are adjusting formatting in the generated C, to make it easier to follow. No change in behaviour of the generated C. Signed-off-by: Andrew Cooper Reviewed-by: Anthony PERARD --- CC: Ian Jackson CC: Wei Liu CC: Anthony Perard --- tools/libxl/libxl_save_msgs_gen.pl | 56 +++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/tools/libxl/libxl_save_msgs_gen.pl b/tools/libxl/libxl_save_msgs_gen.pl index cba7a30e4c..6f1d79f821 100755 --- a/tools/libxl/libxl_save_msgs_gen.pl +++ b/tools/libxl/libxl_save_msgs_gen.pl @@ -15,24 +15,24 @@ our @msgs = ( # and its null-ness needs to be passed through to the helper's xc # W - needs a return value; callback is synchronous # A - needs a return value; callback is asynchronous - [ 1, 'sr', "log", [qw(uint32_t level - uint32_t errnoval - STRING context - STRING formatted)] ], - [ 2, 'sr', "progress", [qw(STRING context - STRING doing_what), - 'unsigned long', 'done', - 'unsigned long', 'total'] ], - [ 3, 'srcxA', "suspend", [] ], - [ 4, 'srcxA', "postcopy", [] ], - [ 5, 'srcxA', "checkpoint", [] ], - [ 6, 'srcxA', "wait_checkpoint", [] ], - [ 7, 'scxA', "switch_qemu_logdirty", [qw(uint32_t domid - unsigned enable)] ], - [ 8, 'rcx', "restore_results", ['xen_pfn_t', 'store_gfn', - 'xen_pfn_t', 'console_gfn'] ], - [ 9, 'srW', "complete", [qw(int retval - int errnoval)] ], + [ 'sr', "log", [qw(uint32_t level + uint32_t errnoval + STRING context + STRING formatted)] ], + [ 'sr', "progress", [qw(STRING context + STRING doing_what), + 'unsigned long', 'done', + 'unsigned long', 'total'] ], + [ 'srcxA', "suspend", [] ], + [ 'srcxA', "postcopy", [] ], + [ 'srcxA', "checkpoint", [] ], + [ 'srcxA', "wait_checkpoint", [] ], + [ 'scxA', "switch_qemu_logdirty", [qw(uint32_t domid + unsigned enable)] ], + [ 'rcx', "restore_results", ['xen_pfn_t', 'store_gfn', + 'xen_pfn_t', 'console_gfn'] ], + [ 'srW', "complete", [qw(int retval + int errnoval)] ], ); #---------------------------------------- @@ -43,7 +43,7 @@ our %func_ah; our @outfuncs; our %out_decls; our %out_body; -our %msgnum_used; +our $msgnum = 0; die unless @ARGV==1; die if $ARGV[0] =~ m/^-/; @@ -123,7 +123,7 @@ static int bytes_get(const unsigned char **msg, void *result, int rlen) { if (endmsg - *msg < rlen) return 0; - memcpy(result,*msg,rlen); + memcpy(result, *msg, rlen); *msg += rlen; return 1; } @@ -167,7 +167,7 @@ static int BLOCK_get(const unsigned char **msg, const unsigned char *const endmsg, const uint8_t **result, uint32_t *result_size) { - if (!uint32_t_get(msg,endmsg,result_size)) return 0; + if (!uint32_t_get(msg, endmsg, result_size)) return 0; if (endmsg - *msg < *result_size) return 0; *result = (const void*)*msg; *msg += *result_size; @@ -180,7 +180,7 @@ static int STRING_get(const unsigned char **msg, { const uint8_t *data; uint32_t datalen; - if (!BLOCK_get(msg,endmsg,&data,&datalen)) return 0; + if (!BLOCK_get(msg, endmsg, &data, &datalen)) return 0; if (datalen == 0) return 0; if (data[datalen-1] != '\\0') return 0; *result = (const void*)data; @@ -228,7 +228,7 @@ foreach my $sr (qw(save restore)) { <(" const uint8_t *$arg;\n". " uint32_t ${arg}_size;\n"); } else { @@ -299,7 +299,7 @@ END_ALWAYS } $c_callback_args .= "$c_args, "; $c_recv.= - " if (!${typeid}_get(&msg,endmsg,$c_get_args)) return 0;\n"; + " if (!${typeid}_get(&msg, endmsg, $c_get_args)) return 0;\n"; f_more("${encode}_$name", " ${typeid}_put(buf, &len, $c_args);\n"); } $f_more_sr->($c_recv); @@ -369,7 +369,7 @@ foreach my $sr (qw(save restore)) { f_more("${receiveds}_${sr}", " default:\n". " return 0;\n". - " }"); + " }\n"); $cbs{$sr} .= "} ".cbtype($sr).";\n\n"; if ($ch eq 'h') { print $cbs{$sr} or die $!;