From patchwork Mon Nov 9 20:18:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 41000 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 9E22A39730CA; Mon, 9 Nov 2020 20:19:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9E22A39730CA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953146; bh=32cHR3K9rnmigI3ULicjauqIkNzMCoSegfmHevR4GLY=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=RCVMvlVmg68fmC/PGu6NHE5I1UxDZG9tENy1+zg1rTg4fRoqFPKfGldSLZR8v+6qW n4XMD2hwFFJDJBPMFegcckUbWxrkO513dUbCPoFbiy4CmpqTh7NuVoPArL02lbj0sF i5j/lXtsr8e/VkKil0YYkUlcfedxV7Gbh/ZIpNMk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by sourceware.org (Postfix) with ESMTPS id 43E5439730A9 for ; Mon, 9 Nov 2020 20:19:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 43E5439730A9 Received: by mail-qt1-x841.google.com with SMTP id 7so2589372qtp.1 for ; Mon, 09 Nov 2020 12:19:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=32cHR3K9rnmigI3ULicjauqIkNzMCoSegfmHevR4GLY=; b=k2S9rkPo2ch3UUjuG1NLcUSrIUy9KqjM0MgDT/dQgcgnFNd5XbbihwmProAxy3yABr tsmtoAxo42+xCJXGuDEnIeFEXxhGf9uIlHhu+Uw/VBz/ot7pexDc2juYDXLfvoALf6dH BEil887StblZCgg/HvR+/Uyt4EcUSTu6xmpxtQrm9Uf7YE9uDlKOk1Y+3pT/cuXZnas5 tkIrr0xPZkQ/bivUqHLwZ6ZDJfNZv/8Jqca98M1Jaeh1piK1FYTtS8U1MubI2Ko/OkQj jtJ+MBeAH2UF3Vwe2rOLyW/FT6wY7Yc/gEmZnwVMt2QrAtsFDTd5naKqPW1i98xpwFFY wtzw== X-Gm-Message-State: AOAM532DzjAPGP698xBtSdfJW81CZdJFsQwVJ4iieYwDJ0e7pseqnxQd Alb7mX73dDFqDLJDReMwNL7GmeSiVQ9gxA== X-Google-Smtp-Source: ABdhPJypoLMZGHbm7LHoU3JIr275JvG//L7RtUGMlIC78RErfvSrlyaoVgZFHPAIl1H0IskrUx1WBQ== X-Received: by 2002:aed:32c4:: with SMTP id z62mr3414978qtd.50.1604953143529; Mon, 09 Nov 2020 12:19:03 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.19.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:19:03 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 20/23] linux: Use generic __syscall_error for riscv Date: Mon, 9 Nov 2020 17:18:23 -0300 Message-Id: <20201109201826.120534-21-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201109201826.120534-1-adhemerval.zanella@linaro.org> References: <20201109201826.120534-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK 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: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The outline __syscall_error already generate the most compact code for riscv64 and riscv32: --- sizes-riscv32-linux-gnu-rv32imafdc-ilp32d.outline +++ sizes-riscv32-linux-gnu-rv32imafdc-ilp32d.inline text data bss dec hex filename - 973220 9460 8840 991520 f2120 libc.so - 98209 4124 176 102509 1906d elf/ld.so - 71063 800 8348 80211 13953 nptl/libpthread.so - 17011 608 168 17787 457b rt/librt.so + 974466 9460 8840 992766 f25fe libc.so + 98331 4124 176 102631 190e7 elf/ld.so + 70939 800 8348 80087 138d7 nptl/libpthread.so + 17095 608 168 17871 45cf rt/librt.so --- sizes-riscv64-linux-gnu-rv64imafdc-lp64d.outline +++ sizes-riscv64-linux-gnu-rv64imafdc-lp64d.inline text data bss dec hex filename -1030902 18632 14472 1064006 103c46 libc.so - 98320 6232 336 104888 199b8 elf/ld.so - 76588 1596 16664 94848 17280 nptl/libpthread.so - 18016 1156 232 19404 4bcc rt/librt.so +1031680 18632 14472 1064784 103f50 libc.so + 98374 6232 336 104942 199ee elf/ld.so + 76544 1596 16664 94804 17254 nptl/libpthread.so + 18106 1156 232 19494 4c26 rt/librt.so Checked with some basic tests to see if errno is set correctly on both static and dynamic binaries with auto-generated syscals and C implementation (which uses INTERNAL_SYSCALL_CALL). --- sysdeps/riscv/nptl/Makefile | 5 --- sysdeps/riscv/nptl/nptl-sysdep.S | 2 - sysdeps/unix/sysv/linux/riscv/sysdep.S | 51 -------------------------- sysdeps/unix/sysv/linux/riscv/sysdep.h | 2 + 4 files changed, 2 insertions(+), 58 deletions(-) delete mode 100644 sysdeps/riscv/nptl/nptl-sysdep.S delete mode 100644 sysdeps/unix/sysv/linux/riscv/sysdep.S diff --git a/sysdeps/riscv/nptl/Makefile b/sysdeps/riscv/nptl/Makefile index 1af6fa6a55..3f6428b0de 100644 --- a/sysdeps/riscv/nptl/Makefile +++ b/sysdeps/riscv/nptl/Makefile @@ -19,8 +19,3 @@ ifeq ($(subdir),csu) gen-as-const-headers += tcb-offsets.sym endif - -ifeq ($(subdir),nptl) -libpthread-sysdep_routines += nptl-sysdep -libpthread-shared-only-routines += nptl-sysdep -endif diff --git a/sysdeps/riscv/nptl/nptl-sysdep.S b/sysdeps/riscv/nptl/nptl-sysdep.S deleted file mode 100644 index 3f5c2a364a..0000000000 --- a/sysdeps/riscv/nptl/nptl-sysdep.S +++ /dev/null @@ -1,2 +0,0 @@ -/* Pull in __syscall_error. */ -#include diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.S b/sysdeps/unix/sysv/linux/riscv/sysdep.S deleted file mode 100644 index 64daa84aac..0000000000 --- a/sysdeps/unix/sysv/linux/riscv/sysdep.S +++ /dev/null @@ -1,51 +0,0 @@ -/* syscall error handlers - Copyright (C) 2011-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 - -#if IS_IN (libc) -# define errno __libc_errno -#endif - -ENTRY (__syscall_error) - mv t0, ra - /* Fall through to __syscall_set_errno. */ -END (__syscall_error) - -/* Non-standard calling convention: argument in a0, return address in t0, - and clobber only t1. */ -ENTRY (__syscall_set_errno) - /* We got here because a0 < 0, but only codes in the range [-4095, -1] - represent errors. Otherwise, just return the result normally. */ - li t1, -4096 - bleu a0, t1, 1f - neg a0, a0 -#if RTLD_PRIVATE_ERRNO - sw a0, rtld_errno, t1 -#elif defined(__PIC__) - la.tls.ie t1, errno - add t1, t1, tp - sw a0, 0(t1) -#else - lui t1, %tprel_hi(errno) - add t1, t1, tp, %tprel_add(errno) - sw a0, %tprel_lo(errno)(t1) -#endif - li a0, -1 -1: jr t0 -END (__syscall_set_errno) diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h index e94afbf106..1bcd942e31 100644 --- a/sysdeps/unix/sysv/linux/riscv/sysdep.h +++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h @@ -19,6 +19,8 @@ #ifndef _LINUX_RISCV_SYSDEP_H #define _LINUX_RISCV_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + #include #include