From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org
Subject: [committed] Add ret to struct file_result
Date: Mon, 29 Mar 2021 08:36:55 +0200 [thread overview]
Message-ID: <20210329063654.GA3469@delia> (raw)
Hi,
Further simplify the serial/parallel code in dwz_files_1 by factoring out the
return status handling. Add a ret field to struct file_result to store the
per-file return status.
Committed to trunk.
Thanks,
- Tom
Add ret to struct file_result
2021-03-29 Tom de Vries <tdevries@suse.de>
* dwz.c (struct file_result): Add ret field.
(wait_child_exit): Return void. Set ret.
(wait_children_exit): Return void. Update call to wait_child_exit.
(dwz_files_1): Move return status handling out of serial/parallel code.
---
dwz.c | 68 ++++++++++++++++++++++++++++++++-----------------------------------
1 file changed, 32 insertions(+), 36 deletions(-)
diff --git a/dwz.c b/dwz.c
index 377e1be..de600c1 100644
--- a/dwz.c
+++ b/dwz.c
@@ -15049,6 +15049,7 @@ struct file_result
0: Processed, changed.
1: Processed, unchanged. */
int res;
+ int ret;
size_t hardlink_to;
unsigned int die_count;
bool skip_multifile;
@@ -16444,7 +16445,7 @@ decode_child_exit_status (int state, struct file_result *res)
}
/* Wait on child exit with PID, update PIDS and RES. */
-static int
+static void
wait_child_exit (pid_t pid, pid_t *pids, int nr_pids,
struct file_result *resa)
{
@@ -16460,28 +16461,21 @@ wait_child_exit (pid_t pid, pid_t *pids, int nr_pids,
}
assert (i < nr_pids);
- return decode_child_exit_status (state, &resa[i]);
+ resa[i].ret = decode_child_exit_status (state, &resa[i]);
}
/* Wait on exit of chilren in PIDS, update RESA. */
-static int
+static void
wait_children_exit (pid_t *pids, int nr_files, struct file_result *resa)
{
- int ret = 0;
-
int i;
for (i = 0; i < nr_files; i++)
{
- int thisret;
struct file_result *res = &resa[i];
if (pids[i] == 0)
continue;
- thisret = wait_child_exit (pids[i], &pids[i], 1, res);
- if (thisret == 1)
- ret = 1;
+ wait_child_exit (pids[i], &pids[i], 1, res);
}
-
- return ret;
}
/* Dwarf-compress FILES. If HARDLINK, detect if some files are hardlinks and
@@ -16540,13 +16534,10 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink,
for (j = 0; j < workset_size; j++)
{
int i = workset[j];
- int thisret;
if (nr_forks == max_forks)
{
- int thisret = wait_child_exit (-1, pids, i, resa);
- if (thisret == 1)
- ret = 1;
+ wait_child_exit (-1, pids, i, resa);
nr_forks--;
}
@@ -16556,7 +16547,7 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink,
{
file = files[i];
struct file_result *res = &resa[i];
- thisret = dwz_with_low_mem (file, NULL, res);
+ int thisret = dwz_with_low_mem (file, NULL, res);
return encode_child_exit_status (thisret, res);
}
else
@@ -16566,30 +16557,32 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink,
}
}
if (nr_forks > 0)
- {
- int thisret = wait_children_exit (pids, nr_files, resa);
- if (thisret == 1)
- ret = 1;
- }
+ wait_children_exit (pids, nr_files, resa);
}
else
{
for (j = 0; j < workset_size; j++)
{
int i = workset[j];
- int thisret;
file = files[i];
struct file_result *res = &resa[i];
if (stats_p)
init_stats (file);
- thisret = dwz_with_low_mem (file, NULL, res);
- if (thisret == 1)
- ret = 1;
- else if (!res->low_mem_p && !res->skip_multifile && res->res >= 0)
- successcount++;
+ res->ret = dwz_with_low_mem (file, NULL, res);
}
}
+ for (j = 0; j < workset_size; j++)
+ {
+ int i = workset[j];
+ struct file_result *res = &resa[i];
+ int thisret = res->ret;
+ if (thisret == 1)
+ ret = 1;
+ else if (!res->low_mem_p && !res->skip_multifile && res->res >= 0)
+ successcount++;
+ }
+
if (hardlink)
update_hardlinks (nr_files, files, resa);
@@ -16647,9 +16640,7 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink,
if (nr_forks == max_forks)
{
- int thisret = wait_child_exit (-1, pids, i, resa);
- if (thisret == 1)
- ret = 1;
+ wait_child_exit (-1, pids, i, resa);
nr_forks--;
}
@@ -16670,17 +16661,14 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink,
}
}
if (nr_forks > 0)
- {
- int thisret = wait_children_exit (pids, nr_files, resa);
- if (thisret == 1)
- ret = 1;
- }
+ wait_children_exit (pids, nr_files, resa);
}
else
{
for (j = 0; j < workset_size; j++)
{
int i = workset[j];
+ struct file_result *res = &resa[i];
dw_cu_ref cu;
file = files[i];
if (stats_p)
@@ -16688,10 +16676,18 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink,
multifile_mode = MULTIFILE_MODE_FI;
for (cu = alt_first_cu; cu; cu = cu->cu_next)
alt_clear_dups (cu->cu_die);
- ret |= dwz (file, NULL, &resa[i]);
+ res->ret = dwz (file, NULL, res);
}
}
+ for (j = 0; j < workset_size; j++)
+ {
+ int i = workset[j];
+ struct file_result *res = &resa[i];
+ int thisret = res->ret;
+ ret |= thisret;
+ }
+
if (hardlink)
update_hardlinks (nr_files, files, resa);
reply other threads:[~2021-03-29 6:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20210329063654.GA3469@delia \
--to=tdevries@suse.de \
--cc=dwz@sourceware.org \
--cc=jakub@redhat.com \
--cc=mark@klomp.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).