diff mbox series

[1/4] trace-cmd: Add internal API to check if tsc2nsec is supported

Message ID 20210329125821.97496-2-tz.stoyanov@gmail.com (mailing list archive)
State Accepted
Headers show
Series Documented new trace-cmd options | expand

Commit Message

Tzvetomir Stoyanov (VMware) March 29, 2021, 12:58 p.m. UTC
A new internal API is added to check is tsc to nanoseconds conversion is
supported:
 bool trace_tsc2nsec_is_supported(void);

Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
 tracecmd/include/trace-local.h | 2 ++
 tracecmd/trace-record.c        | 5 +++++
 2 files changed, 7 insertions(+)

Comments

Steven Rostedt March 30, 2021, 9:37 p.m. UTC | #1
On Mon, 29 Mar 2021 15:58:18 +0300
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> A new internal API is added to check is tsc to nanoseconds conversion is
> supported:
>  bool trace_tsc2nsec_is_supported(void);
> 
> Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
> ---
>  tracecmd/include/trace-local.h | 2 ++
>  tracecmd/trace-record.c        | 5 +++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h
> index 7773e9fc..6a4c5f51 100644
> --- a/tracecmd/include/trace-local.h
> +++ b/tracecmd/include/trace-local.h
> @@ -341,4 +341,6 @@ static inline bool is_digits(const char *s)
>  	return true;
>  }
>  
> +bool trace_tsc2nsec_is_supported(void);
> +
>  #endif /* __TRACE_LOCAL_H */
> diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
> index 5e69cf48..5c9d800f 100644
> --- a/tracecmd/trace-record.c
> +++ b/tracecmd/trace-record.c
> @@ -5827,6 +5827,11 @@ static int get_tsc_nsec(int *shift, int *mult)
>  }
>  #endif
>  
> +bool trace_tsc2nsec_is_supported(void)
> +{
> +	return (get_tsc_nsec(NULL, NULL) == 0);

Return is not a function, no need for the external parenthesis.

-- Steve

> +}
> +
>  static void parse_record_options(int argc,
>  				 char **argv,
>  				 enum trace_cmd curr_cmd,
diff mbox series

Patch

diff --git a/tracecmd/include/trace-local.h b/tracecmd/include/trace-local.h
index 7773e9fc..6a4c5f51 100644
--- a/tracecmd/include/trace-local.h
+++ b/tracecmd/include/trace-local.h
@@ -341,4 +341,6 @@  static inline bool is_digits(const char *s)
 	return true;
 }
 
+bool trace_tsc2nsec_is_supported(void);
+
 #endif /* __TRACE_LOCAL_H */
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index 5e69cf48..5c9d800f 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -5827,6 +5827,11 @@  static int get_tsc_nsec(int *shift, int *mult)
 }
 #endif
 
+bool trace_tsc2nsec_is_supported(void)
+{
+	return (get_tsc_nsec(NULL, NULL) == 0);
+}
+
 static void parse_record_options(int argc,
 				 char **argv,
 				 enum trace_cmd curr_cmd,