They do not work on MMU-less systems.
For atfork, implement a hidden function that always returns EPERM.
* libpthread/nptl/sysdeps/unix/sysv/linux/fork.c: Disable if
__ARCH_USE_MMU__ is not defined.
* libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
(__libc_pthread_init): Handle __ARCH_USE_MMU__.
* libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c: Likewise.
* libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c: Likewise.
Signed-off-by: Mickaël Guêné <mickael.guene(a)st.com>
Signed-off-by: Christophe Lyon <christophe.lyon(a)st.com>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c
b/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c
index 9b96152..429fb90 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c
@@ -28,6 +28,7 @@
#include <atomic.h>
#include <errno.h>
+#ifdef __ARCH_USE_MMU__
unsigned long int *__fork_generation_pointer;
@@ -206,3 +207,5 @@ fork (void)
return pid;
}
libc_hidden_def(fork)
+
+#endif /* __ARCH_USE_MMU__ */
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
b/libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
index 0df9951..0cdbcfe 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/libc_pthread_init.c
@@ -40,10 +40,14 @@ __libc_pthread_init (
void (*reclaim) (void))
{
/* Remember the pointer to the generation counter in libpthread. */
+#ifdef __ARCH_USE_MMU__
__fork_generation_pointer = ptr;
+#endif
/* Called by a child after fork. */
+#ifdef __ARCH_USE_MMU__
__register_atfork (NULL, NULL, reclaim, NULL);
+#endif
#ifndef TLS_MULTIPLE_THREADS_IN_TCB
return &__libc_multiple_threads;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c
b/libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c
index b745f9d..55835e5 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/register-atfork.c
@@ -24,6 +24,7 @@
#include <tls.h>
+#ifdef __ARCH_USE_MMU__
/* Lock to protect allocation and deallocation of fork handlers. */
int __fork_lock = LLL_LOCK_INITIALIZER;
@@ -118,6 +119,18 @@ __linkin_atfork (struct fork_handler *newp)
while (catomic_compare_and_exchange_bool_acq (&__fork_handlers,
newp, newp->next) != 0);
}
+#else
+int
+__register_atfork (
+ void (*prepare) (void),
+ void (*parent) (void),
+ void (*child) (void),
+ void *dso_handle)
+{
+ return EPERM;
+}
+libc_hidden_def (__register_atfork)
+#endif
#if 0
libc_freeres_fn (free_mem)
@@ -145,4 +158,3 @@ libc_freeres_fn (free_mem)
}
}
#endif
-
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c
b/libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c
index 69e2621..e958e71 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c
@@ -22,7 +22,7 @@
#include <atomic.h>
#include <tls.h>
-
+#ifdef __ARCH_USE_MMU__
void
__unregister_atfork (
void *dso_handle)
@@ -120,3 +120,11 @@ __unregister_atfork (
deleted = deleted->next;
}
}
+#else
+void
+__unregister_atfork (
+ void *dso_handle)
+{
+ /* Nothing to do. */
+}
+#endif
--
2.6.3