/* We use glibc __register_atfork() + __dso_handle directly here, as they are not included in the glibc
* headers. __register_atfork() is mostly equivalent to pthread_atfork(), but doesn't require us to link against
* libpthread, as it is part of glibc anyway. */
+#ifdef __GLIBC__
extern int __register_atfork(void (*prepare) (void), void (*parent) (void), void (*child) (void), void * __dso_handle);
extern void* __dso_handle __attribute__ ((__weak__));
+#endif // ifdef __GLIBC__
pid_t getpid_cached(void) {
pid_t current_value;
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <pthread.h> /* for pthread_atfork */
#define strerror_r(e, m, k) (strerror_r(e, m, k) < 0 ? strdup("strerror_r() failed") : m);
# endif
#endif // ENABLE_UTMP
+/*
+ * Systemd makes use of undeclared glibc-specific __register_atfork to avoid
+ * a depednency on libpthread, __register_atfork is roughly equivalent to
+ * pthread_atfork so define __register_atfork to pthread_atfork.
+ */
+#define __register_atfork(prepare,parent,child,dso) pthread_atfork(prepare,parent,child)
+
#endif // !defined(__GLIBC__)
#endif // ELOGIND_BASIC_MUSL_MISSING_H_INCLUDED