public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Wang Nan <wangnan0@huawei.com>
Subject: [PATCH 01/15] perf trace: Move socket_type beautifier to tools/perf/trace/beauty/
Date: Fri, 15 Apr 2016 18:50:47 -0300	[thread overview]
Message-ID: <1460757061-3283-2-git-send-email-acme@kernel.org> (raw)
In-Reply-To: <1460757061-3283-1-git-send-email-acme@kernel.org>

From: Arnaldo Carvalho de Melo <acme@redhat.com>

To reduce the size of builtin-trace.c.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/n/tip-ao91htwxdqwlwxr47gbluou1@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-trace.c            | 60 +----------------------------------
 tools/perf/trace/beauty/socket_type.c | 60 +++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 59 deletions(-)
 create mode 100644 tools/perf/trace/beauty/socket_type.c

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 8e090a785c5e..e5f0cc16bb93 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -51,18 +51,6 @@
 # define O_CLOEXEC		02000000
 #endif
 
-#ifndef SOCK_DCCP
-# define SOCK_DCCP		6
-#endif
-
-#ifndef SOCK_CLOEXEC
-# define SOCK_CLOEXEC		02000000
-#endif
-
-#ifndef SOCK_NONBLOCK
-# define SOCK_NONBLOCK		00004000
-#endif
-
 #ifndef MSG_CMSG_CLOEXEC
 # define MSG_CMSG_CLOEXEC	0x40000000
 #endif
@@ -538,53 +526,6 @@ static const char *socket_families[] = {
 };
 static DEFINE_STRARRAY(socket_families);
 
