From: Slavomir Kaslev <kaslevs@vmware.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org, slavomir.kaslev@gmail.com
Subject: [PATCH 2/3] trace-cmd: Add defines for splice() flags on systems with old glibc
Date: Thu, 14 Feb 2019 16:07:22 +0200 [thread overview]
Message-ID: <20190214140723.27804-2-kaslevs@vmware.com> (raw)
In-Reply-To: <20190214140723.27804-1-kaslevs@vmware.com>
Use SPLICE_F_ defines to refer to splice() flags instead of their numeric
values. This should be only necessary on systems with glibc version < 2.5.
No changes in behavior intended.
Signed-off-by: Slavomir Kaslev <kaslevs@vmware.com>
---
lib/trace-cmd/trace-recorder.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/lib/trace-cmd/trace-recorder.c b/lib/trace-cmd/trace-recorder.c
index b941cdc..1b6a995 100644
--- a/lib/trace-cmd/trace-recorder.c
+++ b/lib/trace-cmd/trace-recorder.c
@@ -26,6 +26,13 @@
# define F_GETPIPE_SZ 1032 /* The Linux number for the option */
#endif
+#ifndef SPLICE_F_MOVE
+# define SPLICE_F_MOVE 1
+# define SPLICE_F_NONBLOCK 2
+# define SPLICE_F_MORE 4
+# define SPLICE_F_GIFT 8
+#endif
+
struct tracecmd_recorder {
int fd;
int fd1;
@@ -122,10 +129,10 @@ tracecmd_create_buffer_recorder_fd2(int fd, int fd2, int cpu, unsigned flags,
recorder->cpu = cpu;
recorder->flags = flags;
- recorder->fd_flags = 1; /* SPLICE_F_MOVE */
+ recorder->fd_flags = SPLICE_F_MOVE;
if (!(recorder->flags & TRACECMD_RECORD_BLOCK))
- recorder->fd_flags |= 2; /* and NON_BLOCK */
+ recorder->fd_flags |= SPLICE_F_NONBLOCK;
/* Init to know what to free and release */
recorder->trace_fd = -1;
@@ -349,7 +356,7 @@ static long splice_data(struct tracecmd_recorder *recorder)
long ret;
read = splice(recorder->trace_fd, NULL, recorder->brass[1], NULL,
- recorder->pipe_size, 1 /* SPLICE_F_MOVE */);
+ recorder->pipe_size, SPLICE_F_MOVE);
if (read < 0) {
if (errno != EAGAIN && errno != EINTR) {
warning("recorder error in splice input");
@@ -421,7 +428,7 @@ static void set_nonblock(struct tracecmd_recorder *recorder)
fcntl(recorder->trace_fd, F_SETFL, flags | O_NONBLOCK);
/* Do not block on streams for write */
- recorder->fd_flags |= 2; /* NON_BLOCK */
+ recorder->fd_flags |= SPLICE_F_NONBLOCK;
}
long tracecmd_flush_recording(struct tracecmd_recorder *recorder)
--
2.19.1
next prev parent reply other threads:[~2019-02-14 14:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-14 14:07 [PATCH 1/3] trace-cmd: Fix tracecmd_recorder leaking file descriptors Slavomir Kaslev
2019-02-14 14:07 ` Slavomir Kaslev [this message]
2019-02-14 14:07 ` [PATCH 3/3] trace-cmd: Removed some unused #includes Slavomir Kaslev
2019-02-14 17:32 ` Steven Rostedt
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=20190214140723.27804-2-kaslevs@vmware.com \
--to=kaslevs@vmware.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=slavomir.kaslev@gmail.com \
/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 NNTP newsgroup(s).