Update.
authorUlrich Drepper <drepper@redhat.com>
Fri, 7 Feb 2003 06:46:21 +0000 (06:46 +0000)
committerUlrich Drepper <drepper@redhat.com>
Fri, 7 Feb 2003 06:46:21 +0000 (06:46 +0000)
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.

13 files changed:
linuxthreads/ChangeLog
linuxthreads/Makefile
linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S
linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S
linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S
linuxthreads/sysdeps/unix/sysv/linux/powerpc/powerpc32/vfork.S
linuxthreads/sysdeps/unix/sysv/linux/s390/s390-64/vfork.S
linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S
linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S
linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S
linuxthreads/tst-popen2.c [new file with mode: 0644]
nptl/ChangeLog
nptl/Makefile

index 648bd31..297a01b 100644 (file)
@@ -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
index f1af122..2978072 100644 (file)
@@ -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
index e750724..9002a3b 100644 (file)
@@ -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
 
index 298aedc..f4a56a5 100644 (file)
@@ -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.  */
index 172ac2b..5541edb 100644 (file)
 /* 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
index 1759005..e85f662 100644 (file)
 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
 
index efc9710..d2faaa1 100644 (file)
    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.  */
index 5e98554..2da7703 100644 (file)
 #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
index 98ad457..8b85d76 100644 (file)
 
 #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
index 3e867a6..28989ea 100644 (file)
 
 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 (file)
index 0000000..3ff69ac
--- /dev/null
@@ -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"
index 997fbbf..faf0720 100644 (file)
@@ -1,5 +1,8 @@
 2003-02-06  Ulrich Drepper  <drepper@redhat.com>
 
+       * Makefile (tests): Add tst-popen1.
+       * tst-popen1.c: New file.
+
        * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_wait.S: Remove wrong
        but inactive generalization.
        * sysdeps/unix/sysv/linux/i386/i486/pthread_cond_timedwait.S: Likewise.
index 6c1ef94..f006421 100644 (file)
@@ -151,7 +151,8 @@ tests = tst-mutex1 tst-mutex2 tst-mutex3 tst-mutex4 tst-mutex5 tst-mutex6 \
        tst-unload \
        tst-sysconf \
        tst-locale1 tst-locale2 \
-       tst-umask1
+       tst-umask1 \
+       tst-popen1
 
 LDFLAGS-pthread.so = -Wl,--enable-new-dtags,-z,nodelete,-z,initfirst