diff mbox series

[1/3] tools/lib/traceevent: Implemented new API tep_ref_get()

Message ID 20180928071940.29810-2-tstoyanov@vmware.com (mailing list archive)
State Superseded, archived
Headers show
Series libtraceevent: Added support for pkg-config and few other fixes related to transfoming traceevent into a library | expand

Commit Message

Tzvetomir Stoyanov Sept. 28, 2018, 7:19 a.m. UTC
This patch implements new API of the tracevent library:
int tep_ref_get(struct tep_handle *pevent);
The API returns the reference counter "ref_count" of the tep handler.
As "struct tep_handle" is internal only, its members cannot be accessed
by the library users, the API is used to get the reference counter.

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
---
 tools/lib/traceevent/event-parse.c | 7 +++++++
 tools/lib/traceevent/event-parse.h | 1 +
 2 files changed, 8 insertions(+)

Comments

Steven Rostedt Nov. 20, 2018, 3:54 a.m. UTC | #1
On Fri, 28 Sep 2018 10:19:38 +0300
Tzvetomir Stoyanov <tstoyanov@vmware.com> wrote:

> This patch implements new API of the tracevent library:
> int tep_ref_get(struct tep_handle *pevent);
> The API returns the reference counter "ref_count" of the tep handler.
> As "struct tep_handle" is internal only, its members cannot be accessed
> by the library users, the API is used to get the reference counter.
> 
> Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
> ---
>  tools/lib/traceevent/event-parse.c | 7 +++++++
>  tools/lib/traceevent/event-parse.h | 1 +
>  2 files changed, 8 insertions(+)
> 
> diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> index f327c990dedc..aa26d0e7c074 100644
> --- a/tools/lib/traceevent/event-parse.c
> +++ b/tools/lib/traceevent/event-parse.c
> @@ -6774,6 +6774,13 @@ void tep_ref(struct tep_handle *pevent)
>  	pevent->ref_count++;
>  }
>  
> +int tep_ref_get(struct tep_handle *pevent)

Hmm, I'm thinking we should call this "tep_get_ref" as that fits more
the naming convention of the Linux kernel.

-- Steve


> +{
> +	if (pevent)
> +		return pevent->ref_count;
> +	return 0;
> +}
> +
>  void tep_free_format_field(struct tep_format_field *field)
>  {
>  	free(field->type);
> diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
> index 100b0b7b29fc..cda21a67160e 100644
> --- a/tools/lib/traceevent/event-parse.h
> +++ b/tools/lib/traceevent/event-parse.h
> @@ -577,6 +577,7 @@ struct tep_handle *tep_alloc(void);
>  void tep_free(struct tep_handle *pevent);
>  void tep_ref(struct tep_handle *pevent);
>  void tep_unref(struct tep_handle *pevent);
> +int tep_ref_get(struct tep_handle *pevent);
>  
>  /* access to the internal parser */
>  void tep_buffer_init(const char *buf, unsigned long long size);
Tzvetomir Stoyanov Nov. 20, 2018, 8:05 a.m. UTC | #2
On Tue, Nov 20, 2018 at 5:54 AM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> On Fri, 28 Sep 2018 10:19:38 +0300
> Tzvetomir Stoyanov <tstoyanov@vmware.com> wrote:
>
> > This patch implements new API of the tracevent library:
> > int tep_ref_get(struct tep_handle *pevent);
> > The API returns the reference counter "ref_count" of the tep handler.
> > As "struct tep_handle" is internal only, its members cannot be accessed
> > by the library users, the API is used to get the reference counter.
> >
> > Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
> > ---
> >  tools/lib/traceevent/event-parse.c | 7 +++++++
> >  tools/lib/traceevent/event-parse.h | 1 +
> >  2 files changed, 8 insertions(+)
> >
> > diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
> > index f327c990dedc..aa26d0e7c074 100644
> > --- a/tools/lib/traceevent/event-parse.c
> > +++ b/tools/lib/traceevent/event-parse.c
> > @@ -6774,6 +6774,13 @@ void tep_ref(struct tep_handle *pevent)
> >       pevent->ref_count++;
> >  }
> >
> > +int tep_ref_get(struct tep_handle *pevent)
>
> Hmm, I'm thinking we should call this "tep_get_ref" as that fits more
> the naming convention of the Linux kernel.
>
> -- Steve

Ok, going to send a V2 of this patch



>
> > +{
> > +     if (pevent)
> > +             return pevent->ref_count;
> > +     return 0;
> > +}
> > +
> >  void tep_free_format_field(struct tep_format_field *field)
> >  {
> >       free(field->type);
> > diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
> > index 100b0b7b29fc..cda21a67160e 100644
> > --- a/tools/lib/traceevent/event-parse.h
> > +++ b/tools/lib/traceevent/event-parse.h
> > @@ -577,6 +577,7 @@ struct tep_handle *tep_alloc(void);
> >  void tep_free(struct tep_handle *pevent);
> >  void tep_ref(struct tep_handle *pevent);
> >  void tep_unref(struct tep_handle *pevent);
> > +int tep_ref_get(struct tep_handle *pevent);
> >
> >  /* access to the internal parser */
> >  void tep_buffer_init(const char *buf, unsigned long long size);
>
diff mbox series

Patch

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index f327c990dedc..aa26d0e7c074 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -6774,6 +6774,13 @@  void tep_ref(struct tep_handle *pevent)
 	pevent->ref_count++;
 }
 
+int tep_ref_get(struct tep_handle *pevent)
+{
+	if (pevent)
+		return pevent->ref_count;
+	return 0;
+}
+
 void tep_free_format_field(struct tep_format_field *field)
 {
 	free(field->type);
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h
index 100b0b7b29fc..cda21a67160e 100644
--- a/tools/lib/traceevent/event-parse.h
+++ b/tools/lib/traceevent/event-parse.h
@@ -577,6 +577,7 @@  struct tep_handle *tep_alloc(void);
 void tep_free(struct tep_handle *pevent);
 void tep_ref(struct tep_handle *pevent);
 void tep_unref(struct tep_handle *pevent);
+int tep_ref_get(struct tep_handle *pevent);
 
 /* access to the internal parser */
 void tep_buffer_init(const char *buf, unsigned long long size);