diff options
author | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2012-06-13 10:00:33 +0200 |
---|---|---|
committer | Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org> | 2012-06-13 10:00:33 +0200 |
commit | 06ada30697940aeb783b86e1f1dd70e23e5ca80c (patch) | |
tree | 2e7dab54c45c926cb9d7bbf549cf5aed9b68a600 | |
parent | 34d361c7f3a36b4d890677e45e7c42ca2782ca45 (diff) | |
download | imx53-lt-3.2-imx5+android.tar.gz |
imx53: Make perf compile on Androidlt-3.2-imx5+android
Change-Id: Ifcfa381c423fbe6b6cd50aea1c0873ad28128e0a
Signed-off-by: Bernhard Rosenkraenzer <Bernhard.Rosenkranzer@linaro.org>
-rw-r--r-- | arch/arm/mach-mx5/clock-mx51-mx53.c | 1 | ||||
-rw-r--r-- | tools/perf/Makefile | 15 | ||||
-rw-r--r-- | tools/perf/builtin-test.c | 7 | ||||
-rw-r--r-- | tools/perf/compat-android.h | 90 | ||||
-rw-r--r-- | tools/perf/config/feature-tests.mak | 13 | ||||
-rw-r--r-- | tools/perf/util/annotate.h | 1 | ||||
-rw-r--r-- | tools/perf/util/event.c | 1 | ||||
-rw-r--r-- | tools/perf/util/event.h | 1 | ||||
-rw-r--r-- | tools/perf/util/util.h | 4 |
9 files changed, 131 insertions, 2 deletions
diff --git a/arch/arm/mach-mx5/clock-mx51-mx53.c b/arch/arm/mach-mx5/clock-mx51-mx53.c index 4cb27697719..e962c88c4cd 100644 --- a/arch/arm/mach-mx5/clock-mx51-mx53.c +++ b/arch/arm/mach-mx5/clock-mx51-mx53.c @@ -1672,4 +1672,5 @@ int __init mx53_clocks_init_dt(void) clk_get_freq_dt(&ckil, &osc, &ckih1, &ckih2); return mx53_clocks_init(ckil, osc, ckih1, ckih2); } +EXPORT_SYMBOL_GPL(mx53_clock_init_dt) #endif diff --git a/tools/perf/Makefile b/tools/perf/Makefile index b98e3075646..9e3de86db94 100644 --- a/tools/perf/Makefile +++ b/tools/perf/Makefile @@ -103,7 +103,7 @@ ifndef PERF_DEBUG endif CFLAGS = -fno-omit-frame-pointer -ggdb3 -Wall -Wextra -std=gnu99 $(CFLAGS_WERROR) $(CFLAGS_OPTIMIZE) -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -EXTLIBS = -lpthread -lrt -lelf -lm +EXTLIBS = -lpthread -lelf -lm ALL_CFLAGS = $(CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 ALL_LDFLAGS = $(LDFLAGS) STRIP ?= strip @@ -429,12 +429,23 @@ FLAGS_LIBELF=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) ifneq ($(call try-cc,$(SOURCE_LIBELF),$(FLAGS_LIBELF)),y) FLAGS_GLIBC=$(ALL_CFLAGS) $(ALL_LDFLAGS) ifneq ($(call try-cc,$(SOURCE_GLIBC),$(FLAGS_GLIBC)),y) - msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); + ifeq ($(call try-cc,$(SOURCE_BIONIC),$(FLAGS_GLIBC)),y) + # Found Bionic instead of glibc... + # That works too, but needs a bit of special treatment + BASIC_CFLAGS += -DANDROID -include compat-android.h + ANDROID := 1 + else + msg := $(error No gnu/libc-version.h found, please install glibc-dev[el]/glibc-static); + endif else msg := $(error No libelf.h/libelf found, please install libelf-dev/elfutils-libelf-devel); endif endif +ifneq ($(ANDROID),1) +EXTLIBS += -lrt +endif + ifneq ($(call try-cc,$(SOURCE_ELF_MMAP),$(FLAGS_COMMON)),y) BASIC_CFLAGS += -DLIBELF_NO_MMAP endif diff --git a/tools/perf/builtin-test.c b/tools/perf/builtin-test.c index 831d1baeac3..e7ee7c8e7c0 100644 --- a/tools/perf/builtin-test.c +++ b/tools/perf/builtin-test.c @@ -466,10 +466,17 @@ static int test__basic_mmap(void) .watermark = 0, }; cpu_set_t cpu_set; +#ifndef ANDROID const char *syscall_names[] = { "getsid", "getppid", "getpgrp", "getpgid", }; pid_t (*syscalls[])(void) = { (void *)getsid, getppid, getpgrp, (void*)getpgid }; +#else + // No getsid() on Android + const char *syscall_names[] = { "getppid", "getpgrp", + "getpgid", }; + pid_t (*syscalls[])(void) = { getppid, getpgrp, (void*)getpgid }; +#endif #define nsyscalls ARRAY_SIZE(syscall_names) int ids[nsyscalls]; unsigned int nr_events[nsyscalls], diff --git a/tools/perf/compat-android.h b/tools/perf/compat-android.h new file mode 100644 index 00000000000..7681f353cc6 --- /dev/null +++ b/tools/perf/compat-android.h @@ -0,0 +1,90 @@ +/* Android compatibility header + * Provides missing bits in Bionic on Android, ignored + * on regular Linux. + * + * Written by Bernhard.Rosenkranzer@linaro.org + * + * Released into the public domain. Do with this file + * whatever you want. + */ +#ifdef ANDROID +/* Bionic has its own idea about ALIGN, and kills other definitions. + * Done outside the multiple-inclusion wrapper to make sure we + * can override Bionic's ALIGN by simply including compat-android.h + * again after including Bionic headers. + */ +#undef ALIGN +#undef __ALIGN_MASK +#define ALIGN(x,a) __ALIGN_MASK(x,(typeof(x))(a)-1) +#define __ALIGN_MASK(x,mask) (((x)+(mask))&~(mask)) + +#ifndef _COMPAT_ANDROID_H_ +#define _COMPAT_ANDROID_H_ 1 +#include <stdio.h> +#include <signal.h> +#include <asm/page.h> // for PAGE_SIZE +#include <asm/termios.h> // for winsize + +#ifndef __WORDSIZE +#include <stdint.h> +#define __WORDSIZE _BITSIZE +#endif + +#ifndef roundup +#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) +#endif + +#ifndef __force +#define __force +#endif + +// Assorted functions that are missing from Bionic +static void psignal(int sig, const char *s) { + if(sig>=0 && sig<NSIG) { + if(s) + fprintf(stderr, "%s: %s\n", s, sys_siglist[sig]); + else + fprintf(stderr, "%s\n", sys_siglist[sig]); + } else { + if(s) + fprintf(stderr, "%s: invalid signal\n", s); + else + fputs("invalid signal\n", stderr); + } +} + +static ssize_t getline(char **lineptr, size_t *n, FILE *stream) { + size_t ret = 0; + + if (!lineptr || !n || !stream) + return -1; + + if(!*lineptr) { + *n = 128; + *lineptr = (char*)malloc(*n); + if(!*lineptr) + return -1; + } + + while(!feof(stream) && !ferror(stream)) { + int c; + if(ret == *n) { + *n += 128; + *lineptr = (char*)realloc(*lineptr, *n); + if(!*lineptr) { + *n = 0; + return -1; + } + } + c = fgetc(stream); + if(c == EOF) + break; + *lineptr[ret++] = c; + if(c == '\n') + break; + } + *lineptr[ret] = 0; + return ret; +} +#endif +#endif diff --git a/tools/perf/config/feature-tests.mak b/tools/perf/config/feature-tests.mak index 6170fd2531b..7362a75782e 100644 --- a/tools/perf/config/feature-tests.mak +++ b/tools/perf/config/feature-tests.mak @@ -43,6 +43,19 @@ int main(void) } endef +define SOURCE_BIONIC +#include <android/api-level.h> + +int main(void) +{ +#ifndef __ANDROID_API__ + error out +#else + return 0; +#endif +} +endef + define SOURCE_ELF_MMAP #include <libelf.h> int main(void) diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index d9072523d34..15fadc05960 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -6,6 +6,7 @@ #include "symbol.h" #include <linux/list.h> #include <linux/rbtree.h> +#include <pthread.h> struct objdump_line { struct list_head node; diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c index 437f8ca679a..d8cf362b16a 100644 --- a/tools/perf/util/event.c +++ b/tools/perf/util/event.c @@ -7,6 +7,7 @@ #include "strlist.h" #include "thread.h" #include "thread_map.h" +#include "../compat-android.h" static const char *perf_event__names[] = { [0] = "TOTAL", diff --git a/tools/perf/util/event.h b/tools/perf/util/event.h index 357a85b8524..e617b88c08d 100644 --- a/tools/perf/util/event.h +++ b/tools/perf/util/event.h @@ -5,6 +5,7 @@ #include "../perf.h" #include "map.h" +#include "../compat-android.h" /* * PERF_SAMPLE_IP | PERF_SAMPLE_TID | * diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h index 0128906bac8..72f54e5f2d2 100644 --- a/tools/perf/util/util.h +++ b/tools/perf/util/util.h @@ -71,15 +71,19 @@ #include <sys/socket.h> #include <sys/ioctl.h> #include <sys/select.h> +#ifndef ANDROID #include <netinet/in.h> #include <netinet/tcp.h> #include <arpa/inet.h> +#endif #include <netdb.h> #include <pwd.h> #include <inttypes.h> #include "../../../include/linux/magic.h" #include "types.h" +#ifndef ANDROID #include <sys/ttydefaults.h> +#endif extern const char *graph_line; extern const char *graph_dotted_line; |