All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tzvetomir Stoyanov <tstoyanov@vmware.com>
To: "rostedt@goodmis.org" <rostedt@goodmis.org>
Cc: "linux-trace-devel@vger.kernel.org" <linux-trace-devel@vger.kernel.org>
Subject: [PATCH v3 07/15] tools/lib/traceevent: traceevent API cleanup
Date: Wed, 28 Nov 2018 09:07:37 +0000	[thread overview]
Message-ID: <20181128090711.17792-8-tstoyanov@vmware.com> (raw)
In-Reply-To: <20181128090711.17792-1-tstoyanov@vmware.com>

In order to make libtraceevent into a proper library, its API
should be straightforward. This patch hides few API functions,
intended for internal usage only:
tep_free_event(), tep_free_format_field(), __tep_data2host2(),
__tep_data2host4() and __tep_data2host8().
The patch also alignes the libtraceevent summary man page with
these API changes.

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
---
 tools/lib/traceevent/event-parse-api.c   |  6 +++---
 tools/lib/traceevent/event-parse-local.h |  7 +++++++
 tools/lib/traceevent/event-parse.c       | 13 ++++++++-----
 tools/lib/traceevent/event-parse.h       | 18 ------------------
 4 files changed, 18 insertions(+), 26 deletions(-)

diff --git a/tools/lib/traceevent/event-parse-api.c b/tools/lib/traceevent/event-parse-api.c
index 52188921cfe3..bdefe3c235ad 100644
--- a/tools/lib/traceevent/event-parse-api.c
+++ b/tools/lib/traceevent/event-parse-api.c
@@ -51,7 +51,7 @@ void tep_set_flag(struct tep_handle *tep, int flag)
 		tep->flags |= flag;
 }
 
-unsigned short __tep_data2host2(struct tep_handle *pevent, unsigned short data)
+unsigned short tep_data2host2(struct tep_handle *pevent, unsigned short data)
 {
 	unsigned short swap;
 
@@ -64,7 +64,7 @@ unsigned short __tep_data2host2(struct tep_handle *pevent, unsigned short data)
 	return swap;
 }
 
-unsigned int __tep_data2host4(struct tep_handle *pevent, unsigned int data)
+unsigned int tep_data2host4(struct tep_handle *pevent, unsigned int data)
 {
 	unsigned int swap;
 
@@ -80,7 +80,7 @@ unsigned int __tep_data2host4(struct tep_handle *pevent, unsigned int data)
 }
 
 unsigned long long
