diff options
Diffstat (limited to 'linuxthreads')
-rw-r--r-- | linuxthreads/ChangeLog | 14 | ||||
-rw-r--r-- | linuxthreads/Makefile | 2 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S | 4 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S | 14 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S | 9 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S | 13 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S | 9 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S | 23 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S | 23 | ||||
-rw-r--r-- | linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S | 8 | ||||
-rw-r--r-- | linuxthreads/tst-popen2.c | 41 |
11 files changed, 146 insertions, 14 deletions
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index 648bd31..297a01b 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,17 @@ +2003-02-07 Jakub Jelinek <jakub@redhat.com> + + * tst-popen2.c: New test. + * Makefile (tests): Add tst-popen2. + * sysdeps/unix/sysv/linux/alpha/vfork.S (__vfork): Branch to __fork + whenever libpthread.so is loaded. + * sysdeps/unix/sysv/linux/i386/vfork.S (__vfork): Likewise. + * sysdeps/unix/sysv/linux/ia64/vfork.S (__vfork): Likewise. + * sysdeps/unix/sysv/linux/s390/s390-64/vfork.S (__vfork): Likewise. + * sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S (__vfork): Likewise. + * sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S (__vfork): Likewise. + * sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S (__vfork): Likewise. + * sysdeps/unix/sysv/linux/x86_64/vfork.S (__vfork): Likewise. + 2003-02-05 Ulrich Drepper <drepper@redhat.com> * sysdeps/pthread/bits/libc-lock.h (__libc_once): Set control diff --git a/linuxthreads/Makefile b/linuxthreads/Makefile index f1af122..2978072 100644 --- a/linuxthreads/Makefile +++ b/linuxthreads/Makefile @@ -88,7 +88,7 @@ tests = ex1 ex2 ex3 ex4 ex5 ex6 ex7 ex8 ex9 $(librt-tests) ex12 ex13 joinrace \ tststack $(tests-nodelete-$(have-z-nodelete)) ecmutex ex14 ex15 ex16 \ ex17 ex18 tst-cancel tst-context bug-sleep \ tst-cancel1 tst-cancel2 tst-cancel3 tst-cancel4 tst-cancel5 \ - tst-cancel6 tst-popen + tst-cancel6 tst-popen tst-popen2 test-srcs = tst-signal # These tests are linked with libc before libpthread tests-reverse += tst-cancel5 diff --git a/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S b/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S index e750724..9002a3b 100644 --- a/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S +++ b/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S @@ -27,10 +27,12 @@ __LABEL(__vfork) .prologue 1 PSEUDO_PROF - SINGLE_THREAD_P(t0) #ifdef SHARED + ldq t0, __libc_pthread_functions(gp) !gprel bne t0, HIDDEN_JUMPTARGET (__fork) !samegp #else + .weak __pthread_fork + ldq t0, __pthread_fork(gp) !literal bne t0, $do_fork #endif diff --git a/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S b/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S index 298aedc..f4a56a5 100644 --- a/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S +++ b/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S @@ -31,7 +31,19 @@ ENTRY (__vfork) #ifdef __NR_vfork - SINGLE_THREAD_P +# ifdef SHARED +# if !defined HAVE_HIDDEN || !USE___THREAD + SETUP_PIC_REG (cx) +# else + call __i686.get_pc_thunk.cx +# endif + addl $_GLOBAL_OFFSET_TABLE_, %ecx + cmpl $0, __libc_pthread_functions@GOTOFF(%ecx) +# else + .weak __pthread_fork + movl $__pthread_fork, %eax + testl %eax, %eax +# endif jne HIDDEN_JUMPTARGET (__fork) /* Pop the return PC value into ECX. */ diff --git a/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S b/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S index 172ac2b..5541edb 100644 --- a/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S +++ b/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S @@ -30,7 +30,14 @@ /* Implemented as __clone_syscall(CLONE_VFORK | CLONE_VM | SIGCHLD, 0) */ ENTRY(__vfork) - SINGLE_THREAD_P +#ifdef SHARED + addl r14 = @gprel(__libc_pthread_functions#), gp;; +#else + .weak __pthread_fork + addl r14 = @ltoff(@fptr(__pthread_fork#)), gp;; +#endif + ld8 r14 = [r14];; + cmp.ne p6, p7 = 0, r14 (p6) br.cond.spnt.few HIDDEN_JUMPTARGET (__fork);; alloc r2=ar.pfs,0,0,2,0 mov out0=CLONE_VM+CLONE_VFORK+SIGCHLD diff --git a/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S b/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S index 1759005..e85f662 100644 --- a/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S +++ b/linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S @@ -29,11 +29,20 @@ ENTRY (__vfork) #ifdef __NR_vfork - - SINGLE_THREAD_P # ifdef SHARED + mflr 9 + bl _GLOBAL_OFFSET_TABLE_@local-4 + mflr 10 + mtlr 9 + lwz 10,__libc_pthread_functions@got(10) + lwz 10,0(10) + cmpwi 10,0 bne- HIDDEN_JUMPTARGET(__fork) # else + .weak __pthread_fork + lis 9,__pthread_fork@ha + la 9,__pthread_fork@l(9) + cmpwi 9,0 bne- .Lhidden_fork # endif diff --git a/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S b/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S index efc9710..d2faaa1 100644 --- a/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S +++ b/linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S @@ -27,7 +27,14 @@ and the process ID of the new process to the old process. */ ENTRY (__vfork) - SINGLE_THREAD_P +#ifdef SHARED + larl %r1,__libc_pthread_functions + lg %r1,0(%r1) +#else + .weak __pthread_fork + larl %r1,__pthread_fork +#endif + ltgr %r1,%r1 jgne HIDDEN_JUMPTARGET(__fork) /* Do vfork system call. */ diff --git a/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S b/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S index 5e98554..2da7703 100644 --- a/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S +++ b/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S @@ -20,9 +20,28 @@ #include <sysdep-cancel.h> .text +#ifdef SHARED +.LLGETPC0: + retl + addl %o7, %o0, %o0 +#endif ENTRY(__vfork) - ld [%g7 + MULTIPLE_THREADS_OFFSET], %o0 - cmp %o0, 0 +#ifdef SHARED + mov %o7, %o1 + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %o0 + call .LLGETPC0 + add %o0, %lo(_GLOBAL_OFFSET_TABLE_+4), %o0 + sethi %hi(__libc_pthread_functions), %o2 + mov %o1, %o7 + or %o2, %lo(__libc_pthread_functions), %o2 + ld [%o0 + %o2], %o2 + ld [%o2], %o2 + cmp %o2, 0 +#else + .weak __pthread_fork + sethi %hi(__pthread_fork), %o0 + orcc %o0, %lo(__pthread_fork), %o0 +#endif #if defined SHARED && !defined BROKEN_SPARC_WDISP22 bne HIDDEN_JUMPTARGET(__fork) #else diff --git a/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S b/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S index 98ad457..8b85d76 100644 --- a/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S +++ b/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S @@ -19,13 +19,28 @@ #include <sysdep-cancel.h> - .text +#ifdef SHARED +.LLGETPC0: + retl + addl %o7, %o0, %o0 +#endif ENTRY(__vfork) - ld [%g7 + MULTIPLE_THREADS_OFFSET], %o0 #ifdef SHARED - cmp %o0, 0 - bne HIDDEN_JUMPTARGET (__fork) + mov %o7, %o1 + sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %o0 + call .LLGETPC0 + add %o0, %lo(_GLOBAL_OFFSET_TABLE_+4), %o0 + sethi %hi(__libc_pthread_functions), %o2 + mov %o1, %o7 + or %o2, %lo(__libc_pthread_functions), %o2 + ldx [%o0 + %o2], %o2 + ldx [%o2], %o2 + cmp %o2, 0 + bne HIDDEN_JUMPTARGET(__fork) #else + .weak __pthread_fork + sethi %hi(__pthread_fork), %o0 + or %o0, %lo(__pthread_fork), %o0 brnz,pn %o0, 1f #endif mov __NR_vfork, %g1 diff --git a/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S b/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S index 3e867a6..28989ea 100644 --- a/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S +++ b/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S @@ -27,7 +27,13 @@ ENTRY (__vfork) - SINGLE_THREAD_P +#ifdef SHARED + cmpq $0, __libc_pthread_functions(%rip) +#else + .weak __pthread_fork + movq $__pthread_fork, %eax + testq %rax, %rax +#endif jne HIDDEN_JUMPTARGET (__fork) /* Pop the return PC value into RDI. We need a register that diff --git a/linuxthreads/tst-popen2.c b/linuxthreads/tst-popen2.c new file mode 100644 index 0000000..3ff69ac --- /dev/null +++ b/linuxthreads/tst-popen2.c @@ -0,0 +1,41 @@ +#include <errno.h> +#include <error.h> +#include <pthread.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +static void * +dummy (void *x) +{ + return NULL; +} + +static char buf[sizeof "something\n"]; + +static int +do_test (void) +{ + FILE *f; + pthread_t p; + int err; + + f = popen ("echo something", "r"); + if (f == NULL) + error (EXIT_FAILURE, errno, "popen failed"); + if (fgets (buf, sizeof (buf), f) == NULL) + error (EXIT_FAILURE, 0, "fgets failed"); + if (strcmp (buf, "something\n")) + error (EXIT_FAILURE, 0, "read wrong data"); + if (pclose (f)) + error (EXIT_FAILURE, errno, "pclose returned non-zero"); + if ((err = pthread_create (&p, NULL, dummy, NULL))) + error (EXIT_FAILURE, err, "pthread_create failed"); + if ((err = pthread_join (p, NULL))) + error (EXIT_FAILURE, err, "pthread_join failed"); + exit (0); +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" |