lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANg8OW+q0VumrJrQL57gecO0W0TrpB_WgspKhM-GeiPEdiSPDQ@mail.gmail.com>
Date:	Wed, 29 Aug 2012 01:06:48 +0300
From:	Irina Tirdea <irina.tirdea@...il.com>
To:	Steven Rostedt <rostedt@...dmis.org>,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	Ingo Molnar <mingo@...nel.org>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Namhyung Kim <namhyung@...nel.org>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Frederic Weisbecker <fweisbec@...il.com>
Subject: [PATCH 12/13] perf tools: replace on_exit with atexit

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@...el.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