blob: 15055161fc267a08d24d9ffab0c8e003a3ff3845 [file] [log] [blame]
Andrew Geissler82c905d2020-04-13 13:39:40 -05001From eed7427db98cc01db7e9b3479655d68b044bc85b 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 Geissler82c905d2020-04-13 13:39:40 -05004Subject: [PATCH] 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>
Andrew Geissler82c905d2020-04-13 13:39:40 -05009
Brad Bishop19323692019-04-05 15:28:33 -040010---
11 src/basic/process-util.c | 7 +++++++
12 1 file changed, 7 insertions(+)
13
Andrew Geissler635e0e42020-08-21 15:58:33 -050014Index: systemd-stable/src/basic/process-util.c
15===================================================================
16--- systemd-stable.orig/src/basic/process-util.c
17+++ systemd-stable/src/basic/process-util.c
Andrew Geissler82c905d2020-04-13 13:39:40 -050018@@ -18,6 +18,9 @@
Brad Bishop19323692019-04-05 15:28:33 -040019 #if HAVE_VALGRIND_VALGRIND_H
20 #include <valgrind/valgrind.h>
21 #endif
22+#ifndef __GLIBC__
23+#include <pthread.h>
24+#endif
25
26 #include "alloc-util.h"
27 #include "architecture.h"
Andrew Geissler635e0e42020-08-21 15:58:33 -050028@@ -1143,11 +1146,15 @@ void reset_cached_pid(void) {
Brad Bishop19323692019-04-05 15:28:33 -040029 cached_pid = CACHED_PID_UNSET;
30 }
31
32+#ifdef __GLIBC__
33 /* We use glibc __register_atfork() + __dso_handle directly here, as they are not included in the glibc
34 * headers. __register_atfork() is mostly equivalent to pthread_atfork(), but doesn't require us to link against
35 * libpthread, as it is part of glibc anyway. */
36 extern int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void *dso_handle);
37 extern void* __dso_handle _weak_;
38+#else
39+#define __register_atfork(prepare,parent,child,dso) pthread_atfork(prepare,parent,child)
40+#endif
41
42 pid_t getpid_cached(void) {
43 static bool installed = false;