From patchwork Mon Nov 9 20:18:13 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: 40990 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 0AB3539724AB; Mon, 9 Nov 2020 20:18:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0AB3539724AB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1604953134; bh=LtQgCurgM+1eGCaad+41dQ3com5lMz12+k1UcydOYB8=; 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=Lj8sNU2YsmekNk87LCcSZR61kPwGvZ2L9oTGg5n2OJ6Q+l8ygUH6ElNuLnpGF4gY/ drl6MlObnAoEePLnCmF5Q0vek4UidaFAVVKGarcpUy945y3rrgNV9QqSrk0wv8Zhod tWWdSAUv852+/3WtmOUkeObhIYYYl/2utfN+tpQA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by sourceware.org (Postfix) with ESMTPS id ACCEE397300F for ; Mon, 9 Nov 2020 20:18:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org ACCEE397300F Received: by mail-qt1-x843.google.com with SMTP id 7so2588806qtp.1 for ; Mon, 09 Nov 2020 12:18:50 -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=LtQgCurgM+1eGCaad+41dQ3com5lMz12+k1UcydOYB8=; b=TiAiONU5XDzFBOId8cL6VGj02qoPaPzKZyaXQtTs6zWQy6olO0GCKK+EwonSTHoygA bYsKen5xF61IgVQFbC3oZoHLYY9fyQR54fzrS54LDGucncB65w46BT55t/pSDGG64QZF ENIiYfmIyWsp69tQmu9O1Ffs8Hl620WMgMJxTY7BbpAjlHLX8WJ/vjFtvcrJa1MaZfcC fOmOtmMgASV8vjDuOOKPvx6sPZ7zPZFo/MF4Hi74eP0kuiE22rWzX3hHNkZGHHpS2VdV IQJqy95ZLdNQwrtfCBI+dGbuL84w+2tweAIHESfxZhE10HqptcUJAU7JmTsd1TF4INIV xs+A== X-Gm-Message-State: AOAM53160NUm3OIo4W7aAG/Y+uMQnVfL5XL1ZaCRQ71yKtdupo5ogGVb s3URNkmqOsooJlTBohGE7IHHaMKJNU+EHQ== X-Google-Smtp-Source: ABdhPJxnnEhLgwxFJUfAka+7F0QosZqfAhBDapx5ZctU7eIU/x8T0vrCheo307cd1efEUAALTuU20Q== X-Received: by 2002:aed:3147:: with SMTP id 65mr15281199qtg.295.1604953129814; Mon, 09 Nov 2020 12:18:49 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id z2sm6843407qkl.22.2020.11.09.12.18.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Nov 2020 12:18:49 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 10/23] linux: Use generic __syscall_error for sparc Date: Mon, 9 Nov 2020 17:18:13 -0300 Message-Id: <20201109201826.120534-11-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 sparc kABI returns a positive errno value in 'o0' register for failure case (the syscall error is signal on conditional register), different than usual Linux kABI with return a negative value in range of [-4096,0). The __syscall_error thus has a different ABI than the generic one, which requires fixing both the inline syscall wrappers and some assembly implementation that calls __syscall_error directly. Using inline function for __syscall_error does not yield any gain: --- sizes-sparc64-linux-gnu.outline +++ sizes-sparc64-linux-gnu.inline text data bss dec hex filename -1469609 20464 14496 1504569 16f539 libc.so - 152853 6960 352 160165 271a5 elf/ld.so - 101586 1220 16672 119478 1d2b6 nptl/libpthread.so - 27282 836 2296 30414 76ce rt/librt.so +1473545 20464 14496 1508505 170499 libc.so + 153077 6960 352 160389 27285 elf/ld.so + 102578 1220 16672 120470 1d696 nptl/libpthread.so + 27474 836 2296 30606 778e rt/librt.so --- sizes-sparcv9-linux-gnu.outline +++ sizes-sparcv9-linux-gnu.inline text data bss dec hex filename -1557171 11208 9440 1577819 18135b libc.so - 149507 4448 192 154147 25a23 elf/ld.so - 101518 588 8356 110462 1af7e nptl/libpthread.so - 26546 404 160 27110 69e6 rt/librt.so +1563315 11208 9440 1583963 182b5b libc.so + 149795 4448 192 154435 25b43 elf/ld.so + 102286 588 8356 111230 1b27e nptl/libpthread.so + 26930 404 160 27494 6b66 rt/librt.so Checked on sparc64-linux-gnu and sparcv9-linux-gnu. --- sysdeps/unix/sysv/linux/sparc/Makefile | 9 ++----- sysdeps/unix/sysv/linux/sparc/rt-sysdep.c | 1 - sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S | 1 + .../unix/sysv/linux/sparc/sparc32/syscall.S | 1 + .../unix/sysv/linux/sparc/sparc32/sysdep.h | 1 + sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S | 1 + sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S | 1 + .../unix/sysv/linux/sparc/sparc64/syscall.S | 1 + .../unix/sysv/linux/sparc/sparc64/sysdep.h | 1 + sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S | 1 + sysdeps/unix/sysv/linux/sparc/sysdep.c | 27 ------------------- sysdeps/unix/sysv/linux/sparc/sysdep.h | 2 ++ 12 files changed, 12 insertions(+), 35 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/sparc/rt-sysdep.c delete mode 100644 sysdeps/unix/sysv/linux/sparc/sysdep.c diff --git a/sysdeps/unix/sysv/linux/sparc/Makefile b/sysdeps/unix/sysv/linux/sparc/Makefile index 1475039677..3a47cd2da4 100644 --- a/sysdeps/unix/sysv/linux/sparc/Makefile +++ b/sysdeps/unix/sysv/linux/sparc/Makefile @@ -2,11 +2,6 @@ abi-variants := 32 64 abi-32-condition := __WORDSIZE == 32 abi-64-condition := __WORDSIZE == 64 -ifeq ($(subdir),rt) -librt-routines += rt-sysdep -librt-shared-only-routines += rt-sysdep -endif - ifeq ($(subdir),sysvipc) sysdep_routines += getshmlba endif @@ -17,6 +12,6 @@ endif ifeq ($(subdir),nptl) # pull in __syscall_error routine -libpthread-routines += sysdep sigreturn_stub -libpthread-shared-only-routines += sysdep sigreturn_stub +libpthread-routines += sigreturn_stub +libpthread-shared-only-routines += sigreturn_stub endif diff --git a/sysdeps/unix/sysv/linux/sparc/rt-sysdep.c b/sysdeps/unix/sysv/linux/sparc/rt-sysdep.c deleted file mode 100644 index 3ff55952e2..0000000000 --- a/sysdeps/unix/sysv/linux/sparc/rt-sysdep.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S b/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S index 0b10f1522b..d693527e7b 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/pipe.S @@ -26,6 +26,7 @@ ENTRY(__libc_pipe) ta 0x10 bcc 1f mov %o7, %g1 + neg %o0, %o0 call __syscall_error mov %g1, %o7 1: st %o0, [%o2] /* PIPEDES[0] = %o0; */ diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S b/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S index 90c639f043..a2b608179a 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/syscall.S @@ -30,6 +30,7 @@ ENTRY(syscall) ta 0x10 bcc 1f mov %o7, %g1 + neg %o0, %o0 call __syscall_error mov %g1, %o7 1: retl diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h index 2c3754770b..3e7671c391 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/sysdep.h @@ -65,6 +65,7 @@ ENTRY(name); \ #ifndef PIC # define SYSCALL_ERROR_HANDLER \ mov %o7, %g1; \ + neg %o0, %o0; \ call __syscall_error; \ mov %g1, %o7; #else diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S b/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S index be48386016..c8d26a49a7 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S @@ -26,6 +26,7 @@ ENTRY(__libc_vfork) ta 0x10 bcc 2f mov %o7, %g1 + neg %o0, %o0 call __syscall_error mov %g1, %o7 2: sub %o1, 1, %o1 diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S b/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S index 072a1936ea..ba75629261 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/pipe.S @@ -27,6 +27,7 @@ ENTRY(__libc_pipe) ta 0x6d bcc,pt %xcc, 1f mov %o7, %g1 + neg %o0, %o0 call __syscall_error mov %g1, %o7 1: st %o0, [%o2] /* PIPEDES[0] = %o0; */ diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S b/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S index fca114371f..63a28f65ee 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/syscall.S @@ -32,6 +32,7 @@ ENTRY(syscall) bcc,pt %xcc, 1f mov %o7, %g1 + neg %o0, %o0 call __syscall_error mov %g1, %o7 1: retl diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h index 2010faf50f..329ec144cf 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h @@ -65,6 +65,7 @@ ENTRY(name); \ #ifndef PIC # define SYSCALL_ERROR_HANDLER \ mov %o7, %g1; \ + neg %o0, %o0; \ call __syscall_error; \ mov %g1, %o7; #else diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S b/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S index 56a491f3de..0a34a3e68c 100644 --- a/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S +++ b/sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S @@ -26,6 +26,7 @@ ENTRY(__libc_vfork) ta 0x6d bcc,pt %xcc, 2f mov %o7, %g1 + neg %o0, %o0 call __syscall_error mov %g1, %o7 2: sub %o1, 1, %o1 diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.c b/sysdeps/unix/sysv/linux/sparc/sysdep.c deleted file mode 100644 index 1bf5ea6f62..0000000000 --- a/sysdeps/unix/sysv/linux/sparc/sysdep.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 1997-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 - -/* This routine is jumped to by all the syscall handlers, to stash - an error number into errno. */ -int -__syscall_error (int err_no) -{ - __set_errno (err_no); - return -1; -} diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h index aec4326cc9..8970ecc1ae 100644 --- a/sysdeps/unix/sysv/linux/sparc/sysdep.h +++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h @@ -19,6 +19,8 @@ #ifndef _LINUX_SPARC_SYSDEP_H #define _LINUX_SPARC_SYSDEP_H 1 +#define SYSCALL_ERROR_FUNC + #include #include #include