summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2018-08-10 16:45:07 +0200
committerDaiki Ueno <ueno@gnu.org>2018-08-10 18:25:28 +0200
commit541d79cb651cfd3238b9aa41fce70208df8e9496 (patch)
treed4b38e7c2ea397bfb6c3717cbab81398b052f393 /common
parent6a8da20c0432499480731548256294844cade631 (diff)
build: Link to libpthread, if pthread_atfork() needs to be used
On non-glibc systems (e.g., FreeBSD), pthread_atfork() stub is provided as a nop and our fork detection mechanism doesn't work. Pull in the actual implementation from libpthread in that case. Signed-off-by: Daiki Ueno <dueno@redhat.com>
Diffstat (limited to 'common')
-rw-r--r--common/library.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/common/library.c b/common/library.c
index b72465b..73a008c 100644
--- a/common/library.c
+++ b/common/library.c
@@ -145,12 +145,14 @@ extern int __register_atfork (void (*prepare) (void), void (*parent) (void),
#ifdef HAVE___REGISTER_ATFORK
-#define p11_register_atfork(a,b,c,d) \
- (__register_atfork((a),(b),(c),(d)))
+extern void *__dso_handle;
+
+#define p11_register_atfork(a,b,c) \
+ (__register_atfork((a),(b),(c),__dso_handle))
#else
-#define p11_register_atfork(a,b,c,d) \
+#define p11_register_atfork(a,b,c) \
(pthread_atfork((a),(b),(c)))
#endif /* HAVE___REGISTER_ATFORK */
@@ -177,7 +179,7 @@ p11_library_init_impl (void)
p11_message_locale = newlocale (LC_ALL_MASK, "POSIX", (locale_t) 0);
#endif
- p11_register_atfork (NULL, NULL, count_forks, NULL);
+ p11_register_atfork (NULL, NULL, count_forks);
}
void