aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorKirill A. Shutemov <kirill@shutemov.name>2010-08-20 20:38:20 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-08-21 10:22:47 -0400
commitf4e7ac0a233a4dc9b51345546ab69c64bb43e2c1 (patch)
tree26de697385ad30163970160e4c0c8ed9a4dd491b /tools
parent8b9e74eb8af808807192d16b76565c27154ae7ed (diff)
perf tools: add test for strlcpy()
Some Linux distributions like ALT Linux provides patched glibc with contains strlcpy(). It's confilcts with strlcpy() from perf. Let's add check for strlcpy(). Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Paul Mackerras <paulus@samba.org> Cc: Ingo Molnar <mingo@elte.hu> LKML-Reference: <1282351101-8879-1-git-send-email-kirill@shutemov.name> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Makefile9
-rw-r--r--tools/perf/feature-tests.mak11
-rw-r--r--tools/perf/util/cache.h2
-rw-r--r--tools/perf/util/path.c3
4 files changed, 24 insertions, 1 deletions
diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index dcb9700b88d2..7473de00682b 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -647,6 +647,15 @@ else
647 endif 647 endif
648endif 648endif
649 649
650
651ifdef NO_STRLCPY
652 BASIC_CFLAGS += -DNO_STRLCPY
653else
654 ifneq ($(call try-cc,$(SOURCE_STRLCPY),),y)
655 BASIC_CFLAGS += -DNO_STRLCPY
656 endif
657endif
658
650ifndef CC_LD_DYNPATH 659ifndef CC_LD_DYNPATH
651 ifdef NO_R_TO_GCC_LINKER 660 ifdef NO_R_TO_GCC_LINKER
652 # Some gcc does not accept and pass -R to the linker to specify 661 # Some gcc does not accept and pass -R to the linker to specify
diff --git a/tools/perf/feature-tests.mak b/tools/perf/feature-tests.mak
index ddb68e601f0e..ef3d0d6a9e23 100644
--- a/tools/perf/feature-tests.mak
+++ b/tools/perf/feature-tests.mak
@@ -110,6 +110,17 @@ int main(void)
110} 110}
111endef 111endef
112 112
113define SOURCE_STRLCPY
114#include <stdlib.h>
115extern size_t strlcpy(char *dest, const char *src, size_t size);
116
117int main(void)
118{
119 strlcpy(NULL, NULL, 0);
120 return 0;
121}
122endef
123
113# try-cc 124# try-cc
114# Usage: option = $(call try-cc, source-to-build, cc-options) 125# Usage: option = $(call try-cc, source-to-build, cc-options)
115try-cc = $(shell sh -c \ 126try-cc = $(shell sh -c \
diff --git a/tools/perf/util/cache.h b/tools/perf/util/cache.h
index 27e9ebe4076e..a7729797fd96 100644
--- a/tools/perf/util/cache.h
+++ b/tools/perf/util/cache.h
@@ -82,6 +82,8 @@ extern char *perf_path(const char *fmt, ...) __attribute__((format (printf, 1, 2
82extern char *perf_pathdup(const char *fmt, ...) 82extern char *perf_pathdup(const char *fmt, ...)
83 __attribute__((format (printf, 1, 2))); 83 __attribute__((format (printf, 1, 2)));
84 84
85#ifdef NO_STRLCPY
85extern size_t strlcpy(char *dest, const char *src, size_t size); 86extern size_t strlcpy(char *dest, const char *src, size_t size);
87#endif
86 88
87#endif /* __PERF_CACHE_H */ 89#endif /* __PERF_CACHE_H */
diff --git a/tools/perf/util/path.c b/tools/perf/util/path.c
index 58a470d036dd..bd7497711424 100644
--- a/tools/perf/util/path.c
+++ b/tools/perf/util/path.c
@@ -22,6 +22,7 @@ static const char *get_perf_dir(void)
22 return "."; 22 return ".";
23} 23}
24 24
25#ifdef NO_STRLCPY
25size_t strlcpy(char *dest, const char *src, size_t size) 26size_t strlcpy(char *dest, const char *src, size_t size)
26{ 27{
27 size_t ret = strlen(src); 28 size_t ret = strlen(src);
@@ -33,7 +34,7 @@ size_t strlcpy(char *dest, const char *src, size_t size)
33 } 34 }
34 return ret; 35 return ret;
35} 36}
36 37#endif
37 38
38static char *get_pathname(void) 39static char *get_pathname(void)
39{ 40{