From patchwork Wed Nov 18 14:47:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Castanho X-Patchwork-Id: 41094 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AB49F39874FC; Wed, 18 Nov 2020 14:47:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB49F39874FC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605710831; bh=3st6HbTKdUkliTCQVyX/XzGOzFYkGMUvMSzDU/NIRbc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=IGLuT/nm+WaRuirs4urr/5eB5saV/3HzaCdKX8OQRtFvwguj2Tn1az6OJPVj987JC fDAPVS+JLjXpubGQDm2QA+z45uMO7tvzTQnvou4qLCyeA1PqkMU61uU3VS/JFjhnIn jWiUvV9iQ4LMUp43hda5yylhQisSGzYsNKBBqKUo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 85FBE39874DC for ; Wed, 18 Nov 2020 14:47:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 85FBE39874DC Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AIEVi9Z017348 for ; Wed, 18 Nov 2020 09:47:09 -0500 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 34w2tuxmfv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 Nov 2020 09:47:09 -0500 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 0AIEcN1r016471 for ; Wed, 18 Nov 2020 14:47:08 GMT Received: from b01cxnp22033.gho.pok.ibm.com (b01cxnp22033.gho.pok.ibm.com [9.57.198.23]) by ppma04wdc.us.ibm.com with ESMTP id 34t6v96w7g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 18 Nov 2020 14:47:08 +0000 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 0AIEl7XP61211026 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 18 Nov 2020 14:47:07 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BC65AAC05F; Wed, 18 Nov 2020 14:47:07 +0000 (GMT) Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3B14AAC05B; Wed, 18 Nov 2020 14:47:07 +0000 (GMT) Received: from localhost (unknown [9.160.22.117]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 18 Nov 2020 14:47:07 +0000 (GMT) To: libc-alpha@sourceware.org Subject: [PATCH 1/4] powerpc: Replace brk.S with a C implementation Date: Wed, 18 Nov 2020 11:47:00 -0300 Message-Id: <20201118144703.75569-2-msc@linux.ibm.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201118144703.75569-1-msc@linux.ibm.com> References: <20201118144703.75569-1-msc@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312, 18.0.737 definitions=2020-11-18_04:2020-11-17, 2020-11-18 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 suspectscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 malwarescore=0 spamscore=0 phishscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2011180100 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Matheus Castanho via Libc-alpha From: Matheus Castanho Reply-To: Matheus Castanho Cc: tuliom@linux.ibm.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" From: Tulio Magno Quites Machado Filho There is no need to maintain a separate assembly implementation of brk for powerpc. It basically does the same thing as the generic C-based version, so we can reuse that instead. --- .../linux/powerpc/{powerpc64/brk.S => brk.c} | 41 +++++++-------- sysdeps/unix/sysv/linux/powerpc/dl-brk.S | 1 - .../unix/sysv/linux/powerpc/powerpc32/brk.S | 52 ------------------- 3 files changed, 18 insertions(+), 76 deletions(-) rename sysdeps/unix/sysv/linux/powerpc/{powerpc64/brk.S => brk.c} (58%) delete mode 100644 sysdeps/unix/sysv/linux/powerpc/dl-brk.S delete mode 100644 sysdeps/unix/sysv/linux/powerpc/powerpc32/brk.S diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/brk.S b/sysdeps/unix/sysv/linux/powerpc/brk.c similarity index 58% rename from sysdeps/unix/sysv/linux/powerpc/powerpc64/brk.S rename to sysdeps/unix/sysv/linux/powerpc/brk.c index f206909b72..af7d1d73a2 100644 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/brk.S +++ b/sysdeps/unix/sysv/linux/powerpc/brk.c @@ -1,6 +1,6 @@ -/* brk system call for Linux. PowerPC64 version. - Copyright (C) 1995-2020 Free Software Foundation, Inc. +/* Copyright (C) 2020 Free Software Foundation, Inc. This file is part of the GNU C Library. + Contributed by Chris Metcalf , 2011. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -13,31 +13,26 @@ 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 + License along with the GNU C Library. If not, see . */ +#include +#include #include -#define _ERRNO_H 1 -#include - .comm __curbrk,8,8 - .section ".toc","aw" -.LC__curbrk: - .tc __curbrk[TC],__curbrk - .section ".text" -ENTRY (__brk) - CALL_MCOUNT 1 +/* This must be initialized data because commons can't have aliases. */ +void *__curbrk = 0; - std r3,-8(r1) - DO_CALL(SYS_ify(brk)) - ld r6,-8(r1) - ld r5,.LC__curbrk@toc(r2) - std r3,0(r5) - cmpld r6,r3 - li r3,0 - blelr+ - li r3,ENOMEM - TAIL_CALL_SYSCALL_ERROR -END (__brk) +int +__brk (void *addr) +{ + __curbrk = (void *) INTERNAL_SYSCALL_CALL (brk, addr); + if (__curbrk < addr) + { + __set_errno (ENOMEM); + return -1; + } + return 0; +} weak_alias (__brk, brk) diff --git a/sysdeps/unix/sysv/linux/powerpc/dl-brk.S b/sysdeps/unix/sysv/linux/powerpc/dl-brk.S deleted file mode 100644 index eeb96544e3..0000000000 --- a/sysdeps/unix/sysv/linux/powerpc/dl-brk.S +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/brk.S b/sysdeps/unix/sysv/linux/powerpc/powerpc32/brk.S deleted file mode 100644 index f3b960795e..0000000000 --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/brk.S +++ /dev/null @@ -1,52 +0,0 @@ -/* brk system call for Linux/ppc. - Copyright (C) 1995-2020 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 - - .comm __curbrk,4,4 - .section ".text" -ENTRY (__brk) - mflr r0 - stwu r1,-16(r1) - cfi_adjust_cfa_offset (16) - stw r3,8(r1) - stw r0,20(r1) - cfi_offset (lr, 4) - DO_CALL(SYS_ify(brk)) - lwz r6,8(r1) -#ifdef PIC - SETUP_GOT_ACCESS(r5,got_label) - addis r5,r5,__curbrk-got_label@ha - stw r3,__curbrk-got_label@l(r5) -#else - lis r4,__curbrk@ha - stw r3,__curbrk@l(r4) -#endif - lwz r0,20(r1) - cmplw r6,r3 - addi r1,r1,16 - mtlr r0 - li r3,0 - blelr+ - li r3,ENOMEM - b __syscall_error@local -END (__brk) - -weak_alias (__brk, brk)