From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org
Subject: [committed] Introduce struct pipe
Date: Tue, 13 Apr 2021 14:32:00 +0200 [thread overview]
Message-ID: <20210413123158.GA16612@delia> (raw)
Hi,
Introduce struct pipe that names the read and write fd of a pipe.
Committed to trunk.
Thanks,
- Tom
Introduce struct pipe
2021-04-13 Tom de Vries <tdevries@suse.de>
* dwz.c (struct pipe): New type.
(pipes): Change variable type to struct type *.
(get_token, pass_token, dwz_files_1): Update.
---
dwz.c | 22 +++++++++++++---------
1 file changed, 13 insertions(+), 9 deletions(-)
diff --git a/dwz.c b/dwz.c
index 879fae6..a3b289f 100644
--- a/dwz.c
+++ b/dwz.c
@@ -15147,18 +15147,23 @@ write_multifile_1 (DSO *dso, struct file_result *res)
return ret;
}
+struct pipe
+{
+ int readfd;
+ int writefd;
+};
+
static bool write_multifile_parallel_p;
static int child_id;
-static int *pipes;
+static struct pipe *pipes;
/* Get token. */
static void
get_token (void)
{
int n = child_id;
- int *base = &pipes[n * 2];
- int readfd = base[0];
- int writefd = base[1];
+ int readfd = pipes[n].readfd;
+ int writefd = pipes[n].writefd;
close (writefd);
char buf;
read (readfd, &buf, 1);
@@ -15169,9 +15174,8 @@ get_token (void)
static void
pass_token (int n)
{
- int *base = &pipes[n * 2];
- int readfd = base[0];
- int writefd = base[1];
+ int readfd = pipes[n].readfd;
+ int writefd = pipes[n].writefd;
close (readfd);
char buf = '\0';
write (writefd, &buf, 1);
@@ -16536,8 +16540,8 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink,
int fds[2];
if (pipe (fds) != 0)
error (1, ENOMEM, "failed to initialize pipe");
- pipes[i * 2] = fds[0];
- pipes[i * 2 + 1] = fds[1];
+ pipes[i].readfd = fds[0];
+ pipes[i].writefd = fds[1];
}
}
else
reply other threads:[~2021-04-13 12:32 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=20210413123158.GA16612@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).