commit 1010fcd033e01ead0d43d61d30b341b0d4c68d49 Author: Bernhard Rosenkraenzer Date: Sun Jun 24 14:35:26 2012 +0200 perf: Don't use on_exit() on Android Change-Id: I5709d0af5b1b0515603dfe17f143e30a9216211f Signed-off-by: Bernhard Rosenkraenzer diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 42e8aca..9eb8a4b 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -32,6 +32,12 @@ #include #include +#ifdef ANDROID +// While stdlib.h has a prototype for it, +// Bionic doesn't actually implement on_exit() +static struct perf_record *__global_rec; +#endif + enum write_mode_t { WRITE_FORCE, WRITE_APPEND @@ -156,6 +162,11 @@ static void perf_record__sig_exit(int exit_status __used, void *arg) signal(signr, SIG_DFL); kill(getpid(), signr); } +#ifdef ANDROID +static void perf_record__sig_exit_android(void) { + perf_record__sig_exit(0, __global_rec); +} +#endif static bool perf_evlist__equal(struct perf_evlist *evlist, struct perf_evlist *other) @@ -339,6 +350,11 @@ static void perf_record__exit(int status __used, void *arg) symbol__exit(); } } +#ifdef ANDROID +static void perf_record__exit_android(void) { + perf_record__exit(0, __global_rec); +} +#endif static void perf_event__synthesize_guest_os(struct machine *machine, void *data) { @@ -412,7 +428,12 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) rec->page_size = sysconf(_SC_PAGE_SIZE); +#ifndef ANDROID on_exit(perf_record__sig_exit, rec); +#else + __global_rec = rec; + atexit(perf_record__sig_exit_android); +#endif signal(SIGCHLD, sig_handler); signal(SIGINT, sig_handler); signal(SIGUSR1, sig_handler); @@ -496,7 +517,11 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv) /* * perf_session__delete(session) will be called at perf_record__exit() */ +#ifndef ANDROID on_exit(perf_record__exit, rec); +#else + atexit(perf_record__exit_android); +#endif if (opts->pipe_output) { err = perf_header__write_pipe(output);