From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
David Ahern <dsa@cumulusnetworks.com>,
David Ahern <dsahern@gmail.com>, Jiri Olsa <jolsa@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 13/19] perf tools: Move parse_nsec_time to time-utils.c
Date: Thu, 1 Dec 2016 15:02:29 -0300 [thread overview]
Message-ID: <20161201180235.18392-14-acme@kernel.org> (raw)
In-Reply-To: <20161201180235.18392-1-acme@kernel.org>
From: David Ahern <dsa@cumulusnetworks.com>
Code move only; no functional change intended.
Committer notes:
Fix the build on Ubuntu 16.04 x86-64 cross-compiling to S/390, with this
set of auto-detected features:
... dwarf: [ on ]
... dwarf_getlocations: [ on ]
... glibc: [ on ]
... gtk2: [ OFF ]
... libaudit: [ OFF ]
... libbfd: [ OFF ]
... libelf: [ on ]
... libnuma: [ OFF ]
... numa_num_possible_cpus: [ OFF ]
... libperl: [ OFF ]
... libpython: [ OFF ]
... libslang: [ OFF ]
... libcrypto: [ OFF ]
... libunwind: [ OFF ]
... libdw-dwarf-unwind: [ on ]
... zlib: [ on ]
... lzma: [ OFF ]
... get_cpuid: [ OFF ]
... bpf: [ on ]
Where it was failing with:
CC /tmp/build/perf/util/time-utils.o
util/time-utils.c: In function 'parse_nsec_time':
util/time-utils.c:17:13: error: implicit declaration of function 'strtoul' [-Werror=implicit-function-declaration]
time_sec = strtoul(str, &end, 10);
^
util/time-utils.c:17:2: error: nested extern declaration of 'strtoul' [-Werror=nested-externs]
time_sec = strtoul(str, &end, 10);
^
util/time-utils.c: In function 'perf_time__parse_str':
util/time-utils.c:93:2: error: implicit declaration of function 'free' [-Werror=implicit-function-declaration]
free(str);
^
util/time-utils.c:93:2: error: incompatible implicit declaration of built-in function 'free' [-Werror]
util/time-utils.c:93:2: note: include '<stdlib.h>' or provide a declaration of 'free'
Do as suggested and add a '#include <stdlib.h>' to get the free() and strtoul()
declarations and fix the build.
Signed-off-by: David Ahern <dsahern@gmail.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1480439746-42695-3-git-send-email-dsahern@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/time-utils.c | 36 +++++++++++++++++++++++++++++++++++-
tools/perf/util/time-utils.h | 2 ++
tools/perf/util/util.c | 33 ---------------------------------
tools/perf/util/util.h | 2 --
4 files changed, 37 insertions(+), 36 deletions(-)
diff --git a/tools/perf/util/time-utils.c b/tools/perf/util/time-utils.c
index 0443b2afd0cf..d1b21c72206d 100644
--- a/tools/perf/util/time-utils.c
+++ b/tools/perf/util/time-utils.c
@@ -1,5 +1,7 @@
+#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
+#include <linux/time64.h>
#include <time.h>
#include <errno.h>
#include <inttypes.h>
@@ -7,7 +9,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.9.3
next prev parent reply other threads:[~2016-12-01 18:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-01 18:02 [GIT PULL 00/19] perf/core improvements and fixes Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 01/19] perf ui helpline: Provide a printf variant Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 02/19] perf annotate: Show invalid jump offset in error message Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 03/19] perf sched timehist: Handle cpu migration events Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 04/19] perf trace: Update tid/pid filtering option to leverage symbol_conf Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 05/19] tools lib bpf: Add missing BPF functions Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 06/19] tools lib bpf: Add private field for bpf_object Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 07/19] tools lib bpf: Retrive bpf_map through offset of bpf_map_def Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 08/19] perf tools: Introduce perf hooks Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 09/19] perf test: Remove "test" and similar strings from test descriptions Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 10/19] perf kmem stat: Track memory freed Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 11/19] perf script: Add option to stop printing callchain Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 12/19] perf tools: Add time-based utility functions Arnaldo Carvalho de Melo
2016-12-01 18:02 ` Arnaldo Carvalho de Melo [this message]
2016-12-01 18:02 ` [PATCH 14/19] perf script: Add option to specify time window of interest Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 15/19] perf sched timehist: " Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 16/19] perf kmem: " Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 17/19] perf report: " Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 18/19] perf annotate: Use arch->objdump.comment_char in dec__parse() Arnaldo Carvalho de Melo
2016-12-01 18:02 ` [PATCH 19/19] perf annotate: AArch64 support Arnaldo Carvalho de Melo
2016-12-02 9:10 ` [GIT PULL 00/19] perf/core improvements and fixes Ingo Molnar
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=20161201180235.18392-14-acme@kernel.org \
--to=acme@kernel.org \
--cc=acme@redhat.com \
--cc=dsa@cumulusnetworks.com \
--cc=dsahern@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).