From d3d86f711a339ed1a875e25ae456e90059eb18bb Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Fri, 20 Dec 2019 12:42:47 +0000 Subject: [PATCH] tools/libxl: Code-gen improvements for libxl_save_msgs_gen.pl 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 --- 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 $!; -- 2.39.5