Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1532576

[PATCH v2 2/6] perf tool: Move parse_nsec_time to time-utils.c

From David Ahern <dsa@cumulusnetworks.com>
Newsgroups linux.kernel
Subject [PATCH v2 2/6] perf tool: Move parse_nsec_time to time-utils.c
Date 2016-11-29 18:20 +0100
Message-ID <sIUev-2Xs-75@gated-at.bofh.it> (permalink)
References <sIUeu-2Xs-27@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Code move only; no functional change intended.

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 tools/perf/util/time-utils.c | 35 ++++++++++++++++++++++++++++++++++-
 tools/perf/util/time-utils.h |  2 ++
 tools/perf/util/util.c       | 33 ---------------------------------
 tools/perf/util/util.h       |  2 --
 4 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/tools/perf/util/time-utils.c b/tools/perf/util/time-utils.c
index 0443b2afd0cf..4ea7c4c80720 100644
--- a/tools/perf/util/time-utils.c
+++ b/tools/perf/util/time-utils.c
@@ -1,5 +1,6 @@
 #include <string.h>
 #include <sys/time.h>
+#include <linux/time64.h>
 #include <time.h>
 #include <errno.h>
 #include <inttypes.h>
@@ -7,7 +8,39 @@
 #include "perf.h"
 #include "debug.h"
 #include "time-utils.h"
-#include "util.h"
+
+int parse_nsec_time(const char *str, u64 *ptime)
+{
+	u64 time_sec, time_nsec;
+	char *end;
+
+	time_sec = strtoul(str, &end, 10);
+	if (*end != '.' && *end != '\0')
+		return -1;
+
+	if (*end == '.') {
+		int i;
+		char nsec_buf[10];
+
+		if (strlen(++end) > 9)
+			return -1;
+
+		strncpy(nsec_buf, end, 9);
+		nsec_buf[9] = '\0';
+
+		/* make it nsec precision */
+		for (i = strlen(nsec_buf); i < 9; i++)
+			nsec_buf[i] = '0';
+
+		time_nsec = strtoul(nsec_buf, &end, 10);
+		if (*end != '\0')
+			return -1;
+	} else
+		time_nsec = 0;
+
+	*ptime = time_sec * NSEC_PER_SEC + time_nsec;
+	return 0;
+}
 
 static int parse_timestr_sec_nsec(struct perf_time_interval *ptime,
 				  char *start_str, char *end_str)
diff --git a/tools/perf/util/time-utils.h b/tools/perf/util/time-utils.h
index 8f3e0e370be8..c1f197c4af6c 100644
--- a/tools/perf/util/time-utils.h
+++ b/tools/perf/util/time-utils.h
@@ -5,6 +5,8 @@ struct perf_time_interval {
 	u64 start, end;
 };
 
+int parse_nsec_time(const char *str, u64 *ptime);
+
 int perf_time__parse_str(struct perf_time_interval *ptime, const char *ostr);
 
 bool perf_time__skip_sample(struct perf_time_interval *ptime, u64 timestamp);
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index 67ac765da27a..9ddd98827d12 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -400,39 +400,6 @@ void sighandler_dump_stack(int sig)
 	raise(sig);
 }
 
-int parse_nsec_time(const char *str, u64 *ptime)
-{
-	u64 time_sec, time_nsec;
-	char *end;
-
-	time_sec = strtoul(str, &end, 10);
-	if (*end != '.' && *end != '\0')
-		return -1;
-
-	if (*end == '.') {
-		int i;
-		char nsec_buf[10];
-
-		if (strlen(++end) > 9)
-			return -1;
-
-		strncpy(nsec_buf, end, 9);
-		nsec_buf[9] = '\0';
-
-		/* make it nsec precision */
-		for (i = strlen(nsec_buf); i < 9; i++)
-			nsec_buf[i] = '0';
-
-		time_nsec = strtoul(nsec_buf, &end, 10);
-		if (*end != '\0')
-			return -1;
-	} else
-		time_nsec = 0;
-
-	*ptime = time_sec * NSEC_PER_SEC + time_nsec;
-	return 0;
-}
-
 int timestamp__scnprintf_usec(u64 timestamp, char *buf, size_t sz)
 {
 	u64  sec = timestamp / NSEC_PER_SEC;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 79662d67891e..1d639e38aa82 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -179,8 +179,6 @@ static inline void *zalloc(size_t size)
 #undef tolower
 #undef toupper
 
-int parse_nsec_time(const char *str, u64 *ptime);
-
 extern unsigned char sane_ctype[256];
 #define GIT_SPACE		0x01
 #define GIT_DIGIT		0x02
-- 
2.7.4 (Apple Git-66)

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/6] perf: Add option to specify time window of interest David Ahern <dsa@cumulusnetworks.com> - 2016-11-29 18:20 +0100
  [PATCH v2 6/6] perf report: Add option to specify time window of interest David Ahern <dsa@cumulusnetworks.com> - 2016-11-29 18:20 +0100
    [tip:perf/core] perf report: Add option to specify time window of  interest tip-bot for David Ahern <tipbot@zytor.com> - 2016-12-02 11:50 +0100
  [PATCH v2 5/6] perf kmem: Add option to specify time window of interest David Ahern <dsa@cumulusnetworks.com> - 2016-11-29 18:20 +0100
    [tip:perf/core] perf kmem: Add option to specify time window of  interest tip-bot for David Ahern <tipbot@zytor.com> - 2016-12-02 11:50 +0100
  [PATCH v2 4/6] perf sched timehist: Add option to specify time window of interest David Ahern <dsa@cumulusnetworks.com> - 2016-11-29 18:20 +0100
    Re: [PATCH v2 4/6] perf sched timehist: Add option to specify time  window of interest Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-29 20:00 +0100
      Re: [PATCH v2 4/6] perf sched timehist: Add option to specify time  window of interest David Ahern <dsahern@gmail.com> - 2016-11-29 20:00 +0100
        Re: [PATCH v2 4/6] perf sched timehist: Add option to specify time  window of interest Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-29 20:30 +0100
    [tip:perf/core] perf sched timehist: Add option to specify time  window of interest tip-bot for David Ahern <tipbot@zytor.com> - 2016-12-02 11:50 +0100
  [PATCH v2 3/6] perf script: Add option to specify time window of interest David Ahern <dsa@cumulusnetworks.com> - 2016-11-29 18:20 +0100
    [tip:perf/core] perf script: Add option to specify time window of  interest tip-bot for David Ahern <tipbot@zytor.com> - 2016-12-02 11:50 +0100
  [PATCH v2 2/6] perf tool: Move parse_nsec_time to time-utils.c David Ahern <dsa@cumulusnetworks.com> - 2016-11-29 18:20 +0100
    [tip:perf/core] perf tools: Move parse_nsec_time to time-utils.c tip-bot for David Ahern <tipbot@zytor.com> - 2016-12-02 11:50 +0100
  [PATCH v2 1/6] perf tool: Add time-based utility functions David Ahern <dsa@cumulusnetworks.com> - 2016-11-29 18:30 +0100
    [tip:perf/core] perf tools: Add time-based utility functions tip-bot for David Ahern <tipbot@zytor.com> - 2016-12-02 11:50 +0100
  Re: [PATCH v2 0/6] perf: Add option to specify time window of  interest Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-29 20:20 +0100
    Re: [PATCH v2 0/6] perf: Add option to specify time window of interest Namhyung Kim <namhyung@kernel.org> - 2016-11-30 06:30 +0100
      Re: [PATCH v2 0/6] perf: Add option to specify time window of  interest Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-11-30 15:30 +0100

csiph-web