blob: 76cc75cf6a4f4eedfe918971982b562b0d2f3583 [file] [log] [blame]
Andrew Geisslerd1e89492021-02-12 15:35:20 -06001From d8e4f0aa1760e4c7bb8476beecd35025c9cbb95a Mon Sep 17 00:00:00 2001
Brad Bishop19323692019-04-05 15:28:33 -04002From: Chen Qi <Qi.Chen@windriver.com>
3Date: Mon, 25 Feb 2019 15:03:47 +0800
Andrew Geisslerd1e89492021-02-12 15:35:20 -06004Subject: [PATCH 09/26] fix missing of __register_atfork for non-glibc builds
Brad Bishop19323692019-04-05 15:28:33 -04005
6Upstream-Status: Inappropriate [musl specific]
7
8Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
9---
10 src/basic/process-util.c | 7 +++++++
11 1 file changed, 7 insertions(+)
12
Andrew Geisslerd1e89492021-02-12 15:35:20 -060013diff --git a/src/basic/process-util.c b/src/basic/process-util.c
14index 0851613fc9..4417101569 100644
15--- a/src/basic/process-util.c
16+++ b/src/basic/process-util.c
Andrew Geissler82c905d2020-04-13 13:39:40 -050017@@ -18,6 +18,9 @@
Brad Bishop19323692019-04-05 15:28:33 -040018 #if HAVE_VALGRIND_VALGRIND_H
19 #include <valgrind/valgrind.h>
20 #endif
21+#ifndef __GLIBC__
22+#include <pthread.h>
23+#endif
24
25 #include "alloc-util.h"
26 #include "architecture.h"
Andrew Geissler635e0e42020-08-21 15:58:33 -050027@@ -1143,11 +1146,15 @@ void reset_cached_pid(void) {
Brad Bishop19323692019-04-05 15:28:33 -040028 cached_pid = CACHED_PID_UNSET;
29 }
30
31+#ifdef __GLIBC__
32 /* We use glibc __register_atfork() + __dso_handle directly here, as they are not included in the glibc
33 * headers. __register_atfork() is mostly equivalent to pthread_atfork(), but doesn't require us to link against
34 * libpthread, as it is part of glibc anyway. */
35 extern int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void *dso_handle);
36 extern void* __dso_handle _weak_;
37+#else
38+#define __register_atfork(prepare,parent,child,dso) pthread_atfork(prepare,parent,child)
39+#endif
40
41 pid_t getpid_cached(void) {
42 static bool installed = false;
Andrew Geisslerd1e89492021-02-12 15:35:20 -060043--
442.27.0
45