All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 12/13] perf tools: replace on_exit with atexit
@ 2012-08-28 22:06 Irina Tirdea
  2012-08-29 16:59 ` David Ahern
  0 siblings, 1 reply; 3+ messages in thread
From: Irina Tirdea @ 2012-08-28 22:06 UTC (permalink / raw)
  To: Steven Rostedt, Arnaldo Carvalho de Melo, Ingo Molnar
  Cc: LKML, Namhyung Kim, Peter Zijlstra, Frederic Weisbecker

on_exit() is only available in new versions of glibc.
Using on_exit on Android leads to errors at compile time.

Replacing on_exit with its more portable version atexit.
This leads to using a global variable since on_exit supports
sending a parameters while atexit does not.

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
---
 tools/perf/builtin-record.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 3fc9bf9..f5daedf 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -66,6 +66,9 @@ struct perf_record {
     off_t            post_processing_offset;
 };

+/* for atexit */
+static struct perf_record *saved_rec;
+
 static void advance_output(struct perf_record *rec, size_t size)
 {
     rec->bytes_written += size;
@@ -143,9 +146,9 @@ static void sig_handler(int sig)
     signr = sig;
 }

-static void perf_record__sig_exit(int exit_status __maybe_unused, void *arg)
+static void perf_record__sig_exit(void)
 {
-    struct perf_record *rec = arg;
+    struct perf_record *rec = saved_rec;
     int status;

     if (rec->evlist->workload.pid > 0) {
@@ -335,9 +338,9 @@ static int process_buildids(struct perf_record *rec)
                           size, &build_id__mark_dso_hit_ops);
 }

-static void perf_record__exit(int status __maybe_unused, void *arg)
+static void perf_record__exit(void)
 {
-    struct perf_record *rec = arg;
+    struct perf_record *rec = saved_rec;

     if (!rec->opts.pipe_output) {
         rec->session->header.data_size += rec->bytes_written;
@@ -424,7 +427,8 @@ static int __cmd_record(struct perf_record *rec,
int argc, const char **argv)

     rec->page_size = sysconf(_SC_PAGE_SIZE);

-    on_exit(perf_record__sig_exit, rec);
+    saved_rec = rec;
+    atexit(perf_record__sig_exit);
     signal(SIGCHLD, sig_handler);
     signal(SIGINT, sig_handler);
     signal(SIGUSR1, sig_handler);
@@ -508,7 +512,7 @@ static int __cmd_record(struct perf_record *rec,
int argc, const char **argv)
     /*
      * perf_session__delete(session) will be called at perf_record__exit()
      */
-    on_exit(perf_record__exit, rec);
+    atexit(perf_record__exit);

     if (opts->pipe_output) {
         err = perf_header__write_pipe(output);
--
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-09-02 20:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-28 22:06 [PATCH 12/13] perf tools: replace on_exit with atexit Irina Tirdea
2012-08-29 16:59 ` David Ahern
2012-09-02 20:30   ` Irina Tirdea

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.