-#ifndef SOCK_TYPE_MASK
-#define SOCK_TYPE_MASK 0xf
-#endif
-
-static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size,
-						      struct syscall_arg *arg)
-{
-	size_t printed;
-	int type = arg->val,
-	    flags = type & ~SOCK_TYPE_MASK;
-
-	type &= SOCK_TYPE_MASK;
-	/*
- 	 * Can't use a strarray, MIPS may override for ABI reasons.
- 	 */
-	switch (type) {
-#define	P_SK_TYPE(n) case SOCK_##n: printed = scnprintf(bf, size, #n); break;
-	P_SK_TYPE(STREAM);
-	P_SK_TYPE(DGRAM);
-	P_SK_TYPE(RAW);
-	P_SK_TYPE(RDM);
-	P_SK_TYPE(SEQPACKET);
-	P_SK_TYPE(DCCP);
-	P_SK_TYPE(PACKET);
-#undef P_SK_TYPE
-	default:
-		printed = scnprintf(bf, size, "%#x", type);
-	}
-
-#define	P_SK_FLAG(n) \
-	if (flags & SOCK_##n) { \
-		printed += scnprintf(bf + printed, size - printed, "|%s", #n); \
-		flags &= ~SOCK_##n; \
-	}
-
-	P_SK_FLAG(CLOEXEC);
-	P_SK_FLAG(NONBLOCK);
-#undef P_SK_FLAG
-
-	if (flags)
-		printed += scnprintf(bf + printed, size - printed, "|%#x", flags);
-
-	return printed;
-}
-
-#define SCA_SK_TYPE syscall_arg__scnprintf_socket_type
-
 #ifndef MSG_PROBE
 #define MSG_PROBE	     0x10
 #endif
@@ -951,6 +892,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char *bf, size_t size,
 #include "trace/beauty/mmap.c"
 #include "trace/beauty/mode_t.c"
 #include "trace/beauty/sched_policy.c"
+#include "trace/beauty/socket_type.c"
 #include "trace/beauty/waitid_options.c"
 
 static struct syscall_fmt {
diff --git a/tools/perf/trace/beauty/socket_type.c b/tools/perf/trace/beauty/socket_type.c
new file mode 100644
index 000000000000..0a5ce818131c
--- /dev/null
+++ b/tools/perf/trace/beauty/socket_type.c
@@ -0,0 +1,60 @@
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#ifndef SOCK_DCCP
+# define SOCK_DCCP		6
+#endif
+
+#ifndef SOCK_CLOEXEC
+# define SOCK_CLOEXEC		02000000
+#endif
+
+#ifndef SOCK_NONBLOCK
+# define SOCK_NONBLOCK		00004000
+#endif
+
+#ifndef SOCK_TYPE_MASK
+#define SOCK_TYPE_MASK 0xf
+#endif
+
+static size_t syscall_arg__scnprintf_socket_type(char *bf, size_t size, struct syscall_arg *arg)
+{
+	size_t printed;
+	int type = arg->val,
+	    flags = type & ~SOCK_TYPE_MASK;
+
+	type &= SOCK_TYPE_MASK;
+	/*
+	 * Can't use a strarray, MIPS may override for ABI reasons.
+	 */
+	switch (type) {
+#define	P_SK_TYPE(n) case SOCK_##n: printed = scnprintf(bf, size, #n); break;
+	P_SK_TYPE(STREAM);
+	P_SK_TYPE(DGRAM);
+	P_SK_TYPE(RAW);
+	P_SK_TYPE(RDM);
+	P_SK_TYPE(SEQPACKET);
+	P_SK_TYPE(DCCP);
+	P_SK_TYPE(PACKET);
+#undef P_SK_TYPE
+	default:
+		printed = scnprintf(bf, size, "%#x", type);
+	}
+
+#define	P_SK_FLAG(n) \
+	if (flags & SOCK_##n) { \
+		printed += scnprintf(bf + printed, size - printed, "|%s", #n); \
+		flags &= ~SOCK_##n; \
+	}
+
+	P_SK_FLAG(CLOEXEC);
+	P_SK_FLAG(NONBLOCK);
+#undef P_SK_FLAG
+
+	if (flags)
+		printed += scnprintf(bf + printed, size - printed, "|%#x", flags);
+
+	return printed;
+}
+
+#define SCA_SK_TYPE syscall_arg__scnprintf_socket_type
-- 
2.5.5

  reply	other threads:[~2016-04-15 21:54 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-15 21:50 [GIT PULL 00/15] perf/core improvements Arnaldo Carvalho de Melo
2016-04-15 21:50 ` Arnaldo Carvalho de Melo [this message]
2016-04-15 21:50 ` [PATCH 02/15] perf callchain: Start moving away from global per thread cursors Arnaldo Carvalho de Melo
2016-04-15 21:50 ` [PATCH 03/15] perf evsel: Remove symbol_conf usage Arnaldo Carvalho de Melo
2016-04-15 21:50 ` [PATCH 04/15] perf symbols: Move fprintf routines to separate object file Arnaldo Carvalho de Melo
2016-04-15 21:50 ` [PATCH 05/15] perf evsel: Require that callchains be resolved before calling fprintf_{sym,callchain} Arnaldo Carvalho de Melo
2016-04-15 21:50 ` [PATCH 06/15] perf tools: Remove addr_location argument to sample__fprintf_callchain Arnaldo Carvalho de Melo
2016-04-15 21:50 ` [PATCH 07/15] perf script: Add --max-stack knob Arnaldo Carvalho de Melo
2016-04-15 21:50 ` [PATCH 08/15] perf trace: " Arnaldo Carvalho de Melo
2016-04-15 21:50 ` [PATCH 09/15] perf evsel: Move fprintf methods to separate source file Arnaldo Carvalho de Melo
2016-04-15 21:50 ` [PATCH 10/15] perf trace: Do not print interrupted syscalls when using --duration Arnaldo Carvalho de Melo
2016-04-15 21:50 ` [PATCH 11/15] perf trace: Introduce --min-stack filter Arnaldo Carvalho de Melo
2016-04-15 21:50 ` [PATCH 12/15] perf record: Export record_opts based callchain parsing helper Arnaldo Carvalho de Melo
2016-04-15 21:50 ` [PATCH 13/15] perf trace: Make --(min,max}-stack imply "--call-graph dwarf" Arnaldo Carvalho de Melo
2016-04-15 21:51 ` [PATCH 14/15] perf evlist: Expose perf_event_mlock_kb_in_pages() helper Arnaldo Carvalho de Melo
2016-04-15 21:51 ` [PATCH 15/15] perf trace: Bump --mmap-pages when --call-graph is used by the root user Arnaldo Carvalho de Melo
2016-04-16  9:12 ` [GIT PULL 00/15] perf/core improvements Ingo Molnar

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=1460757061-3283-2-git-send-email-acme@kernel.org \
    --to=acme@kernel.org \
    --cc=acme@redhat.com \
    --cc=adrian.hunter@intel.com \
    --cc=dsahern@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung@kernel.org \
    --cc=wangnan0@huawei.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