summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2018-08-09 17:45:37 +0200
committerDaiki Ueno <ueno@gnu.org>2018-08-10 10:11:24 +0200
commitce3cec7f8742254b8627b9db48973b81e91cbfc8 (patch)
treee818b6bf9a0f73cf5435b295771bd2c6b34c92e2 /common
parent50f8906e63c9413a7687bab6608496d83c29a222 (diff)
common: Prefer __register_atfork() to pthread_atfork() if possible
Diffstat (limited to 'common')
-rw-r--r--common/library.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/common/library.c b/common/library.c
index c1275f3..b72465b 100644
--- a/common/library.c
+++ b/common/library.c
@@ -138,6 +138,23 @@ _p11_library_get_thread_local (void)
}
#endif
+#if defined(HAVE_DECL___REGISTER_ATFORK) && !HAVE_DECL___REGISTER_ATFORK
+extern int __register_atfork (void (*prepare) (void), void (*parent) (void),
+ void (*child) (void), void *dso_handle);
+#endif /* HAVE_DECL___REGISTER_ATFORK */
+
+#ifdef HAVE___REGISTER_ATFORK
+
+#define p11_register_atfork(a,b,c,d) \
+ (__register_atfork((a),(b),(c),(d)))
+
+#else
+
+#define p11_register_atfork(a,b,c,d) \
+ (pthread_atfork((a),(b),(c)))
+
+#endif /* HAVE___REGISTER_ATFORK */
+
static void
count_forks (void)
{
@@ -160,7 +177,7 @@ p11_library_init_impl (void)
p11_message_locale = newlocale (LC_ALL_MASK, "POSIX", (locale_t) 0);
#endif
- pthread_atfork (NULL, NULL, count_forks);
+ p11_register_atfork (NULL, NULL, count_forks, NULL);
}
void