From patchwork Fri Nov 13 16:58: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: 41057 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 DCF803945C15; Fri, 13 Nov 2020 16:59:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DCF803945C15 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605286744; bh=03XM0kntEgYMQVgp2KLRo/PXVJ0qwwAnY5HCvjwT11E=; 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=mb3joNfP/ts2kuq2TDjA6APh6UOBYjhsQ6vciSXdafO9fYPnYKdd628fSYCVTIBUy t0/nNdfOPXCYapy+i6kQALFvcURGR/L4X1ZG5AyLRIRm7bzvdopipqy8nWLJ/3nvCs U6GDbprhAZmmCTVzVU+ZANHbUya/Ow+ap6CzYdTQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf42.google.com (mail-qv1-xf42.google.com [IPv6:2607:f8b0:4864:20::f42]) by sourceware.org (Postfix) with ESMTPS id 582DF39450C2 for ; Fri, 13 Nov 2020 16:59:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 582DF39450C2 Received: by mail-qv1-xf42.google.com with SMTP id a15so2747147qvk.5 for ; Fri, 13 Nov 2020 08:59:01 -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=03XM0kntEgYMQVgp2KLRo/PXVJ0qwwAnY5HCvjwT11E=; b=hNvQWMjwhDz10oGwLVH8bz/HMmxiFPzIz/hWZ7OmunHxctlZOi6G26B5hUDscq/JFi UmceBvZhDy1kiuD17gPQGZmSm5jOkpASIj4zQuDKqbCNtdYxCxV2++eHKb6tTLU2Oj0V Z4kXpD8D34iWNIDWng+kDcNsrU7m0IfY0xFLqayeVZ84t23kN6ACZ1HglIn+kqepwvpK awQvG6RouTFUdW5q8mlbmyE/vxu+lwT2QUqXLkY7Ezq57I+7EgwSw7VMHRk+ete/Ixbk pPIGl05vjNvAptrlvAcmYuqGD6ubt1IK9MvsKH9oGsisAz5b0INkU2nXHnwgrXO6dbS1 jXTg== X-Gm-Message-State: AOAM531+kHj68YDUI3k0FDBRSA/cVmkWj7OMrdGBlvUq877milNqMUNz ghbWl2zMyIgIWM2KXvODJRNrIf8HUdsPRw== X-Google-Smtp-Source: ABdhPJx8/1Aw3h2VrSQdyX8fAcg/4lXoTpq2A1uonX2CsvAFjzyNW9X56JxPEcxpEB89jsih4wxwtw== X-Received: by 2002:a05:6214:2e1:: with SMTP id h1mr3220580qvu.60.1605286735659; Fri, 13 Nov 2020 08:58:55 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id s16sm7363931qkg.5.2020.11.13.08.58.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:58:55 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH v2 09/23] linux: Use generic __syscall_error for sparc Date: Fri, 13 Nov 2020 13:58:23 -0300 Message-Id: <20201113165837.121629-10-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 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 + sysdeps/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 + sysdeps/unix/sysv/linux/sparc/sparc64/sysdep.h | 1 + sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S | 1 + .../linux/sparc/{sysdep.c => syscall_error.h} | 18 ++++++++---------- 11 files changed, 18 insertions(+), 18 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/sparc/rt-sysdep.c rename sysdeps/unix/sysv/linux/sparc/{sysdep.c => syscall_error.h} (74%) 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/syscall_error.h similarity index 74% rename from sysdeps/unix/sysv/linux/sparc/sysdep.c rename to sysdeps/unix/sysv/linux/sparc/syscall_error.h index 1bf5ea6f62..6a9fac278a 100644 --- a/sysdeps/unix/sysv/linux/sparc/sysdep.c +++ b/sysdeps/unix/sysv/linux/sparc/syscall_error.h @@ -1,4 +1,5 @@ -/* Copyright (C) 1997-2020 Free Software Foundation, Inc. +/* Linux wrappers for setting errno. SPARC 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 @@ -15,13 +16,10 @@ License along with the GNU C Library; if not, see . */ -#include +#ifndef _SYSCALL_ERROR_H +#define _SYSCALL_ERROR_H -/* 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; -} +#define SYSCALL_ERROR_FUNC 1 +#define SYSCALL_ERROR_FUNC_ATTR + +#endif