diff options
Diffstat (limited to 'libpthread/linuxthreads')
-rw-r--r-- | libpthread/linuxthreads/ptfork.c | 37 |
1 files changed, 16 insertions, 21 deletions
diff --git a/libpthread/linuxthreads/ptfork.c b/libpthread/linuxthreads/ptfork.c index 364db7e69..eb544f34b 100644 --- a/libpthread/linuxthreads/ptfork.c +++ b/libpthread/linuxthreads/ptfork.c @@ -17,6 +17,9 @@ /* The "atfork" stuff */ #include <errno.h> + +#ifdef __ARCH_HAS_MMU__ + #include <stddef.h> #include <stdlib.h> #include <unistd.h> @@ -74,7 +77,7 @@ static inline void pthread_call_handlers(struct handler_list * list) { for (/*nothing*/; list != NULL; list = list->next) (list->handler)(); } -#ifdef __ARCH_HAS_MMU__ + extern int __libc_fork(void); pid_t __fork(void) @@ -105,27 +108,19 @@ pid_t __vfork(void) return __fork(); } weak_alias (__vfork, vfork); + #else -pid_t __vfork(void) -{ - pid_t pid; - struct handler_list * prepare, * child, * parent; - pthread_mutex_lock(&pthread_atfork_lock); - prepare = pthread_atfork_prepare; - child = pthread_atfork_child; - parent = pthread_atfork_parent; - pthread_mutex_unlock(&pthread_atfork_lock); - pthread_call_handlers(prepare); - pid = __libc_vfork(); - if (pid == 0) { - __pthread_reset_main_thread(); - __fresetlockfiles(); - pthread_call_handlers(child); - } else { - pthread_call_handlers(parent); - } - return pid; +/* We can't support pthread_atfork without MMU, since we don't have + fork(), and we can't offer the correct semantics for vfork(). */ +int pthread_atfork(void (*prepare)(void), + void (*parent)(void), + void (*child)(void)) +{ + /* ENOMEM is probably pushing it a little bit. + Take it as `no *virtual* memory' :-) */ + errno = ENOMEM; + return -1; } -weak_alias (__vfork, vfork); + #endif |