From: Ulrich Drepper Date: Thu, 9 Jan 2003 20:30:21 +0000 (+0000) Subject: Update. X-Git-Tag: cvs/glibc-2_3_2~335 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=29d9a17dba956f7d14eb0dd15f71751fd6da02ce;p=platform%2Fupstream%2Fglibc.git Update. 2003-01-09 Jakub Jelinek * posix/test-vfork.c (noop): Add __attribute_noinline__. * sysdeps/generic/sysdep.h (JUMPTARGET): Define if not defined. * sysdeps/i386/sysdep.h (JUMPTARGET): Undefine JUMPTARGET before defining it. * sysdeps/powerpc/powerpc32/sysdep.h (JUMPTARGET): Likewise. * sysdeps/powerpc/powerpc64/sysdep.h (JUMPTARGET): Likewise. * sysdeps/s390/s390-32/sysdep.h (JUMPTARGET): Likewise. * sysdeps/s390/s390-64/sysdep.h (JUMPTARGET): Likewise. * sysdeps/x86_64/sysdep.h (JUMPTARGET): Likewise. --- diff --git a/ChangeLog b/ChangeLog index 5957e05..134ab27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2003-01-09 Jakub Jelinek + + * posix/test-vfork.c (noop): Add __attribute_noinline__. + * sysdeps/generic/sysdep.h (JUMPTARGET): Define if not defined. + * sysdeps/i386/sysdep.h (JUMPTARGET): Undefine JUMPTARGET before + defining it. + * sysdeps/powerpc/powerpc32/sysdep.h (JUMPTARGET): Likewise. + * sysdeps/powerpc/powerpc64/sysdep.h (JUMPTARGET): Likewise. + * sysdeps/s390/s390-32/sysdep.h (JUMPTARGET): Likewise. + * sysdeps/s390/s390-64/sysdep.h (JUMPTARGET): Likewise. + * sysdeps/x86_64/sysdep.h (JUMPTARGET): Likewise. + 2003-01-09 Andreas Schwab * sysdeps/m68k/fpu/libm-test-ulps: Regenerated. diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog index 0a6e6a6..862b548 100644 --- a/linuxthreads/ChangeLog +++ b/linuxthreads/ChangeLog @@ -1,3 +1,16 @@ +2003-01-09 Jakub Jelinek + + * sysdeps/unix/sysv/linux/i386/vfork.S: New file. + * sysdeps/unix/sysv/linux/ia64/vfork.S: New file. + * sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h + [__ASSEMBLER__] (SINGLE_THREAD_P): Remove trailing ;;. + * sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S: New file. + * sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S: New file. + * sysdeps/unix/sysv/linux/x86_64/vfork.S: New file. + * sysdeps/unix/sysv/linux/alpha/vfork.S: New file. + * tst-popen.c: New test. + * Makefile (tests): Add tst-popen. + 2003-01-06 Jakub Jelinek * sysdeps/unix/sysv/linux/sigwait.c (do_sigwait): Add diff --git a/linuxthreads/Makefile b/linuxthreads/Makefile index ef34cda..f1af122 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-cancel6 tst-popen 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 new file mode 100644 index 0000000..c057bd2 --- /dev/null +++ b/linuxthreads/sysdeps/unix/sysv/linux/alpha/vfork.S @@ -0,0 +1,38 @@ +/* Copyright (C) 2003 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + + +#include + + .globl __vfork + .align 4 + .ent __vfork,0 +__LABEL(__vfork) + ldgp gp, 0(pv) + .prologue 1 + PSEUDO_PROF + SINGLE_THREAD_P(t0) + bne t0, HIDDEN_JUMPTARGET (__fork) !samegp + lda v0, SYS_ify(vfork) + call_pal PAL_callsys + bne a3, __syscall_error !samegp + ret +PSEUDO_END(__vfork) +libc_hidden_def (__vfork) + +weak_alias (__vfork, vfork) diff --git a/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S b/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S new file mode 100644 index 0000000..298aedc --- /dev/null +++ b/linuxthreads/sysdeps/unix/sysv/linux/i386/vfork.S @@ -0,0 +1,81 @@ +/* Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Andreas Schwab . + + 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#define _ERRNO_H 1 +#include +#include + +/* 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) + +#ifdef __NR_vfork + + SINGLE_THREAD_P + jne HIDDEN_JUMPTARGET (__fork) + + /* Pop the return PC value into ECX. */ + popl %ecx + + /* Stuff the syscall number in EAX and enter into the kernel. */ + movl $SYS_ify (vfork), %eax + int $0x80 + + /* Jump to the return PC. Don't jump directly since this + disturbs the branch target cache. Instead push the return + address back on the stack. */ + pushl %ecx + + cmpl $-4095, %eax + /* Branch forward if it failed. */ +# ifdef __ASSUME_VFORK_SYSCALL + jae SYSCALL_ERROR_LABEL +.Lpseudo_end: +# else + jae .Lerror +# endif + + ret + +# ifndef __ASSUME_VFORK_SYSCALL +.Lerror: + /* Check if vfork syscall is known at all. */ + cmpl $-ENOSYS, %eax + jne SYSCALL_ERROR_LABEL +# endif +#endif + +#ifndef __ASSUME_VFORK_SYSCALL + /* If we don't have vfork, fork is close enough. */ + + movl $SYS_ify (fork), %eax + int $0x80 + cmpl $-4095, %eax + jae SYSCALL_ERROR_LABEL +.Lpseudo_end: + ret +#endif +PSEUDO_END (__vfork) +libc_hidden_def (__vfork) + +weak_alias (__vfork, vfork) diff --git a/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h b/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h index ec787da..ec94517 100644 --- a/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h +++ b/linuxthreads/sysdeps/unix/sysv/linux/ia64/sysdep-cancel.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2002 Free Software Foundation, Inc. +/* Copyright (C) 2002, 2003 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2002. @@ -105,7 +105,7 @@ __syscall_error_##args: \ p_header.data.multiple_threads) == 0, 1) # else # define SINGLE_THREAD_P \ - adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14 ;; + adds r14 = MULTIPLE_THREADS_OFFSET, r13 ;; ld4 r14 = [r14] ;; cmp4.ne p6, p7 = 0, r14 # endif #elif !defined __ASSEMBLER__ diff --git a/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S b/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S new file mode 100644 index 0000000..78c2622 --- /dev/null +++ b/linuxthreads/sysdeps/unix/sysv/linux/ia64/vfork.S @@ -0,0 +1,49 @@ +/* Copyright (C) 2000, 2002, 2003 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + + +#include +#define _SIGNAL_H +#include + +#define JUMPTARGET(name) name + +/* The following are defined in linux/sched.h, which unfortunately */ +/* is not safe for inclusion in an assembly file. */ +#define CLONE_VM 0x00000100 /* set if VM shared between processes */ +#define CLONE_VFORK 0x00004000 /* set if the parent wants the child to wake it up on mm_release */ + +/* pid_t vfork(void); */ +/* Implemented as __clone_syscall(CLONE_VFORK | CLONE_VM | SIGCHLD, 0) */ + +ENTRY(__vfork) + SINGLE_THREAD_P +(p6) br.cond.spnt.few HIDDEN_JUMPTARGET (__fork);; + alloc r2=ar.pfs,0,0,2,0 + mov out0=CLONE_VM+CLONE_VFORK+SIGCHLD + mov out1=0 /* Standard sp value. */ + ;; + DO_CALL (SYS_ify (clone)) + cmp.eq p6,p0=-1,r10 + ;; +(p6) br.cond.spnt.few __syscall_error + ret +PSEUDO_END(__vfork) +libc_hidden_def (__vfork) + +weak_alias (__vfork, vfork) diff --git a/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S b/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S new file mode 100644 index 0000000..adf7b22 --- /dev/null +++ b/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S @@ -0,0 +1,37 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2003. + + 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + + .text +ENTRY(__vfork) + ld [%g6 + MULTIPLE_THREADS_OFFSET], %o0 + cmp %o0, 0 + bne HIDDEN_JUMPTARGET(__fork) + mov __NR_vfork, %g1 + ta 0x10; + bcs __syscall_error_handler + nop + sub %o1, 1, %o1 + retl + and %o0, %o1, %o0 + SYSCALL_ERROR_HANDLER +PSEUDO_END (__vfork) +libc_hidden_def (__vfork) +weak_alias (__vfork, vfork) diff --git a/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S b/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S new file mode 100644 index 0000000..e4ea918 --- /dev/null +++ b/linuxthreads/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S @@ -0,0 +1,36 @@ +/* Copyright (C) 2003 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2003. + + 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include + + .text +ENTRY(__vfork) + ld [%g6 + MULTIPLE_THREADS_OFFSET], %o0 + bne HIDDEN_JUMPTARGET (__fork) + mov __NR_vfork, %g1 + ta 0x6d + bcs,pn %xcc, __syscall_error_handler + nop + sub %o1, 1, %o1 + retl + and %o0, %o1, %o0 + SYSCALL_ERROR_HANDLER +PSEUDO_END (__vfork) +libc_hidden_def (__vfork) +weak_alias (__vfork, vfork) diff --git a/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S b/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S new file mode 100644 index 0000000..3e867a6 --- /dev/null +++ b/linuxthreads/sysdeps/unix/sysv/linux/x86_64/vfork.S @@ -0,0 +1,54 @@ +/* Copyright (C) 2001, 2002, 2003 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, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#define _ERRNO_H 1 +#include + +/* 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) + + SINGLE_THREAD_P + jne HIDDEN_JUMPTARGET (__fork) + + /* Pop the return PC value into RDI. We need a register that + is preserved by the syscall and that we're allowed to destroy. */ + popq %rdi + + /* Stuff the syscall number in RAX and enter into the kernel. */ + movl $SYS_ify (vfork), %eax + syscall + + /* Push back the return PC. */ + pushq %rdi + + cmpl $-4095, %eax + jae SYSCALL_ERROR_LABEL /* Branch forward if it failed. */ + + /* Normal return. */ +.Lpseudo_end: + ret + +PSEUDO_END (__vfork) +libc_hidden_def (__vfork) + +weak_alias (__vfork, vfork) diff --git a/linuxthreads/tst-popen.c b/linuxthreads/tst-popen.c new file mode 100644 index 0000000..f76a6e7 --- /dev/null +++ b/linuxthreads/tst-popen.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include +#include +#include +#include + +static void * +dummy (void *x) +{ + return NULL; +} + +static char buf[sizeof "something\n"]; + +static int +do_test (void) +{ + FILE *f; + pthread_t p; + + pthread_create (&p, NULL, dummy, NULL); + 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"); + exit (0); +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/sysdeps/generic/sysdep.h b/sysdeps/generic/sysdep.h index 280e0e4..0d69ac6 100644 --- a/sysdeps/generic/sysdep.h +++ b/sysdeps/generic/sysdep.h @@ -1,5 +1,5 @@ /* Generic asm macros used on many machines. - Copyright (C) 1991,92,93,96,98,2002 Free Software Foundation, Inc. + Copyright (C) 1991,92,93,96,98,2002,2003 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 @@ -42,4 +42,8 @@ #ifndef END #define END(sym) #endif + +#ifndef JUMPTARGET +#define JUMPTARGET(sym) sym +#endif #endif /* __ASSEMBLER__ */ diff --git a/sysdeps/i386/sysdep.h b/sysdeps/i386/sysdep.h index 55f376d..9fa7f8d 100644 --- a/sysdeps/i386/sysdep.h +++ b/sysdeps/i386/sysdep.h @@ -1,5 +1,5 @@ /* Assembler macros for i386. - Copyright (C) 1991,92,93,95,96,98,2002 Free Software Foundation, Inc. + Copyright (C) 1991,92,93,95,96,98,2002,2003 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 @@ -108,6 +108,7 @@ lose: SYSCALL_PIC_SETUP \ #define PSEUDO_END(name) \ END (name) +#undef JUMPTARGET #ifdef PIC #define JUMPTARGET(name) name##@PLT #define SYSCALL_PIC_SETUP \ diff --git a/sysdeps/powerpc/powerpc32/sysdep.h b/sysdeps/powerpc/powerpc32/sysdep.h index 169abf7..7453835 100644 --- a/sysdeps/powerpc/powerpc32/sysdep.h +++ b/sysdeps/powerpc/powerpc32/sysdep.h @@ -1,5 +1,5 @@ /* Assembly macros for 32-bit PowerPC. - Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 1999, 2001, 2002, 2003 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 @@ -104,6 +104,7 @@ li 0,syscall; \ sc +#undef JUMPTARGET #ifdef PIC #define JUMPTARGET(name) name##@plt #else diff --git a/sysdeps/powerpc/powerpc64/sysdep.h b/sysdeps/powerpc/powerpc64/sysdep.h index 6a50517..c25df40 100644 --- a/sysdeps/powerpc/powerpc64/sysdep.h +++ b/sysdeps/powerpc/powerpc64/sysdep.h @@ -1,5 +1,5 @@ /* Assembly macros for 64-bit PowerPC. - Copyright (C) 2002 Free Software Foundation, Inc. + Copyright (C) 2002, 2003 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 @@ -207,6 +207,7 @@ LT_LABELSUFFIX(name,_name_end): ; \ sc /* ppc64 is always PIC */ +#undef JUMPTARGET #define JUMPTARGET(name) DOT_LABEL(name) #define PSEUDO(name, syscall_name, args) \ diff --git a/sysdeps/s390/s390-32/sysdep.h b/sysdeps/s390/s390-32/sysdep.h index 2fe9f53..316fc4c 100644 --- a/sysdeps/s390/s390-32/sysdep.h +++ b/sysdeps/s390/s390-32/sysdep.h @@ -1,5 +1,5 @@ /* Assembler macros for s390. - Copyright (C) 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -94,6 +94,7 @@ lose: SYSCALL_PIC_SETUP \ #define PSEUDO_END(name) \ END (name) +#undef JUMPTARGET #ifdef PIC #define JUMPTARGET(name) \ basr %r1,0 \ diff --git a/sysdeps/s390/s390-64/sysdep.h b/sysdeps/s390/s390-64/sysdep.h index 7cf745b..430cee3 100644 --- a/sysdeps/s390/s390-64/sysdep.h +++ b/sysdeps/s390/s390-64/sysdep.h @@ -1,5 +1,5 @@ /* Assembler macros for 64 bit S/390. - Copyright (C) 2001 Free Software Foundation, Inc. + Copyright (C) 2001, 2003 Free Software Foundation, Inc. Contributed by Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of the GNU C Library. @@ -92,6 +92,7 @@ lose: SYSCALL_PIC_SETUP \ #define PSEUDO_END(name) \ END (name) +#undef JUMPTARGET #ifdef PIC #define JUMPTARGET(name) \ brasl name##@PLT diff --git a/sysdeps/x86_64/sysdep.h b/sysdeps/x86_64/sysdep.h index 1aa60fe..99b7e56 100644 --- a/sysdeps/x86_64/sysdep.h +++ b/sysdeps/x86_64/sysdep.h @@ -1,5 +1,5 @@ /* Assembler macros for x86-64. - Copyright (C) 2001, 2002 Free Software Foundation, Inc. + Copyright (C) 2001, 2002, 2003 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 @@ -86,6 +86,7 @@ lose: \ #define PSEUDO_END(name) \ END (name) +#undef JUMPTARGET #ifdef PIC #define JUMPTARGET(name) name##@PLT #else