-__tep_data2host8(struct tep_handle *pevent, unsigned long long data)
+tep_data2host8(struct tep_handle *pevent, unsigned long long data)
 {
 	unsigned long long swap;
 
diff --git a/tools/lib/traceevent/event-parse-local.h b/tools/lib/traceevent/event-parse-local.h
index 94746efef433..9a092dd4a86d 100644
--- a/tools/lib/traceevent/event-parse-local.h
+++ b/tools/lib/traceevent/event-parse-local.h
@@ -89,4 +89,11 @@ struct tep_handle {
 	char *trace_clock;
 };
 
+void tep_free_event(struct tep_event *event);
+void tep_free_format_field(struct tep_format_field *field);
+
+unsigned short tep_data2host2(struct tep_handle *pevent, unsigned short data);
+unsigned int tep_data2host4(struct tep_handle *pevent, unsigned int data);
+unsigned long long tep_data2host8(struct tep_handle *pevent, unsigned long long data);
+
 #endif /* _PARSE_EVENTS_INT_H */
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 7140b845e20f..668bc5e2805f 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3343,15 +3343,18 @@ tep_find_any_field(struct tep_event *event, const char *name)
 unsigned long long tep_read_number(struct tep_handle *pevent,
 				   const void *ptr, int size)
 {
+	unsigned long long val;
+
 	switch (size) {
 	case 1:
 		return *(unsigned char *)ptr;
 	case 2:
-		return tep_data2host2(pevent, ptr);
+		return tep_data2host2(pevent, *(unsigned short *)ptr);
 	case 4:
-		return tep_data2host4(pevent, ptr);
+		return tep_data2host4(pevent, *(unsigned int *)ptr);
 	case 8:
-		return tep_data2host8(pevent, ptr);
+		memcpy(&val, (ptr), sizeof(unsigned long long));
+		return tep_data2host8(pevent, val);
 	default:
 		/* BUG! */
 		return 0;
@@ -4077,7 +4080,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
 			f = tep_find_any_field(event, arg->string.string);
 			arg->string.offset = f->offset;
 		}
-		str_offset = tep_data2host4(pevent, data + arg->string.offset);
+		str_offset = tep_data2host4(pevent, *(unsigned int *)(data + arg->string.offset));
 		str_offset &= 0xffff;
 		print_str_to_seq(s, format, len_arg, ((char *)data) + str_offset);
 		break;
@@ -4095,7 +4098,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
 			f = tep_find_any_field(event, arg->bitmask.bitmask);
 			arg->bitmask.offset = f->offset;
 		}
-		bitmask_offset = tep_data2host4(pevent, data + arg->bitmask.offset);
+		bitmask_offset = tep_data2host4(pevent, *(unsigned int *)(data + arg->bitmask.offset));
 		bitmask_size = bitmask_offset >> 16;
 		bitmask_offset &= 0xffff;
 		print_bitmask_to_seq(pevent, s, format, len_arg,
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 0c8548bf234c..4e0602522c28 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -409,22 +409,6 @@ void tep_print_plugins(struct trace_seq *s,
 typedef char *(tep_func_resolver_t)(void *priv,
 				    unsigned long long *addrp, char **modp);
 void tep_set_flag(struct tep_handle *tep, int flag);
-unsigned short __tep_data2host2(struct tep_handle *pevent, unsigned short data);
-unsigned int __tep_data2host4(struct tep_handle *pevent, unsigned int data);
-unsigned long long
-__tep_data2host8(struct tep_handle *pevent, unsigned long long data);
-
-#define tep_data2host2(pevent, ptr)	\
-	__tep_data2host2(pevent, *(unsigned short *)(ptr))
-#define tep_data2host4(pevent, ptr)	\
-	__tep_data2host4(pevent, *(unsigned int *)(ptr))
-#define tep_data2host8(pevent, ptr)	\
-({								\
-	unsigned long long __val;				\
-								\
-	memcpy(&__val, (ptr), sizeof(unsigned long long));	\
-	__tep_data2host8(pevent, __val);			\
-})
 
 static inline int tep_host_bigendian(void)
 {
@@ -477,8 +461,6 @@ enum tep_errno tep_parse_format(struct tep_handle *pevent,
 				struct tep_event **eventp,
 				const char *buf,
 				unsigned long size, const char *sys);
-void tep_free_event(struct tep_event *event);
-void tep_free_format_field(struct tep_format_field *field);
 
 void *tep_get_field_raw(struct trace_seq *s, struct tep_event *event,
 			const char *name, struct tep_record *record,
-- 
2.19.1

  parent reply	other threads:[~2018-11-28 20:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-28  9:07 [PATCH v3 00/15] tools/lib/traceevent,tools/perf: Various changes in libtraceevent APIs Tzvetomir Stoyanov
2018-11-28  9:07 ` [PATCH v3 01/15] tools/lib/traceevent: Implemented new API tep_get_ref() Tzvetomir Stoyanov
2018-11-28 20:01   ` Steven Rostedt
2018-11-28  9:07 ` [PATCH v3 02/15] tools/lib/traceevent: Added support for pkg-config Tzvetomir Stoyanov
2018-11-28 20:14   ` Steven Rostedt
2018-11-28 20:15     ` Steven Rostedt
2018-11-28  9:07 ` [PATCH v3 03/15] tools/lib/traceevent: Install trace-seq.h API header file Tzvetomir Stoyanov
2018-11-28  9:07 ` [PATCH v3 04/15] tools/lib/traceevent, tools/perf: Rename struct tep_event_format to struct tep_event Tzvetomir Stoyanov
2018-11-28  9:07 ` [PATCH v3 05/15] tools/lib/traceevent: Rename tep_free_format() to tep_free_event() Tzvetomir Stoyanov
2018-11-28  9:07 ` [PATCH v3 06/15] tools/perf: traceevent API cleanup, remove __tep_data2host*() Tzvetomir Stoyanov
2018-11-28  9:07 ` Tzvetomir Stoyanov [this message]
2018-11-28  9:07 ` [PATCH v3 08/15] tools/lib/traceevent: Introduce new libtracevent API: tep_override_comm() Tzvetomir Stoyanov
2018-11-28  9:07 ` [PATCH v3 09/15] tools/lib/traceevent: Initialize host_bigendian at tep_handle allocation Tzvetomir Stoyanov
2018-11-28  9:07 ` [PATCH v3 10/15] tools/lib/traceevent: Rename struct cmdline to struct tep_cmdline Tzvetomir Stoyanov
2018-11-28  9:07 ` [PATCH v3 11/15] tools/lib/traceevent: Changed return logic of trace_seq_printf() and trace_seq_vprintf() APIs Tzvetomir Stoyanov
2018-11-28  9:07 ` [PATCH v3 12/15] tools/lib/traceevent: Changed return logic of tep_register_event_handler() API Tzvetomir Stoyanov
2018-11-28  9:07 ` [PATCH v3 13/15] tools/lib/traceevent: Rename tep_is_file_bigendian() to tep_file_bigendian() Tzvetomir Stoyanov
2018-11-28  9:07 ` [PATCH v3 14/15] tools/lib/traceevent: Change description of few APIs Tzvetomir Stoyanov
2018-12-01  3:43   ` Steven Rostedt
2018-12-01  3:58     ` Steven Rostedt
2019-03-13 15:56       ` Steven Rostedt
2018-11-28  9:07 ` [PATCH v3 15/15] tools/lib/traceevent: Remove tep_data_event_from_type() API Tzvetomir Stoyanov

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=20181128090711.17792-8-tstoyanov@vmware.com \
    --to=tstoyanov@vmware.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.