From patchwork Thu May 29 23:09:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 353865 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id EFC7014008B for ; Fri, 30 May 2014 09:09:38 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; q= dns; s=default; b=s4HuyuRNJp49TBmLlv1hPEllAR6fKiBAqGljheH2iu4wTz pxSKkjbckdOjAHvWpGXJFUli4ty1/UBZdhW2uNc9PzOUb/Cni3DiNuCo/uIN7nUy Pl8Q/A7X4x0hDXrNKlqMycTtY6q7l2JSyjEY3eO6rEfJwtAzmtAKM8qzDSLnw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:message-id:date; s= default; bh=dnhJeGL0m2fHsj8TQYwwG+Asqi4=; b=iohATvoeknANgumDncM3 k7dsKyI59qdDLyFEJBlbY+H2uCwolx+pX5ClXI/UmZOskh3mgpsL0lxq0Yhfgj19 1bQS7Yqb3aSgL7k2Ktno5zDtkC1nr7oYwHYFnhXfml5pNNsNI+zAf2JMStL0HYq4 HRRgCoRVtKS9JO27B3/FQAc= Received: (qmail 9321 invoked by alias); 29 May 2014 23:09:32 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 9301 invoked by uid 89); 29 May 2014 23:09:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [PATCH roland/nptl-sh] SH: Consolidate NPTL/non versions of vfork Message-Id: <20140529230926.133C22C3C21@topped-with-meat.com> Date: Thu, 29 May 2014 16:09:26 -0700 (PDT) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=29mdIY2FDLMA:10 a=Z6MIti7PxpgA:10 a=kj9zAlcOel0A:10 a=hOe2yjtxAAAA:8 a=mDV3o1hIAAAA:8 a=rXaInmXk7iX-kv74-AwA:9 a=aGSchFqbnnyPS6gv:21 a=iZrKFvI2pRy5zMDI:21 a=CjuIK1q_8ugA:10 I haven't tried to compile this or anything. It should result in no changes to the object code. The only change should be in libpthread.so's symbol table, where the {__,}vfork@@GLIBC_x.y symbols become just @GLIBC_x.y. It might be ideal to avoid the copy of the vfork code in libpthread, as I've done for other machines. That would need the __libc_vfork alias added to vfork.S and then either an assembly implementation of a tail call to the __libc_vfork PLT entry or testimony that a C tail call will definitely get compiled into a proper tail call. I'll leave that further cleanup to Kaz. Thanks, Roland 2014-05-29 Roland McGrath * nptl/sysdeps/unix/sysv/linux/sh/vfork.S: Moved ... * sysdeps/unix/sysv/linux/sh/vfork.S: ... here. * sysdeps/unix/sysv/linux/sh/pt-vfork.S: New file. * nptl/sysdeps/unix/sysv/linux/sh/pt-vfork.S: File removed. --- a/nptl/sysdeps/unix/sysv/linux/sh/pt-vfork.S +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 2003-2014 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 - . */ - -#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) - /* Save the PID value. */ - stc gbr, r2 - mov.w .L2, r0 - mov.l @(r0,r2), r4 - neg r4, r1 - 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 - -PSEUDO_END (__vfork) -libc_hidden_def (__vfork) - -weak_alias (__vfork, vfork) --- a/nptl/sysdeps/unix/sysv/linux/sh/vfork.S +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2004-2014 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 - . */ - -#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) - /* 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) -libc_hidden_def (__vfork) - -weak_alias (__vfork, vfork) --- /dev/null +++ b/sysdeps/unix/sysv/linux/sh/pt-vfork.S @@ -0,0 +1,28 @@ +/* libpthread ABI compatibility entry point for vfork. SH version. + Copyright (C) 2014 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 + . */ + +#include + +/* libpthread has its own copy of vfork only for ABI compatibility. */ + +#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_20) +# include + +compat_symbol (__vfork, __vfork, GLIBC_2_0) +compat_symbol (vfork, vfork, GLIBC_2_0) +#endif --- a/sysdeps/unix/sysv/linux/sh/vfork.S +++ b/sysdeps/unix/sysv/linux/sh/vfork.S @@ -1,4 +1,4 @@ -/* Copyright (C) 1999-2014 Free Software Foundation, Inc. +/* Copyright (C) 2004-2014 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 @@ -18,6 +18,7 @@ #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 @@ -25,45 +26,44 @@ and the process ID of the new process to the old process. */ ENTRY (__vfork) - -#ifdef __NR_vfork - mov.w .L3, r3 - trapa #0x10 - mov r0, r1 - mov #-12, r2 - shad r2, r1 - not r1, r1 // r1=0 means r0 = -1 to -4095 - tst r1, r1 // i.e. error in linux + /* 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.w .L1, r1 - cmp/eq r1, r0 - bt 2f - bra .Lsyscall_error - nop -.L1: - .word -ENOSYS -.L3: .word __NR_vfork + mov #1, r1 + rotr r1 1: - rts - nop -2: -#endif + mov.l r1, @(r0,r2) - /* If we don't have vfork, fork is close enough. */ - mov #+__NR_fork, r3 + 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 -.Lsyscall_error: SYSCALL_ERROR_HANDLER .Lpseudo_end: rts nop - +.L1: + .word __NR_vfork +.L2: + .word PID - TLS_PRE_TCB_SIZE + .align 2 PSEUDO_END (__vfork) libc_hidden_def (__vfork)