summaryrefslogtreecommitdiff
path: root/libpthread/nptl
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@openadk.org>2017-01-22 10:24:51 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2017-01-28 10:31:19 +0100
commitbddde5860ffb8a78587854cc8e3e914bd69269ca (patch)
treed37c90a9ca983fb8be614844343ba2941927f88a /libpthread/nptl
parent30adfbeb8843c28869cc6ee33d7c556721cb241a (diff)
remove PID caching
Follow GNU C Library from c579f48edba88380635ab98cb612030e3ed8691e and remove the PID caching. These simplifies the architecture specific assembly code. The run of the test suite found no regressions, it even solves some of the test failures for x86/x86_64/sparc. Reviewed-by: Max Filippov <jcmvbkbc@gmail.com> Reviewed-by: Vineet Gupta <Vineet.Gupta1@synopsys.com> Acked-by: Matthew Fortune <Matthew.Fortune@imgtec.com> Acked-by: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
Diffstat (limited to 'libpthread/nptl')
-rw-r--r--libpthread/nptl/allocatestack.c20
-rw-r--r--libpthread/nptl/descr.h3
-rw-r--r--libpthread/nptl/init.c28
-rw-r--r--libpthread/nptl/pthreadP.h19
-rw-r--r--libpthread/nptl/pthread_cancel.c6
-rw-r--r--libpthread/nptl/sysdeps/alpha/tcb-offsets.sym1
-rw-r--r--libpthread/nptl/sysdeps/arc/tcb-offsets.sym1
-rw-r--r--libpthread/nptl/sysdeps/arm/tcb-offsets.sym1
-rw-r--r--libpthread/nptl/sysdeps/i386/tcb-offsets.sym1
-rw-r--r--libpthread/nptl/sysdeps/metag/tcb-offsets.sym1
-rw-r--r--libpthread/nptl/sysdeps/microblaze/tcb-offsets.sym1
-rw-r--r--libpthread/nptl/sysdeps/mips/tcb-offsets.sym1
-rw-r--r--libpthread/nptl/sysdeps/nds32/tcb-offsets.sym1
-rw-r--r--libpthread/nptl/sysdeps/nios2/tcb-offsets.sym1
-rw-r--r--libpthread/nptl/sysdeps/powerpc/tcb-offsets.sym1
-rw-r--r--libpthread/nptl/sysdeps/pthread/createthread.c5
-rw-r--r--libpthread/nptl/sysdeps/sh/tcb-offsets.sym1
-rw-r--r--libpthread/nptl/sysdeps/sparc/tcb-offsets.sym1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/clone.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/alpha/vfork.S45
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch3
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/clone.S10
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arc/vfork.S11
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch8
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/clone.S3
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/arm/vfork.S38
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/fork.c12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c30
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/Makefile.arch4
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/clone.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/i386/vfork.S37
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile.arch3
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/clone.S9
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/metag/vfork.S55
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/Makefile.arch1
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/clone.S4
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/vfork.S5
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile.arch7
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/clone.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/pt-clone.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/mips/vfork.S42
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/Makefile.arch3
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/clone.S4
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nds32/vfork.S43
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nios2/Makefile.arch2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nios2/clone.S3
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nios2/vfork.S38
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/nptl-signals.h84
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S9
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S57
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c5
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c12
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/raise.c51
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/Makefile.arch2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/clone.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sh/vfork.S70
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/Makefile.arch3
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/clone.S2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/sparc/vfork.S48
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile.arch6
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S3
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S42
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/Makefile.arch3
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/clone.S3
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/vfork.S59
-rw-r--r--libpthread/nptl/sysdeps/x86_64/tcb-offsets.sym1
-rw-r--r--libpthread/nptl/sysdeps/xtensa/tcb-offsets.sym1
68 files changed, 130 insertions, 856 deletions
diff --git a/libpthread/nptl/allocatestack.c b/libpthread/nptl/allocatestack.c
index 39ec8577e..ccf34d6f6 100644
--- a/libpthread/nptl/allocatestack.c
+++ b/libpthread/nptl/allocatestack.c
@@ -418,9 +418,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
THREAD_SYSINFO(pd) = THREAD_SELF_SYSINFO;
#endif
- /* The process ID is also the same as that of the caller. */
- pd->pid = THREAD_GETMEM (THREAD_SELF, pid);
-
/* Allocate the DTV for this thread. */
if (_dl_allocate_tls (TLS_TPADJ (pd)) == NULL)
{
@@ -556,9 +553,6 @@ allocate_stack (const struct pthread_attr *attr, struct pthread **pdp,
THREAD_SYSINFO(pd) = THREAD_SELF_SYSINFO;
#endif
- /* The process ID is also the same as that of the caller. */
- pd->pid = THREAD_GETMEM (THREAD_SELF, pid);
-
/* Allocate the DTV for this thread. */
if (_dl_allocate_tls (TLS_TPADJ (pd)) == NULL)
{
@@ -833,9 +827,6 @@ __reclaim_stacks (void)
/* This marks the stack as free. */
curp->tid = 0;
- /* The PID field must be initialized for the new process. */
- curp->pid = self->pid;
-
/* Account for the size of the stack. */
stack_cache_actsize += curp->stackblock_size;
@@ -862,13 +853,6 @@ __reclaim_stacks (void)
}
}
- /* Reset the PIDs in any cached stacks. */
- list_for_each (runp, &stack_cache)
- {
- struct pthread *curp = list_entry (runp, struct pthread, list);
- curp->pid = self->pid;
- }
-
/* Add the stack of all running threads to the cache. */
list_splice (&stack_used, &stack_cache);
@@ -995,9 +979,9 @@ setxid_signal_thread (struct xid_command *cmdp, struct pthread *t)
return 0;
int val;
+ pid_t pid = getpid ();
INTERNAL_SYSCALL_DECL (err);
- val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
- t->tid, SIGSETXID);
+ val = INTERNAL_SYSCALL (tgkill, err, 3, pid, t->tid, SIGSETXID);
/* If this failed, it must have had not started yet or else exited. */
if (!INTERNAL_SYSCALL_ERROR_P (val, err))
diff --git a/libpthread/nptl/descr.h b/libpthread/nptl/descr.h
index 3fda681b8..06fdbee4b 100644
--- a/libpthread/nptl/descr.h
+++ b/libpthread/nptl/descr.h
@@ -152,9 +152,6 @@ struct pthread
therefore stack) used' flag. */
pid_t tid;
- /* Process ID - thread group ID in kernel speak. */
- pid_t pid;
-
/* List of robust mutexes the thread is holding. */
#ifdef __PTHREAD_MUTEX_HAVE_PREV
void *robust_prev;
diff --git a/libpthread/nptl/init.c b/libpthread/nptl/init.c
index 0e1c60cda..09220c220 100644
--- a/libpthread/nptl/init.c
+++ b/libpthread/nptl/init.c
@@ -64,24 +64,13 @@ static const char nptl_version[] __attribute_used__ = VERSION;
static void
sigcancel_handler (int sig, siginfo_t *si, void *ctx)
{
-#ifdef __ASSUME_CORRECT_SI_PID
- /* Determine the process ID. It might be negative if the thread is
- in the middle of a fork() call. */
- pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
- if (__builtin_expect (pid < 0, 0))
- pid = -pid;
-#endif
/* Safety check. It would be possible to call this function for
other signals and send a signal from another process. This is not
correct and might even be a security problem. Try to catch as
many incorrect invocations as possible. */
if (sig != SIGCANCEL
-#ifdef __ASSUME_CORRECT_SI_PID
- /* Kernels before 2.5.75 stored the thread ID and not the process
- ID in si_pid so we skip this test. */
- || si->si_pid != pid
-#endif
+ || si->si_pid != getpid()
|| si->si_code != SI_TKILL)
return;
@@ -125,24 +114,13 @@ struct xid_command *__xidcmd attribute_hidden;
static void
sighandler_setxid (int sig, siginfo_t *si, void *ctx)
{
-#ifdef __ASSUME_CORRECT_SI_PID
- /* Determine the process ID. It might be negative if the thread is
- in the middle of a fork() call. */
- pid_t pid = THREAD_GETMEM (THREAD_SELF, pid);
- if (__builtin_expect (pid < 0, 0))
- pid = -pid;
-#endif
/* Safety check. It would be possible to call this function for
other signals and send a signal from another process. This is not
correct and might even be a security problem. Try to catch as
many incorrect invocations as possible. */
if (sig != SIGSETXID
-#ifdef __ASSUME_CORRECT_SI_PID
- /* Kernels before 2.5.75 stored the thread ID and not the process
- ID in si_pid so we skip this test. */
- || si->si_pid != pid
-#endif
+ || si->si_pid != getpid()
|| si->si_code != SI_TKILL)
return;
@@ -191,7 +169,7 @@ __pthread_initialize_minimal_internal (void)
/* Minimal initialization of the thread descriptor. */
struct pthread *pd = THREAD_SELF;
INTERNAL_SYSCALL_DECL (err);
- pd->pid = pd->tid = INTERNAL_SYSCALL (set_tid_address, err, 1, &pd->tid);
+ pd->tid = INTERNAL_SYSCALL (set_tid_address, err, 1, &pd->tid);
THREAD_SETMEM (pd, specific[0], &pd->specific_1stblock[0]);
THREAD_SETMEM (pd, user_stack, true);
if (LLL_LOCK_INITIALIZER != 0)
diff --git a/libpthread/nptl/pthreadP.h b/libpthread/nptl/pthreadP.h
index 013b91dd4..4707f6548 100644
--- a/libpthread/nptl/pthreadP.h
+++ b/libpthread/nptl/pthreadP.h
@@ -30,6 +30,8 @@
#include <internaltypes.h>
#include <atomic.h>
#include <bits/kernel-features.h>
+#include <errno.h>
+#include <nptl-signals.h>
/* Atomic operations on TLS memory. */
@@ -310,23 +312,6 @@ __do_cancel (void)
# define LIBC_CANCEL_HANDLED() /* Nothing. */
#endif
-/* The signal used for asynchronous cancellation. */
-#define SIGCANCEL __SIGRTMIN
-
-
-/* Signal needed for the kernel-supported POSIX timer implementation.
- We can reuse the cancellation signal since we can distinguish
- cancellation from timer expirations. */
-#define SIGTIMER SIGCANCEL
-
-
-/* Signal used to implement the setuid et.al. functions. */
-#define SIGSETXID (__SIGRTMIN + 1)
-
-/* Used to communicate with signal handler. */
-extern struct xid_command *__xidcmd attribute_hidden;
-
-
/* Internal prototypes. */
/* Thread list handling. */
diff --git a/libpthread/nptl/pthread_cancel.c b/libpthread/nptl/pthread_cancel.c
index ee9a3202f..d3fd140e8 100644
--- a/libpthread/nptl/pthread_cancel.c
+++ b/libpthread/nptl/pthread_cancel.c
@@ -21,6 +21,7 @@
#include "pthreadP.h"
#include "atomic.h"
#include <sysdep.h>
+#include <unistd.h>
#include <bits/kernel-features.h>
@@ -74,10 +75,9 @@ pthread_cancel (
the thread is executing fork, it would have to happen in
a signal handler. But this is no allowed, pthread_cancel
is not guaranteed to be async-safe. */
+ pid_t pid = getpid ();
int val;
- val = INTERNAL_SYSCALL (tgkill, err, 3,
- THREAD_GETMEM (THREAD_SELF, pid), pd->tid,
- SIGCANCEL);
+ val = INTERNAL_SYSCALL (tgkill, err, 3, pid, pd->tid, SIGCANCEL);
if (INTERNAL_SYSCALL_ERROR_P (val, err))
result = INTERNAL_SYSCALL_ERRNO (val, err);
diff --git a/libpthread/nptl/sysdeps/alpha/tcb-offsets.sym b/libpthread/nptl/sysdeps/alpha/tcb-offsets.sym
index c21a79104..1005621b3 100644
--- a/libpthread/nptl/sysdeps/alpha/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/alpha/tcb-offsets.sym
@@ -10,5 +10,4 @@
#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - sizeof(struct pthread))
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
diff --git a/libpthread/nptl/sysdeps/arc/tcb-offsets.sym b/libpthread/nptl/sysdeps/arc/tcb-offsets.sym
index cbf0ae42c..519a62954 100644
--- a/libpthread/nptl/sysdeps/arc/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/arc/tcb-offsets.sym
@@ -2,7 +2,6 @@
#include <tls.h>
PTHREAD_TID offsetof (struct pthread, tid)
-PTHREAD_PID offsetof (struct pthread, pid)
MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
TLS_PRE_TCB_SIZE sizeof (struct pthread)
TLS_TCB_SIZE sizeof(tcbhead_t)
diff --git a/libpthread/nptl/sysdeps/arm/tcb-offsets.sym b/libpthread/nptl/sysdeps/arm/tcb-offsets.sym
index 92cc441d3..bf9c0a1c1 100644
--- a/libpthread/nptl/sysdeps/arm/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/arm/tcb-offsets.sym
@@ -7,5 +7,4 @@
#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - sizeof(struct pthread))
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
diff --git a/libpthread/nptl/sysdeps/i386/tcb-offsets.sym b/libpthread/nptl/sysdeps/i386/tcb-offsets.sym
index 69f9deb36..990ac7a57 100644
--- a/libpthread/nptl/sysdeps/i386/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/i386/tcb-offsets.sym
@@ -3,7 +3,6 @@
RESULT offsetof (struct pthread, result)
TID offsetof (struct pthread, tid)
-PID offsetof (struct pthread, pid)
CANCELHANDLING offsetof (struct pthread, cancelhandling)
CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
diff --git a/libpthread/nptl/sysdeps/metag/tcb-offsets.sym b/libpthread/nptl/sysdeps/metag/tcb-offsets.sym
index 753b72b2d..852b5cc26 100644
--- a/libpthread/nptl/sysdeps/metag/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/metag/tcb-offsets.sym
@@ -3,7 +3,6 @@
RESULT offsetof (struct pthread, result)
TID offsetof (struct pthread, tid)
-PID offsetof (struct pthread, pid)
CANCELHANDLING offsetof (struct pthread, cancelhandling)
CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
diff --git a/libpthread/nptl/sysdeps/microblaze/tcb-offsets.sym b/libpthread/nptl/sysdeps/microblaze/tcb-offsets.sym
index 18afbee29..614f0dfed 100644
--- a/libpthread/nptl/sysdeps/microblaze/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/microblaze/tcb-offsets.sym
@@ -7,5 +7,4 @@
#define thread_offsetof(mem) (long)(offsetof (struct pthread, mem) - sizeof (struct pthread))
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
diff --git a/libpthread/nptl/sysdeps/mips/tcb-offsets.sym b/libpthread/nptl/sysdeps/mips/tcb-offsets.sym
index e0e71dc43..9ea25b94a 100644
--- a/libpthread/nptl/sysdeps/mips/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/mips/tcb-offsets.sym
@@ -7,5 +7,4 @@
#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
diff --git a/libpthread/nptl/sysdeps/nds32/tcb-offsets.sym b/libpthread/nptl/sysdeps/nds32/tcb-offsets.sym
index 3b9e10186..6701626e1 100644
--- a/libpthread/nptl/sysdeps/nds32/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/nds32/tcb-offsets.sym
@@ -7,6 +7,5 @@
#define thread_offsetof(mem) (long)(offsetof(struct pthread, mem) - TLS_TCB_OFFSET - TLS_PRE_TCB_SIZE)
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
diff --git a/libpthread/nptl/sysdeps/nios2/tcb-offsets.sym b/libpthread/nptl/sysdeps/nios2/tcb-offsets.sym
index d9ae95258..3cd8d984a 100644
--- a/libpthread/nptl/sysdeps/nios2/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/nios2/tcb-offsets.sym
@@ -9,6 +9,5 @@
# define thread_offsetof(mem) ((ptrdiff_t) THREAD_SELF + offsetof (struct pthread, mem))
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
-PID_OFFSET thread_offsetof (pid)
TID_OFFSET thread_offsetof (tid)
POINTER_GUARD (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
diff --git a/libpthread/nptl/sysdeps/powerpc/tcb-offsets.sym b/libpthread/nptl/sysdeps/powerpc/tcb-offsets.sym
index 8ac133dfd..0bd16fb3a 100644
--- a/libpthread/nptl/sysdeps/powerpc/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/powerpc/tcb-offsets.sym
@@ -12,7 +12,6 @@
#if TLS_MULTIPLE_THREADS_IN_TCB
MULTIPLE_THREADS_OFFSET thread_offsetof (header.multiple_threads)
#endif
-PID thread_offsetof (pid)
TID thread_offsetof (tid)
POINTER_GUARD (offsetof (tcbhead_t, pointer_guard) - TLS_TCB_OFFSET - sizeof (tcbhead_t))
#ifndef __ASSUME_PRIVATE_FUTEX
diff --git a/libpthread/nptl/sysdeps/pthread/createthread.c b/libpthread/nptl/sysdeps/pthread/createthread.c
index ebfee16f9..550bf2cfe 100644
--- a/libpthread/nptl/sysdeps/pthread/createthread.c
+++ b/libpthread/nptl/sysdeps/pthread/createthread.c
@@ -91,6 +91,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr,
if (__builtin_expect (stopped != 0, 0))
{
INTERNAL_SYSCALL_DECL (err);
+ pid_t pid = getpid ();
int res = 0;
/* Set the affinity mask if necessary. */
@@ -105,9 +106,7 @@ do_clone (struct pthread *pd, const struct pthread_attr *attr,
send it the cancellation signal. */
INTERNAL_SYSCALL_DECL (err2);
err_out:
- (void) INTERNAL_SYSCALL (tgkill, err2, 3,
- THREAD_GETMEM (THREAD_SELF, pid),
- pd->tid, SIGCANCEL);
+ (void) INTERNAL_SYSCALL (tgkill, err2, 3, pid, pd->tid, SIGCANCEL);
return (INTERNAL_SYSCALL_ERROR_P (res, err)
? INTERNAL_SYSCALL_ERRNO (res, err)
diff --git a/libpthread/nptl/sysdeps/sh/tcb-offsets.sym b/libpthread/nptl/sysdeps/sh/tcb-offsets.sym
index 753b72b2d..852b5cc26 100644
--- a/libpthread/nptl/sysdeps/sh/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/sh/tcb-offsets.sym
@@ -3,7 +3,6 @@
RESULT offsetof (struct pthread, result)
TID offsetof (struct pthread, tid)
-PID offsetof (struct pthread, pid)
CANCELHANDLING offsetof (struct pthread, cancelhandling)
CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
diff --git a/libpthread/nptl/sysdeps/sparc/tcb-offsets.sym b/libpthread/nptl/sysdeps/sparc/tcb-offsets.sym
index 923af8a5b..f75d02065 100644
--- a/libpthread/nptl/sysdeps/sparc/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/sparc/tcb-offsets.sym
@@ -3,5 +3,4 @@
MULTIPLE_THREADS_OFFSET offsetof (tcbhead_t, multiple_threads)
POINTER_GUARD offsetof (tcbhead_t, pointer_guard)
-PID offsetof (struct pthread, pid)
TID offsetof (struct pthread, tid)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/clone.S
deleted file mode 100644
index eea1cbeed..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/clone.S
+++ /dev/null
@@ -1,2 +0,0 @@
-#define RESET_PID
-#include <sysdeps/unix/sysv/linux/alpha/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/vfork.S
deleted file mode 100644
index 664cac494..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/alpha/vfork.S
+++ /dev/null
@@ -1,45 +0,0 @@
-/* Copyright (C) 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-#include <tcb-offsets.h>
-
-#undef PSEUDO_PREPARE_ARGS
-#define PSEUDO_PREPARE_ARGS \
- /* Load the current cached pid value across the vfork. */ \
- rduniq; \
- ldl a2, PID_OFFSET(v0); \
- mov v0, a1; \
- /* If the cached value is initialized (nonzero), then write \
- back its negation, or INT_MIN, to indicate that the pid \
- value is uninitialized in the the child, and in the window \
- between here and the point at which we restore the value. */ \
- ldah t0, -0x8000; \
- negl a2, t1; \
- cmovne a2, t1, t0; \
- stl t0, PID_OFFSET(v0);
-
-PSEUDO (__vfork, vfork, 0)
-
- /* If we're back in the parent, restore the saved pid. */
- beq v0, 1f
- stl a2, PID_OFFSET(a1)
-1: ret
-
-PSEUDO_END (__vfork)
-libc_hidden_def (__vfork)
-weak_alias (__vfork, vfork)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch
index fa5d530d4..64f3a4f7b 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/Makefile.arch
@@ -9,6 +9,3 @@ libpthread_linux_arch_SSRC =
libpthread_linux_arch_CSRC = pthread_once.c
libc_linux_arch_CSRC = fork.c
-libc_linux_arch_SSRC = clone.S vfork.S
-libc_linux_arch_SSRC-OMIT = waitpid.S
-
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/clone.S
deleted file mode 100644
index 5fd1de3c2..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/clone.S
+++ /dev/null
@@ -1,10 +0,0 @@
-/*
- * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
- *
- * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
- */
-
-#define RESET_PID
-#include <tls.h>
-#include <tcb-offsets.h>
-#include "../../../../../../../libc/sysdeps/linux/arc/clone.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/arc/vfork.S
deleted file mode 100644
index d29e05a8a..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arc/vfork.S
+++ /dev/null
@@ -1,11 +0,0 @@
-/*
- * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
- *
- * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
- */
-
-#define SAVE_PID
-#define RESTORE_PID
-#include <tls.h>
-#include <tcb-offsets.h>
-#include "../../../../../../../libc/sysdeps/linux/arc/vfork.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch
index 49d0684ee..55afe20af 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/Makefile.arch
@@ -9,11 +9,3 @@ libpthread_linux_arch_SSRC =
libpthread_linux_arch_CSRC = pthread_once.c
libc_linux_arch_CSRC = fork.c
-libc_linux_arch_SSRC = clone.S vfork.S
-libc_linux_arch_SSRC-OMIT = waitpid.S
-
-# We always compile it in arm mode because of SAVE_PID macro
-# This macro should be alternatively implemented in THUMB
-# assembly.
-ASFLAGS-vfork.S = -marm
-CFLAGS-OMIT-vfork.S = -mthumb
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/clone.S
deleted file mode 100644
index 23227eb24..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/clone.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#define RESET_PID
-#include <tcb-offsets.h>
-#include "../../../../../../../libc/sysdeps/linux/arm/clone.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/arm/vfork.S
deleted file mode 100644
index b9e8cf846..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/arm/vfork.S
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 2005 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <tcb-offsets.h>
-
-/* Save the PID value. */
-#define SAVE_PID \
- str lr, [sp, #-4]!; /* Save LR. */ \
- mov r0, #0xffff0fff; /* Point to the high page. */ \
- mov lr, pc; /* Save our return address. */ \
- sub pc, r0, #31; /* Jump to the TLS entry. */ \
- ldr lr, [sp], #4; /* Restore LR. */ \
- mov r2, r0; /* Save the TLS addr in r2. */ \
- ldr r3, [r2, #PID_OFFSET]; /* Load the saved PID. */ \
- rsbs r0, r3, #0; /* Negate it. */ \
- moveq r0, #0x80000000; /* Use 0x80000000 if it was 0. */ \
- str r0, [r2, #PID_OFFSET] /* Store the temporary PID. */
-
-/* Restore the old PID value in the parent. */
-#define RESTORE_PID \
- cmp r0, #0; /* If we are the parent... */ \
- strne r3, [r2, #PID_OFFSET] /* ... restore the saved PID. */
-
-#include "../../../../../../../libc/sysdeps/linux/arm/vfork.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c b/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c
index af4041031..49806dab9 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/fork.c
@@ -135,12 +135,6 @@ fork (void)
pid_t ppid = THREAD_GETMEM (THREAD_SELF, tid);
#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
- handler uses getpid(), the value returned is correct. */
- pid_t parentpid = THREAD_GETMEM (THREAD_SELF, pid);
- THREAD_SETMEM (THREAD_SELF, pid, -parentpid);
-
#ifdef ARCH_FORK
pid = ARCH_FORK ();
#else
@@ -158,9 +152,6 @@ fork (void)
if (__fork_generation_pointer != NULL)
*__fork_generation_pointer += 4;
- /* Adjust the PID field for the new process. */
- THREAD_SETMEM (self, pid, THREAD_GETMEM (self, tid));
-
#if HP_TIMING_AVAIL
/* The CPU clock of the thread and process have to be set to zero. */
hp_timing_t now;
@@ -206,9 +197,6 @@ fork (void)
{
assert (THREAD_GETMEM (THREAD_SELF, tid) == ppid);
- /* Restore the PID value. */
- THREAD_SETMEM (THREAD_SELF, pid, parentpid);
-
/* We execute this even if the 'fork' call failed. */
__UCLIBC_IO_MUTEX_UNLOCK_CANCEL_UNSAFE(_stdio_openlist_add_lock);
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c b/libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c
index 24abccc93..03b1031a4 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/getpid.c
@@ -25,41 +25,11 @@
# define __NR_getpid __NR_getxpid
#endif
-#ifndef NOT_IN_libc
-static inline __attribute__((always_inline)) pid_t really_getpid (pid_t oldval);
-
-static inline __attribute__((always_inline)) pid_t
-really_getpid (pid_t oldval)
-{
- if (__builtin_expect (oldval == 0, 1))
- {
- pid_t selftid = THREAD_GETMEM (THREAD_SELF, tid);
- if (__builtin_expect (selftid != 0, 1))
- return selftid;
- }
-
- INTERNAL_SYSCALL_DECL (err);
- pid_t result = INTERNAL_SYSCALL (getpid, err, 0);
-
- /* We do not set the PID field in the TID here since we might be
- called from a signal handler while the thread executes fork. */
- if (oldval == 0)
- THREAD_SETMEM (THREAD_SELF, tid, result);
- return result;
-}
-#endif
-
static pid_t
__getpid (void)
{
-#ifdef NOT_IN_libc
INTERNAL_SYSCALL_DECL (err);
pid_t result = INTERNAL_SYSCALL (getpid, err, 0);
-#else
- pid_t result = THREAD_GETMEM (THREAD_SELF, pid);
- if (__builtin_expect (result <= 0, 0))
- result = really_getpid (result);
-#endif
return result;
}
weak_alias(__getpid, getpid)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/Makefile.arch
index be07d9c85..ee38a6988 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/Makefile.arch
@@ -5,11 +5,9 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-libpthread_linux_arch_SSRC = clone.S pthread_spin_unlock.S pthread_once.S
+libpthread_linux_arch_SSRC = pthread_spin_unlock.S pthread_once.S
libpthread_linux_arch_CSRC = pthread_spin_init.c
libc_linux_arch_CSRC = fork.c
-libc_linux_arch_SSRC = clone.S vfork.S
ASFLAGS += -DUSE___THREAD
-
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/clone.S
deleted file mode 100644
index 9c7c46467..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/clone.S
+++ /dev/null
@@ -1,2 +0,0 @@
-#define RESET_PID
-#include <libc/sysdeps/linux/i386/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/i386/vfork.S
deleted file mode 100644
index 074f0f046..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/i386/vfork.S
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Copyright (C) 1999,2002,2004,2006 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <tcb-offsets.h>
-
-/* Save the PID value. */
-#define SAVE_PID \
- movl %gs:PID, %edx; \
- movl %edx, %eax; \
- negl %eax; \
- jne 1f; \
- movl $0x80000000, %eax; \
-1: movl %eax, %gs:PID
-
-/* Restore the old PID value in the parent. */
-#define RESTORE_PID \
- testl %eax, %eax; \
- je 1f; \
- movl %edx, %gs:PID; \
-1:
-
-
-#include <libc/sysdeps/linux/i386/vfork.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile.arch
index 0f4d8d327..4c85f0abc 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/Makefile.arch
@@ -9,8 +9,5 @@ libpthread_linux_arch_SSRC =
libpthread_linux_arch_CSRC = pthread_once.c
libc_linux_arch_CSRC = fork.c
-libc_linux_arch_SSRC = clone.S vfork.S
-libc_linux_arch_SSRC-OMIT = waitpid.S
CFLAGS += $(SSP_ALL_CFLAGS)
-
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/clone.S
deleted file mode 100644
index f5c5c7c5d..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/clone.S
+++ /dev/null
@@ -1,9 +0,0 @@
-/*
- * Copyright (C) 2013 Imagination Technologies Ltd.
- *
- * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
- */
-
-#define RESET_PID
-#include <tcb-offsets.h>
-#include "../../../../../../../libc/sysdeps/linux/metag/clone.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/metag/vfork.S
deleted file mode 100644
index 7b369b1b4..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/metag/vfork.S
+++ /dev/null
@@ -1,55 +0,0 @@
-/* Copyright (C) 2005 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; see the file COPYING.LIB. If
- not, see <http://www.gnu.org/licenses/>.  */
-
-#include <tcb-offsets.h>
-#include <asm/unistd.h>
-
-#ifdef __PIC__
-#define __VFORK_METAG_LOAD_TP ___metag_load_tp@PLT
-#else
-#define __VFORK_METAG_LOAD_TP ___metag_load_tp
-#endif
-
-/* Save the PID value. */
-#define SAVE_PID \
- SETL [A0StP++], D0FrT, D1RtP; \
- CALLR D1RtP, __VFORK_METAG_LOAD_TP; \
- SUB D0Re0, D0Re0, #TLS_PRE_TCB_SIZE; \
- GETD D0FrT, [D0Re0 + #PID]; \
- NEGS D0FrT, D0FrT; \
- BNZ 1f; \
- MOVT D0FrT, #0x8000; \
-1: SETD [D0Re0 + #PID], D0FrT; \
- GETL D0FrT, D1RtP, [--A0StP];
-
-#define RESTORE_PID \
- CMP D0Re0, #0; \
- BEQ 1f; \
- MSETL [A0StP++], D0Re0, D0FrT; \
- CALLR D1RtP, __VFORK_METAG_LOAD_TP; \
- SUB D0Re0, D0Re0, #TLS_PRE_TCB_SIZE; \
- GETD D0FrT, [D0Re0 + #PID]; \
- NEG D0FrT, D0FrT; \
- MOVT D1Re0, #0x8000; \
- CMP D0FrT, D1Re0; \
- XOREQ D0FrT, D0FrT, D0FrT; \
- SETD [D0Re0 + #PID], D0FrT; \
- GETL D0FrT, D1RtP, [--A0StP]; \
- GETL D0Re0, D1Re0, [--A0StP]; \
-1:
-
-#include <../../../../../../../libc/sysdeps/linux/metag/vfork.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/Makefile.arch
index 77707a085..44a005306 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/Makefile.arch
@@ -5,4 +5,3 @@ libpthread_linux_arch_SSRC =
libpthread_linux_arch_CSRC = pthread_once.c
libc_linux_arch_CSRC = fork.c
-libc_linux_arch_SSRC = clone.S vfork.S
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/clone.S
deleted file mode 100644
index faa78d936..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/clone.S
+++ /dev/null
@@ -1,4 +0,0 @@
-#define RESET_PID
-#include <tls.h>
-#include <tcb-offsets.h>
-#include "../../../../../../../libc/sysdeps/linux/microblaze/clone.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/vfork.S
deleted file mode 100644
index 433671717..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/microblaze/vfork.S
+++ /dev/null
@@ -1,5 +0,0 @@
-#define SAVE_PID
-#define RESTORE_PID
-#include <tls.h>
-#include <tcb-offsets.h>
-#include <libc/sysdeps/linux/microblaze/vfork.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile.arch
index 565efd4a3..402c5ffaf 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/Makefile.arch
@@ -5,13 +5,8 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-libpthread_linux_arch_SSRC = clone.S
libpthread_linux_arch_CSRC = pthread_once.c
libc_linux_arch_CSRC = fork.c
-libc_linux_arch_SSRC = clone.S vfork.S
-ifneq ($(CONFIG_MIPS_O32_ABI),y)
-libc_linux_arch_SSRC-OMIT = waitpid.S
-endif
-ASFLAGS += -DUSE___THREAD
+ASFLAGS += -DUSE___THREAD
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/clone.S
deleted file mode 100644
index 858877f07..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/clone.S
+++ /dev/null
@@ -1,2 +0,0 @@
-#define RESET_PID
-#include <libc/sysdeps/linux/mips/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/pt-clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/pt-clone.S
deleted file mode 100644
index add405523..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/pt-clone.S
+++ /dev/null
@@ -1,2 +0,0 @@
-#define RESET_PID
-#include <../../../../../../../libc/sysdeps/linux/mips/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/mips/vfork.S
deleted file mode 100644
index a23d99cfa..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/mips/vfork.S
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <features.h>
-#include <tls.h>
-
-/* Save the PID value. */
-#define SAVE_PID \
- READ_THREAD_POINTER(v1); /* Get the thread pointer. */ \
- lw a2, PID_OFFSET(v1); /* Load the saved PID. */ \
- subu a2, $0, a2; /* Negate it. */ \
- bnez a2, 1f; /* If it was zero... */ \
- lui a2, 0x8000; /* use 0x80000000 instead. */ \
-1: sw a2, PID_OFFSET(v1); /* Store the temporary PID. */
-
-/* Restore the old PID value in the parent. */
-#define RESTORE_PID \
- beqz v0, 1f; /* If we are the parent... */ \
- READ_THREAD_POINTER(v1); /* Get the thread pointer. */ \
- lw a2, PID_OFFSET(v1); /* Load the saved PID. */ \
- subu a2, $0, a2; /* Re-negate it. */ \
- lui a0, 0x8000; /* Load 0x80000000... */ \
- bne a2, a0, 2f; /* ... compare against it... */ \
- li a2, 0; /* ... use 0 instead. */ \
-2: sw a2, PID_OFFSET(v1); /* Restore the PID. */ \
-1:
-
-#include <../../../../../../../libc/sysdeps/linux/mips/vfork.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/Makefile.arch
index 3b8935ce5..94aa25ffb 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/Makefile.arch
@@ -5,8 +5,5 @@ libpthread_linux_arch_SSRC =
libpthread_linux_arch_CSRC = pthread_once.c
libc_linux_arch_CSRC = fork.c
-libc_linux_arch_SSRC = clone.S vfork.S
-libc_linux_arch_SSRC-OMIT = waitpid.S
CFLAGS += $(SSP_ALL_CFLAGS)
-
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/clone.S
deleted file mode 100644
index 94b39fcf9..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/clone.S
+++ /dev/null
@@ -1,4 +0,0 @@
-/* We want an #include_next, but we are the main source file.
- So, #include ourselves and in that incarnation we can use #include_next. */
-# define RESET_PID
-# include <libc/sysdeps/linux/nds32/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/vfork.S
deleted file mode 100644
index f11f76ae1..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/nds32/vfork.S
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2016-2017 Andes Technology, Inc.
- * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
- */
-
-/* Copyright (C) 2013 Free Software Foundation, Inc.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <tls.h>
-
-/* Save the PID value. */
-#define SAVE_PID \
- lwi $r1, [$r25 + PID_OFFSET];/* Get the thread pointer. */ \
- subri $r1, $r1, 0x0; /* Negate it. */ \
- bnez $r1, 1f; /* If it was zero... */ \
- sethi $r1, 0x80000; /* use 0x80000000 instead. */ \
-1: swi $r1, [$r25 + PID_OFFSET];/* Store the temporary PID. */
-
-/* Restore the old PID value in the parent. */
-#define RESTORE_PID \
- beqz $r0, 1f; /* If we are the parent... */ \
- lwi $r1, [$r25 + PID_OFFSET];/* Get the thread pointer. */ \
- subri $r1, $r1, 0x0; /* Re-negate it. */ \
- sethi $r2, 0x80000; /* Load 0x80000000... */ \
- bne $r1, $r2, 2f; /* ... compare against it... */ \
- movi $r1, 0; /* ... use 0 instead. */ \
-2: swi $r1, [$r25 + PID_OFFSET];/* Restore the PID. */ \
-1:
-
-#include <../../../../../../../libc/sysdeps/linux/nds32/vfork.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/Makefile.arch
index 26f51fb67..1295c34af 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/Makefile.arch
@@ -5,5 +5,3 @@ libpthread_linux_arch_SSRC =
libpthread_linux_arch_CSRC = pthread_once.c
libc_linux_arch_CSRC = fork.c
-libc_linux_arch_SSRC = clone.S vfork.S
-libc_linux_arch_SSRC-OMIT = waitpid.S
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/clone.S
deleted file mode 100644
index 544974f9f..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/clone.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#define RESET_PID
-#include <tcb-offsets.h>
-#include "../../../../../../../libc/sysdeps/linux/nios2/clone.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/vfork.S
deleted file mode 100644
index 6ee414c20..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/nios2/vfork.S
+++ /dev/null
@@ -1,38 +0,0 @@
-/* Copyright (C) 2005 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <tcb-offsets.h>
-
-/* Save the PID value. */
-#define SAVE_PID \
- str lr, [sp, #-4]!; /* Save LR. */ \
- mov r0, #0xffff0fff; /* Point to the high page. */ \
- mov lr, pc; /* Save our return address. */ \
- sub pc, r0, #31; /* Jump to the TLS entry. */ \
- ldr lr, [sp], #4; /* Restore LR. */ \
- mov r2, r0; /* Save the TLS addr in r2. */ \
- ldr r3, [r2, #PID_OFFSET]; /* Load the saved PID. */ \
- rsbs r0, r3, #0; /* Negate it. */ \
- moveq r0, #0x80000000; /* Use 0x80000000 if it was 0. */ \
- str r0, [r2, #PID_OFFSET] /* Store the temporary PID. */
-
-/* Restore the old PID value in the parent. */
-#define RESTORE_PID \
- cmp r0, #0; /* If we are the parent... */ \
- strne r3, [r2, #PID_OFFSET] /* ... restore the saved PID. */
-
-#include "../../../../../../../libc/sysdeps/linux/nios2/vfork.S"
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/nptl-signals.h b/libpthread/nptl/sysdeps/unix/sysv/linux/nptl-signals.h
new file mode 100644
index 000000000..43aa1a939
--- /dev/null
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/nptl-signals.h
@@ -0,0 +1,84 @@
+/* Special use of signals in NPTL internals. Linux version.
+ Copyright (C) 2014-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <signal.h>
+
+/* The signal used for asynchronous cancelation. */
+#define SIGCANCEL __SIGRTMIN
+
+
+/* Signal needed for the kernel-supported POSIX timer implementation.
+ We can reuse the cancellation signal since we can distinguish
+ cancellation from timer expirations. */
+#define SIGTIMER SIGCANCEL
+
+
+/* Signal used to implement the setuid et.al. functions. */
+#define SIGSETXID (__SIGRTMIN + 1)
+
+
+/* Return is sig is used internally. */
+static inline int
+__nptl_is_internal_signal (int sig)
+{
+ return (sig == SIGCANCEL) || (sig == SIGTIMER) || (sig == SIGSETXID);
+}
+
+/* Remove internal glibc signal from the mask. */
+static inline void
+__nptl_clear_internal_signals (sigset_t *set)
+{
+ __sigdelset (set, SIGCANCEL);
+ __sigdelset (set, SIGTIMER);
+ __sigdelset (set, SIGSETXID);
+}
+
+#define SIGALL_SET \
+ ((__sigset_t) { .__val = {[0 ... _SIGSET_NWORDS-1 ] = -1 } })
+
+/* Block all signals, including internal glibc ones. */
+static inline int
+__libc_signal_block_all (sigset_t *set)
+{
+ INTERNAL_SYSCALL_DECL (err);
+ return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &SIGALL_SET,
+ set, _NSIG / 8);
+}
+
+/* Block all application signals (excluding internal glibc ones). */
+static inline int
+__libc_signal_block_app (sigset_t *set)
+{
+ sigset_t allset = SIGALL_SET;
+ __nptl_clear_internal_signals (&allset);
+ INTERNAL_SYSCALL_DECL (err);
+ return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &allset, set,
+ _NSIG / 8);
+}
+
+/* Restore current process signal mask. */
+static inline int
+__libc_signal_restore_set (const sigset_t *set)
+{
+ INTERNAL_SYSCALL_DECL (err);
+ return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, set, NULL,
+ _NSIG / 8);
+}
+
+/* Used to communicate with signal handler. */
+extern struct xid_command *__xidcmd attribute_hidden;
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch
index 2abb1d22a..689e029df 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/Makefile.arch
@@ -9,7 +9,5 @@ libpthread_linux_arch_SSRC =
libpthread_linux_arch_CSRC = pthread_once.c
libc_linux_arch_CSRC = fork.c
-libc_linux_arch_SSRC = clone.S vfork.S
ASFLAGS += -DUSE___THREAD
-
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S
deleted file mode 100644
index 675a997e9..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/clone.S
+++ /dev/null
@@ -1,9 +0,0 @@
-/* We want an #include_next, but we are the main source file.
- So, #include ourselves and in that incarnation we can use #include_next. */
-#ifndef INCLUDED_SELF
-# define INCLUDED_SELF
-# include <clone.S>
-#else
-# define RESET_PID
-# include_next <clone.S>
-#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S
deleted file mode 100644
index 28c59fd2e..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/powerpc/vfork.S
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Copyright (C) 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-#define _ERRNO_H 1
-#include <bits/errno.h>
-#include <bits/kernel-features.h>
-#include <tcb-offsets.h>
-
-/* Clone the calling process, but without copying the whole address space.
- The calling process is suspended until the new process exits or is
- replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
- and the process ID of the new process to the old process. */
-
-ENTRY (__vfork)
- lwz 0,PID(2)
- cmpwi 0,0,0
- neg 0,0
- bne- 0,1f
- lis 0,0x8000
-1: stw 0,PID(2)
-
- DO_CALL (SYS_ify (vfork))
-
- cmpwi 1,3,0
- beqlr- 1
-
- lwz 0,PID(2)
- /* Cannot use clrlwi. here, because cr0 needs to be preserved
- until PSEUDO_RET. */
- clrlwi 4,0,1
- cmpwi 1,4,0
- beq- 1,1f
- neg 4,0
-1: stw 4,PID(2)
-
- PSEUDO_RET
-
-PSEUDO_END (__vfork)
-libc_hidden_def (__vfork)
-weak_alias (__vfork, vfork)
-libc_hidden_weak(vfork)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c
index e27ab5104..1cce9bfc9 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_kill.c
@@ -57,9 +57,10 @@ __pthread_kill (
function would have to be called while the thread is executing
fork, it would have to happen in a signal handler. But this is
no allowed, pthread_kill is not guaranteed to be async-safe. */
+
+ pid_t pid = getpid ();
int val;
- val = INTERNAL_SYSCALL (tgkill, err, 3, THREAD_GETMEM (THREAD_SELF, pid),
- tid, signo);
+ val = INTERNAL_SYSCALL (tgkill, err, 3, pid, tid, signo);
return (INTERNAL_SYSCALL_ERROR_P (val, err)
? INTERNAL_SYSCALL_ERRNO (val, err) : 0);
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c
index 2b7fa1471..0bd3b7983 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/pthread_sigqueue.c
@@ -53,26 +53,22 @@ pthread_sigqueue (
if (signo == SIGCANCEL || signo == SIGTIMER || signo == SIGSETXID)
return EINVAL;
+ pid_t pid = getpid ();
+
/* Set up the siginfo_t structure. */
siginfo_t info;
memset (&info, '\0', sizeof (siginfo_t));
info.si_signo = signo;
info.si_code = SI_QUEUE;
- info.si_pid = THREAD_GETMEM (THREAD_SELF, pid);
+ info.si_pid = pid;
info.si_uid = getuid ();
info.si_value = value;
/* We have a special syscall to do the work. */
INTERNAL_SYSCALL_DECL (err);
- /* One comment: The PID field in the TCB can temporarily be changed
- (in fork). But this must not affect this code here. Since this
- function would have to be called while the thread is executing
- fork, it would have to happen in a signal handler. But this is
- no allowed, pthread_sigqueue is not guaranteed to be async-safe. */
int val = INTERNAL_SYSCALL (rt_tgsigqueueinfo, err, 4,
- THREAD_GETMEM (THREAD_SELF, pid),
- tid, signo, &info);
+ pid, tid, signo, &info);
return (INTERNAL_SYSCALL_ERROR_P (val, err)
? INTERNAL_SYSCALL_ERRNO (val, err) : 0);
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c b/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c
index 6b159384f..f74cd0be3 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/raise.c
@@ -20,37 +20,32 @@
#include <limits.h>
#include <signal.h>
#include <sysdep.h>
-#include <pthreadP.h>
-
+#include <nptl-signals.h>
int
raise (int sig)
{
- struct pthread *pd = THREAD_SELF;
- pid_t pid = THREAD_GETMEM (pd, pid);
- pid_t selftid = THREAD_GETMEM (pd, tid);
- if (selftid == 0)
- {
- /* This system call is not supposed to fail. */
-#ifdef INTERNAL_SYSCALL
- INTERNAL_SYSCALL_DECL (err);
- selftid = INTERNAL_SYSCALL (gettid, err, 0);
-#else
- selftid = INLINE_SYSCALL (gettid, 0);
-#endif
- THREAD_SETMEM (pd, tid, selftid);
-
- /* We do not set the PID field in the TID here since we might be
- called from a signal handler while the thread executes fork. */
- pid = selftid;
- }
- else
- /* raise is an async-safe function. It could be called while the
- fork/vfork function temporarily invalidated the PID field. Adjust for
- that. */
- if (__builtin_expect (pid <= 0, 0))
- pid = (pid & INT_MAX) == 0 ? selftid : -pid;
-
- return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
+ /* rt_sigprocmask may fail if:
+
+ 1. sigsetsize != sizeof (sigset_t) (EINVAL)
+ 2. a failure in copy from/to user space (EFAULT)
+ 3. an invalid 'how' operation (EINVAL)
+
+ The first case is already handle in glibc syscall call by using the arch
+ defined _NSIG. Second case is handled by using a stack allocated mask.
+ The last one should be handled by the block/unblock functions. */
+
+ sigset_t set;
+ __libc_signal_block_app (&set);
+
+ INTERNAL_SYSCALL_DECL (err);
+ pid_t pid = INTERNAL_SYSCALL (getpid, err, 0);
+ pid_t tid = INTERNAL_SYSCALL (gettid, err, 0);
+
+ int ret = INLINE_SYSCALL (tgkill, 3, pid, tid, sig);
+
+ __libc_signal_restore_set (&set);
+
+ return ret;
}
libc_hidden_def (raise)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/Makefile.arch
index c07498f94..e3b2f7c4e 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/Makefile.arch
@@ -13,7 +13,5 @@ libpthread_linux_arch_SSRC = pthread_once.S pthread_rwlock_wrlock.S \
sem_post.S sem_timedwait.S sem_trywait.S sem_wait.S
libc_linux_arch_CSRC = fork.c
-libc_linux_arch_SSRC = clone.S vfork.S
ASFLAGS += -DUSE___THREAD
-
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/clone.S
deleted file mode 100644
index 918d57926..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/clone.S
+++ /dev/null
@@ -1,2 +0,0 @@
-#define RESET_PID
-#include <libc/sysdeps/linux/sh/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sh/vfork.S
deleted file mode 100644
index 5ea1bc120..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/sh/vfork.S
+++ /dev/null
@@ -1,70 +0,0 @@
-/* Copyright (C) 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-#define _ERRNO_H 1
-#include <bits/errno.h>
-#include <tcb-offsets.h>
-
-/* Clone the calling process, but without copying the whole address space.
- The calling process is suspended until the new process exits or is
- replaced by a call to `execve'. Return -1 for errors, 0 to the new process,
- and the process ID of the new process to the old process. */
-
-ENTRY (__vfork)
- /* Save the PID value. */
- stc gbr, r2
- mov.w .L2, r0
- mov.l @(r0,r2), r4
- neg r4, r1
- tst r1, r1
- bf 1f
- mov #1, r1
- rotr r1
-1:
- mov.l r1, @(r0,r2)
-
- mov.w .L1, r3
- trapa #0x10
- mov r0, r1
-
- /* Restore the old PID value in the parent. */
- tst r0, r0
- bt.s 2f
- stc gbr, r2
- mov.w .L2, r0
- mov.l r4, @(r0,r2)
- mov r1, r0
-2:
- mov #-12, r2
- shad r2, r1
- not r1, r1 // r1=0 means r0 = -1 to -4095
- tst r1, r1 // i.e. error in linux
- bf .Lpseudo_end
- SYSCALL_ERROR_HANDLER
-.Lpseudo_end:
- rts
- nop
-.L1:
- .word __NR_vfork
-.L2:
- .word PID - TLS_PRE_TCB_SIZE
- .align 2
-PSEUDO_END (__vfork)
-hidden_def (vfork)
-
-weak_alias (__vfork, vfork)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/Makefile.arch
index f93ad4d8d..5253f1c2f 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/Makefile.arch
@@ -5,12 +5,9 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-libpthread_linux_arch_SSRC = clone.S
libpthread_linux_arch_CSRC = pthread_once.c lowlevellock.c \
pthread_barrier_init.c pthread_barrier_wait.c pthread_barrier_destroy.c
libc_linux_arch_CSRC = fork.c libc-lowlevellock.c
-libc_linux_arch_SSRC = clone.S vfork.S
ASFLAGS += -DUSE___THREAD
-
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/clone.S
deleted file mode 100644
index a6142aafe..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/clone.S
+++ /dev/null
@@ -1,2 +0,0 @@
-#define RESET_PID
-#include <libc/sysdeps/linux/sparc/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/vfork.S
deleted file mode 100644
index 71f0662a2..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/sparc/vfork.S
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Copyright (C) 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <sysdep.h>
-#include <tcb-offsets.h>
-
- .text
- .globl __syscall_error
-ENTRY(__vfork)
- ld [%g7 + PID], %o5
- cmp %o5, 0
- bne 1f
- sub %g0, %o5, %o4
- sethi %hi(0x80000000), %o4
-1: st %o4, [%g7 + PID]
-
- LOADSYSCALL(vfork)
- ta 0x10
- bcc 2f
- mov %o7, %g1
- st %o5, [%g7 + PID]
- call __syscall_error
- mov %g1, %o7
-2: sub %o1, 1, %o1
- andcc %o0, %o1, %o0
- bne,a 1f
- st %o5, [%g7 + PID]
-1: retl
- nop
-END(__vfork)
-
-libc_hidden_def (vfork)
-weak_alias (__vfork, vfork)
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile.arch
index b48f4cb0b..f3883dbe0 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/Makefile.arch
@@ -5,7 +5,7 @@
# Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
#
-libpthread_linux_arch_SSRC = clone.S pthread_once.S \
+libpthread_linux_arch_SSRC = pthread_once.S \
lowlevellock.S pthread_barrier_wait.S pthread_cond_signal.S pthread_cond_broadcast.S \
sem_post.S sem_timedwait.S lowlevelrobustlock.S \
sem_trywait.S sem_wait.S pthread_rwlock_rdlock.S pthread_rwlock_wrlock.S \
@@ -14,9 +14,7 @@ libpthread_linux_arch_SSRC = clone.S pthread_once.S \
libpthread_linux_arch_CSRC = pthread_spin_init.c
libc_linux_arch_CSRC = fork.c
-libc_linux_arch_SSRC = clone.S vfork.S libc-cancellation.S libc-lowlevellock.S
-libc_linux_arch_SSRC-OMIT = waitpid.S
+libc_linux_arch_SSRC = libc-cancellation.S libc-lowlevellock.S
librt_linux_arch_SSRC = librt-cancellation.S
ASFLAGS += -DUSE___THREAD
-
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S
deleted file mode 100644
index efbaee3d1..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/clone.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#include <tcb-offsets.h>
-#define RESET_PID
-#include <libc/sysdeps/linux/x86_64/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S
deleted file mode 100644
index f3280b8cc..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/x86_64/vfork.S
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Copyright (C) 2004 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
-
-/* We want an #include_next, but we are the main source file.
- So, #include ourselves and in that incarnation we can use #include_next. */
-#ifndef INCLUDED_SELF
-# define INCLUDED_SELF
-# include <vfork.S>
-#else
-
-# include <tcb-offsets.h>
-
-# define SAVE_PID \
- movl %fs:PID, %esi; \
- movl $0x80000000, %ecx; \
- movl %esi, %edx; \
- negl %edx; \
- cmove %ecx, %edx; \
- movl %edx, %fs:PID
-
-# define RESTORE_PID \
- testq %rax, %rax; \
- je 1f; \
- movl %esi, %fs:PID; \
-1:
-
-# include_next <vfork.S>
-#endif
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/Makefile.arch b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/Makefile.arch
index 7014c3f04..6f1734871 100644
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/Makefile.arch
+++ b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/Makefile.arch
@@ -2,13 +2,10 @@
# Licensed under the LGPL v2.1, see the file COPYING and LICENSE.
libc_linux_arch_CSRC = fork.c
-libc_linux_arch_SSRC = clone.S vfork.S
libpthread_linux_arch_CSRC = pthread_once.c
libpthread_linux_arch_SSRC =
CFLAGS-OMIT-fork.c = -DNOT_IN_libc -DIS_IN_libpthread
-ASFLAGS-clone.S = -D_LIBC_REENTRANT
-ASFLAGS-vfork.S = -D_LIBC_REENTRANT
ASFLAGS-syscall.S = -D_LIBC_REENTRANT
ASFLAGS-mmap.S = -D_LIBC_REENTRANT
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/clone.S b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/clone.S
deleted file mode 100644
index 539b9ef38..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/clone.S
+++ /dev/null
@@ -1,3 +0,0 @@
-#define RESET_PID
-#include <tcb-offsets.h>
-#include <libc/sysdeps/linux/xtensa/clone.S>
diff --git a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/vfork.S b/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/vfork.S
deleted file mode 100644
index 46eb76dd6..000000000
--- a/libpthread/nptl/sysdeps/unix/sysv/linux/xtensa/vfork.S
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright (C) 2013 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
-
- The GNU C Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- The GNU C Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with the GNU C Library. If not, see
- <http://www.gnu.org/licenses/>. */
-
-#include <tls.h>
-
-/*
- Save the PID value, save 0x80000000 if PID was 0.
- Registers a2 and a3 are available; ar should return the PID and as threadptr
- */
-
-#define SAVE_PID(pid,tp,ar,as) \
- rur tp, threadptr; \
- movi ar, TLS_PRE_TCB_SIZE; \
- sub tp, tp, ar; \
- l32i pid, tp, PID; \
- neg ar, pid; \
- movi as, 0x80000000; \
- moveqz ar, as, ar; \
- s32i ar, tp, PID; \
-
-/*
- Restore the PID value, restore to 0 if saved value was 0x80000000
- Return value from the syscall is in a2.
- */
-#define RESTORE_PID(pid,tp,res) \
- beqz res, 1f; \
- s32i pid, tp, PID; \
-1:
-
-/*
- Special version for call12, where we don't have enough registers
- available to preserve the original PID.
- */
-#define RESTORE_PID12(ar, as, at) \
- rur as, threadptr; \
- movi ar, TLS_PRE_TCB_SIZE; \
- sub as, as, ar; \
- l32i ar, as, PID; \
- movi at, 0x80000000; \
- sub at, at, ar; \
- neg ar, ar; \
- moveqz ar, at, at; \
- s32i ar, as, PID;
-
-#include <libc/sysdeps/linux/xtensa/vfork.S>
diff --git a/libpthread/nptl/sysdeps/x86_64/tcb-offsets.sym b/libpthread/nptl/sysdeps/x86_64/tcb-offsets.sym
index cf863752e..d908521be 100644
--- a/libpthread/nptl/sysdeps/x86_64/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/x86_64/tcb-offsets.sym
@@ -3,7 +3,6 @@
RESULT offsetof (struct pthread, result)
TID offsetof (struct pthread, tid)
-PID offsetof (struct pthread, pid)
CANCELHANDLING offsetof (struct pthread, cancelhandling)
CLEANUP_JMP_BUF offsetof (struct pthread, cleanup_jmp_buf)
CLEANUP offsetof (struct pthread, cleanup)
diff --git a/libpthread/nptl/sysdeps/xtensa/tcb-offsets.sym b/libpthread/nptl/sysdeps/xtensa/tcb-offsets.sym
index 4c8687647..54eae20b1 100644
--- a/libpthread/nptl/sysdeps/xtensa/tcb-offsets.sym
+++ b/libpthread/nptl/sysdeps/xtensa/tcb-offsets.sym
@@ -3,5 +3,4 @@
TLS_PRE_TCB_SIZE sizeof (struct pthread)
MULTIPLE_THREADS_OFFSET offsetof (struct pthread, header.multiple_threads)
-PID offsetof (struct pthread, pid)
TID offsetof (struct pthread, tid)