From patchwork Wed Dec 5 09:21:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzvetomir Stoyanov X-Patchwork-Id: 10760119 Return-Path: Received: from mail-eopbgr770055.outbound.protection.outlook.com ([40.107.77.55]:6363 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726944AbeLEJVv (ORCPT ); Wed, 5 Dec 2018 04:21:51 -0500 From: Tzvetomir Stoyanov To: "rostedt@goodmis.org" CC: "linux-trace-devel@vger.kernel.org" Subject: [PATCH 1/6] tools lib traceevent: Implement new API tep_get_ref() Date: Wed, 5 Dec 2018 09:21:47 +0000 Message-ID: <20181205092134.2214-2-tstoyanov@vmware.com> References: <20181205092134.2214-1-tstoyanov@vmware.com> In-Reply-To: <20181205092134.2214-1-tstoyanov@vmware.com> Content-Language: en-US MIME-Version: 1.0 Sender: linux-trace-devel-owner@vger.kernel.org List-ID: Content-Length: 1786 This patch implements a new API of the tracevent library: int tep_get_ref(struct tep_handle *tep); 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 Cc: Andrew Morton Cc: Jiri Olsa Cc: Namhyung Kim Link: http://lkml.kernel.org/r/20181130154646.890615385@goodmis.org Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Arnaldo Carvalho de Melo --- include/traceevent/event-parse.h | 1 + lib/traceevent/event-parse.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/traceevent/event-parse.h b/include/traceevent/event-parse.h index af1f068..ea6d25d 100644 --- a/include/traceevent/event-parse.h +++ b/include/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_get_ref(struct tep_handle *tep); /* access to the internal parser */ void tep_buffer_init(const char *buf, unsigned long long size); diff --git a/lib/traceevent/event-parse.c b/lib/traceevent/event-parse.c index 2e8031c..57e3615 100644 --- a/lib/traceevent/event-parse.c +++ b/lib/traceevent/event-parse.c @@ -6761,6 +6761,13 @@ void tep_ref(struct tep_handle *pevent) pevent->ref_count++; } +int tep_get_ref(struct tep_handle *tep) +{ + if (tep) + return tep->ref_count; + return 0; +} + void tep_free_format_field(struct tep_format_field *field) { free(field->type);