diff options
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux')
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/fork.c | 14 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/fork.h | 6 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/register-atfork.c | 6 | ||||
-rw-r--r-- | nptl/sysdeps/unix/sysv/linux/unregister-atfork.c | 2 |
4 files changed, 25 insertions, 3 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/fork.c b/nptl/sysdeps/unix/sysv/linux/fork.c index 2202b40f6a..071b412a6f 100644 --- a/nptl/sysdeps/unix/sysv/linux/fork.c +++ b/nptl/sysdeps/unix/sysv/linux/fork.c @@ -116,9 +116,11 @@ __libc_fork (void) _IO_list_lock (); +#ifndef PTHREAD_T_IS_TID #ifndef NDEBUG pid_t ppid = THREAD_GETMEM (THREAD_SELF, tid); #endif +#endif /* We need to prevent the getpid() code to update the PID field so that, if a signal arrives in the child very early and the signal @@ -138,13 +140,19 @@ __libc_fork (void) { struct pthread *self = THREAD_SELF; +#ifndef PTHREAD_T_IS_TID assert (THREAD_GETMEM (self, tid) != ppid); +#endif if (__fork_generation_pointer != NULL) *__fork_generation_pointer += 4; /* Adjust the PID field for the new process. */ +#ifndef PTHREAD_T_IS_TID THREAD_SETMEM (self, pid, THREAD_GETMEM (self, tid)); +#else + THREAD_SETMEM (self, pid, getpid ()); +#endif #if HP_TIMING_AVAIL /* The CPU clock of the thread and process have to be set to zero. */ @@ -204,11 +212,17 @@ __libc_fork (void) } /* Initialize the fork lock. */ +#ifndef lll_init __fork_lock = LLL_LOCK_INITIALIZER; +#else + lll_init (__fork_lock); +#endif } else { +#ifndef PTHREAD_T_IS_TID assert (THREAD_GETMEM (THREAD_SELF, tid) == ppid); +#endif /* Restore the PID value. */ THREAD_SETMEM (THREAD_SELF, pid, parentpid); diff --git a/nptl/sysdeps/unix/sysv/linux/fork.h b/nptl/sysdeps/unix/sysv/linux/fork.h index dadd0dfee6..753460abb0 100644 --- a/nptl/sysdeps/unix/sysv/linux/fork.h +++ b/nptl/sysdeps/unix/sysv/linux/fork.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2006 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -25,7 +25,11 @@ extern unsigned long int __fork_generation attribute_hidden; extern unsigned long int *__fork_generation_pointer attribute_hidden; /* Lock to protect allocation and deallocation of fork handlers. */ +#ifndef lll_define extern int __fork_lock attribute_hidden; +#else +lll_define (extern, __fork_lock) attribute_hidden; +#endif /* Elements of the fork handler lists. */ struct fork_handler diff --git a/nptl/sysdeps/unix/sysv/linux/register-atfork.c b/nptl/sysdeps/unix/sysv/linux/register-atfork.c index 8b5557d892..49fcd215a7 100644 --- a/nptl/sysdeps/unix/sysv/linux/register-atfork.c +++ b/nptl/sysdeps/unix/sysv/linux/register-atfork.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2005, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -24,7 +24,11 @@ /* Lock to protect allocation and deallocation of fork handlers. */ +#ifndef lll_define_initialized int __fork_lock = LLL_LOCK_INITIALIZER; +#else +lll_define_initialized (, __fork_lock); +#endif /* Number of pre-allocated handler entries. */ diff --git a/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c b/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c index ed006c1223..2c8789b9bb 100644 --- a/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c +++ b/nptl/sysdeps/unix/sysv/linux/unregister-atfork.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003, 2005, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002. |