From patchwork Fri Nov 13 16:58:33 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: 41067 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 B939F3947407; Fri, 13 Nov 2020 16:59:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B939F3947407 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286758; bh=wz2LksJaPC29verM8T1VCdm1oYhxwR1PY+U+GXZsyxE=; 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=uoHqobzUTup5eZEFZK4FLJbRC+7nt++VWAAfwUo1D7eE0vcR/WRovERy7/itdlplc 1q+8361y3Tl543Rd3OQ91v7lZB8nB1EcHjw7LoxWDWvbMIyU97x1+mWMPV/NnbWXil zyhg7EkbbCEVl3XurBK8zItMAdjimqqBuvyt6gGM= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by sourceware.org (Postfix) with ESMTPS id 0383639450F2 for ; Fri, 13 Nov 2020 16:59:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 0383639450F2 Received: by mail-qk1-x744.google.com with SMTP id v143so9427568qkb.2 for ; Fri, 13 Nov 2020 08:59:15 -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=wz2LksJaPC29verM8T1VCdm1oYhxwR1PY+U+GXZsyxE=; b=QZEehx3dn96Zwii/x5JFkiFTe0aDrXMN09E1i4Fuu8YulL9+D4Pgafary3FuZFX6Zz pkIAow06vrXs2/M25KYKP0sGZ70pt6XerHwWe+q0HDdzCs85+T7FJa5Fg7IhCpcTomU2 5EvMnfyskhRWD6eEGapUi6l1vkvD8Bl0BVCoRLROtV8+0eWcXNdsiczjS2dwcsebc55r n7FdFBJghIKcrUWDmj3A/I3KBF9A60d//m88djYi3bk8wNklJo5zrA2ZLdoae3iuqdkq QWUX1Eafldfd8v9OOsPcwILSTuPCsE283Kvfh7MEdW+dLWUkATIn9dN+qLjNCsZZDkuM K0Dw== X-Gm-Message-State: AOAM533W0weF6jMBaIEgcmLXbAGBTF7bcMjgpSKAHhG4Hu1ca2xks1I8 h0Himz7udIqmgAFe3MX4sGQ0HYh2uXLfuw== X-Google-Smtp-Source: ABdhPJwdjlgAdxzMLoMLU8P0lPdvA5vrWKfW/u0p3Nfw2mEhJnG57AaCLskCvpPoq8617SNVhlXCRw== X-Received: by 2002:a37:2cc2:: with SMTP id s185mr2907016qkh.118.1605286749425; Fri, 13 Nov 2020 08:59:09 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.59.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:59:08 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 19/23] linux: Use generic __syscall_error for riscv Date: Fri, 13 Nov 2020 13:58:33 -0300 Message-Id: <20201113165837.121629-20-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201113165837.121629-1-adhemerval.zanella@linaro.org> References: <20201113165837.121629-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/syscall_error.h | 25 +++++++++ sysdeps/unix/sysv/linux/riscv/sysdep.S | 51 ------------------- 4 files changed, 25 insertions(+), 58 deletions(-) delete mode 100644 sysdeps/riscv/nptl/nptl-sysdep.S create mode 100644 sysdeps/unix/sysv/linux/riscv/syscall_error.h 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/syscall_error.h b/sysdeps/unix/sysv/linux/riscv/syscall_error.h new file mode 100644 index 0000000000..932f34aa0f --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/syscall_error.h @@ -0,0 +1,25 @@ +/* Linux wrappers for setting errno. RISCV version. + Copyright (C) 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 + . */ + +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H + +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR + +#endif 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)