unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Carlos O'Donell <carlos@redhat.com>
Cc: Florian Weimer <fweimer@redhat.com>,
	Joseph Myers <joseph@codesourcery.com>,
	Szabolcs Nagy <szabolcs.nagy@arm.com>,
	libc-alpha@sourceware.org,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Subject: [PATCH 3/5] support record failure: allow use from constructor
Date: Fri,  3 May 2019 14:42:17 -0400	[thread overview]
Message-ID: <20190503184219.19266-4-mathieu.desnoyers@efficios.com> (raw)
In-Reply-To: <20190503184219.19266-1-mathieu.desnoyers@efficios.com>

Expose support_record_failure_init () so constructors can explicitly
initialize the record failure API.

This is preferred to lazy initialization at first use, because
lazy initialization does not cover use in constructors within
forked children processes (forked from parent constructor).

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
CC: Carlos O'Donell <carlos@redhat.com>
CC: Florian Weimer <fweimer@redhat.com>
CC: Joseph Myers <joseph@codesourcery.com>
CC: Szabolcs Nagy <szabolcs.nagy@arm.com>
CC: libc-alpha@sourceware.org
---
 support/check.h                  |  4 ++++
 support/support_record_failure.c | 18 +++++++++++++-----
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/support/check.h b/support/check.h
index eb3d2487a7..f8684a477a 100644
--- a/support/check.h
+++ b/support/check.h
@@ -88,6 +88,10 @@ void support_test_verify_exit_impl (int status, const char *file, int line,
    does not support reporting failures from a DSO.  */
 void support_record_failure (void);
 
+/* Initialize record failure.  Calling this is only needed when
+   recording failures from constructors.  */
+void support_record_failure_init (void);
+
 /* Static assertion, under a common name for both C++ and C11.  */
 #ifdef __cplusplus
 # define support_static_assert static_assert
diff --git a/support/support_record_failure.c b/support/support_record_failure.c
index a8ffd1fb7d..86d9c71409 100644
--- a/support/support_record_failure.c
+++ b/support/support_record_failure.c
@@ -32,8 +32,12 @@
    zero, the failure of a test can be detected.
 
    The init constructor function below puts *state on a shared
-   annonymous mapping, so that failure reports from subprocesses
-   propagate to the parent process.  */
+   anonymous mapping, so that failure reports from subprocesses
+   propagate to the parent process.
+
+   support_record_failure_init is exposed so it can be called explicitly
+   in case this API needs to be used from a constructor.  */
+
 struct test_failures
 {
   unsigned int counter;
@@ -41,10 +45,14 @@ struct test_failures
 };
 static struct test_failures *state;
 
-static __attribute__ ((constructor)) void
-init (void)
+__attribute__ ((constructor)) void
+support_record_failure_init (void)
 {
-  void *ptr = mmap (NULL, sizeof (*state), PROT_READ | PROT_WRITE,
+  void *ptr;
+
+  if (state != NULL)
+    return;
+  ptr = mmap (NULL, sizeof (*state), PROT_READ | PROT_WRITE,
                     MAP_ANONYMOUS | MAP_SHARED, -1, 0);
   if (ptr == MAP_FAILED)
     {
-- 
2.17.1


  parent reply	other threads:[~2019-05-03 18:42 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-03 18:42 [PATCH 0/5] Restartable Sequences support for glibc 2.30 Mathieu Desnoyers
2019-05-03 18:42 ` [PATCH 1/5] glibc: Perform rseq(2) registration at C startup and thread creation (v10) Mathieu Desnoyers
2019-05-27 11:19   ` Florian Weimer
2019-05-27 19:27     ` Mathieu Desnoyers
2019-05-29 15:45       ` Mathieu Desnoyers
2019-05-30 20:56         ` Mathieu Desnoyers
2019-05-31  8:06           ` Florian Weimer
2019-05-31 14:48             ` Mathieu Desnoyers
2019-05-31 15:46               ` Florian Weimer
2019-05-31 18:10                 ` Mathieu Desnoyers
2019-06-04 11:46                   ` Florian Weimer
2019-06-04 15:57                     ` Mathieu Desnoyers
2019-06-06 11:57                       ` Florian Weimer
2019-06-10 14:43                         ` Carlos O'Donell
2019-06-12 14:00                           ` Mathieu Desnoyers
2019-06-14 10:03                             ` Mathieu Desnoyers
2019-06-14 10:06                               ` Florian Weimer
2019-06-14 10:14                                 ` Mathieu Desnoyers
2019-06-14 11:35                                   ` Florian Weimer
2019-06-14 12:55                                     ` Mathieu Desnoyers
2019-06-14 13:01                                       ` Mathieu Desnoyers
2019-06-14 13:09                                         ` Florian Weimer
2019-06-14 13:18                                           ` Mathieu Desnoyers
2019-06-14 13:24                                             ` Florian Weimer
2019-06-14 13:34                                               ` Mathieu Desnoyers
2019-06-14 13:42                                                 ` Florian Weimer
2019-06-14 13:47                                                   ` Mathieu Desnoyers
2019-06-14 13:53                                                     ` Florian Weimer
2019-06-14 13:59                                                       ` Mathieu Desnoyers
     [not found]                                         ` <69a53ec2ce184af29c4cae58e0b2fb57@AcuMS.aculab.com>
2019-06-14 13:39                                           ` Mathieu Desnoyers
2019-06-12 14:16                         ` Mathieu Desnoyers
2019-06-12 14:22                           ` Florian Weimer
2019-06-12 14:36                             ` Mathieu Desnoyers
2019-06-12 14:43                               ` Florian Weimer
2019-05-03 18:42 ` [PATCH 2/5] glibc: sched_getcpu(): use rseq cpu_id TLS on Linux (v4) Mathieu Desnoyers
2019-05-03 18:42 ` Mathieu Desnoyers [this message]
2019-05-03 18:42 ` [PATCH 4/5] support: implement xpthread key create/delete (v2) Mathieu Desnoyers
2019-05-03 18:42 ` [PATCH 5/5] rseq registration tests (v4) Mathieu Desnoyers
2019-05-20 15:24 ` [PATCH 0/5] Restartable Sequences support for glibc 2.30 Mathieu Desnoyers
  -- strict thread matches above, loose matches on Subject: below --
2019-04-22 17:56 Mathieu Desnoyers
2019-04-22 17:56 ` [PATCH 3/5] support record failure: allow use from constructor Mathieu Desnoyers
2019-04-16 17:32 [PATCH 0/5] Restartable Sequences support for glibc 2.30 Mathieu Desnoyers
2019-04-16 17:32 ` [PATCH 3/5] support record failure: allow use from constructor Mathieu Desnoyers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190503184219.19266-4-mathieu.desnoyers@efficios.com \
    --to=mathieu.desnoyers@efficios.com \
    --cc=carlos@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=szabolcs.nagy@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).