From patchwork Wed Nov 18 19:55:51 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: 1402511 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=DU42DoQF; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CbtsK6dk1z9s1l for ; Thu, 19 Nov 2020 06:58:13 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C1EAE3948A7B; Wed, 18 Nov 2020 19:56:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C1EAE3948A7B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605729400; bh=wj237K5xkWyeVO9NgelQhMq79ZEQQgQYob+9egZQy/M=; 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=DU42DoQFZuAGIxnLJXDTuA6dajYqTYAMAgU5v/MloOHeIoIFArAJl2tB8eKBLYfz0 Xrj351QlSxF75twDVr4Dp7slAhmf3lhsxuPNP43qEqKln3Xu1eDeWo9ZJspTilq4+O e+3qEVw9Z34nPmR6XZGvFR9cCKCC/Y9TkjYWkRLQ= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) by sourceware.org (Postfix) with ESMTPS id 07F3B394847E for ; Wed, 18 Nov 2020 19:56:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 07F3B394847E Received: by mail-qv1-xf31.google.com with SMTP id u23so1680673qvf.1 for ; Wed, 18 Nov 2020 11:56:37 -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=wj237K5xkWyeVO9NgelQhMq79ZEQQgQYob+9egZQy/M=; b=QiiGibrpZPmgJluuYElTVTe/B2D3BhsjOUkYeKSzj3BbI+B6Eb0a3J65ObSbHF7sA5 2q9N1AxzbYV/j4x/5LNTGgJv7enUkc2vLtyk7eM7VdaTX47OCsZtzpOglDItla+E+ePB 9QzzgVZ9Z6jE1WPKR7SOWcNaMSZSncj/Peyeqq6hvqN/8GEXghHqKux5rcJ6FCQrF9PL Pwr0Qs+VlwoobwLHrlQcj8368GqwG8aOZTJTID9pj0dHj8EcRv7/F6aMmzAMrDk5vsbD LVHQfB/2mDZ8e+/9ZPTfSGQbN/ykQzu48+4unJxkBMg3qASJUcxBN5ZeRSfGi2N0Evke Jl0Q== X-Gm-Message-State: AOAM5306U7qgLIVaFAXvMRNZMn0j5zQ20S7ZEQptPHNUA4ZEufKjhGC9 Iwzw3dSGtG2ROz7bgSNcF3GYqjTCFdm5mA== X-Google-Smtp-Source: ABdhPJygSMufUpo1ldX/v3K2oLoL2HBdp1bFjinAXh0FDpLn+A09WRhz6r3xQ6v+k2VanO5itbTR0w== X-Received: by 2002:a0c:aed2:: with SMTP id n18mr6571631qvd.4.1605729396002; Wed, 18 Nov 2020 11:56:36 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id f27sm6538775qtv.95.2020.11.18.11.56.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 11:56:35 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 27/28] linux: Add generic C syscall implementation Date: Wed, 18 Nov 2020 16:55:51 -0300 Message-Id: <20201118195552.2687336-28-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201118195552.2687336-1-adhemerval.zanella@linaro.org> References: <20201118195552.2687336-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 X-Spam-Status: No, score=-13.9 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 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 hppa and riscv one are also removed. The riscv specially is abusing the internal interfaces by defining it with a different signature. If the idea is to provide an optimized version a better alternative would be to provide an assembly one as other architectures. Checked on x86_64-linux-gnu and with build for the affected ABIs. --- sysdeps/unix/sysv/linux/hppa/syscall.c | 65 ------------------- sysdeps/unix/sysv/linux/{riscv => }/syscall.c | 33 ++++++---- 2 files changed, 20 insertions(+), 78 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/hppa/syscall.c rename sysdeps/unix/sysv/linux/{riscv => }/syscall.c (53%) diff --git a/sysdeps/unix/sysv/linux/hppa/syscall.c b/sysdeps/unix/sysv/linux/hppa/syscall.c deleted file mode 100644 index 7f6794b09f..0000000000 --- a/sysdeps/unix/sysv/linux/hppa/syscall.c +++ /dev/null @@ -1,65 +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 -#include -#include - -/* HPPA implements syscall() in 'C'; the assembler version would - typically be in syscall.S. Also note that we have INLINE_SYSCALL, - INTERNAL_SYSCALL, and all the generated pure assembly syscall wrappers. - How often the function is used is unknown. */ - -long int -syscall (long int __sysno, ...) -{ - /* FIXME: Keep this matching INLINE_SYSCALL for hppa */ - va_list args; - long int arg0, arg1, arg2, arg3, arg4, arg5; - long int __sys_res; - - /* Load varargs */ - va_start (args, __sysno); - arg0 = va_arg (args, long int); - arg1 = va_arg (args, long int); - arg2 = va_arg (args, long int); - arg3 = va_arg (args, long int); - arg4 = va_arg (args, long int); - arg5 = va_arg (args, long int); - va_end (args); - - { - LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5) - register unsigned long int __res asm("r28"); - PIC_REG_DEF - LOAD_REGS_6 - asm volatile (SAVE_ASM_PIC - " ble 0x100(%%sr2, %%r0) \n" - " copy %1, %%r20 \n" - LOAD_ASM_PIC - : "=r" (__res) - : "r" (__sysno) PIC_REG_USE ASM_ARGS_6 - : "memory", CALL_CLOB_REGS CLOB_ARGS_6); - __sys_res = __res; - } - if ((unsigned long int) __sys_res >= (unsigned long int) -4095) - { - __set_errno (-__sys_res); - __sys_res = -1; - } - return __sys_res; -} diff --git a/sysdeps/unix/sysv/linux/riscv/syscall.c b/sysdeps/unix/sysv/linux/syscall.c similarity index 53% rename from sysdeps/unix/sysv/linux/riscv/syscall.c rename to sysdeps/unix/sysv/linux/syscall.c index a99375c054..2e39ed9bc9 100644 --- a/sysdeps/unix/sysv/linux/riscv/syscall.c +++ b/sysdeps/unix/sysv/linux/syscall.c @@ -1,5 +1,5 @@ -/* system call interface. Linux/RISC-V version. - Copyright (C) 2001-2020 Free Software Foundation, Inc. +/* Indirect system call. Linux 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 @@ -16,19 +16,26 @@ License along with the GNU C Library. If not, see . */ +#include #include long int -syscall (long int syscall_number, long int arg1, long int arg2, long int arg3, - long int arg4, long int arg5, long int arg6, long int arg7) +syscall (long int number, ...) { - long int ret; - - ret = INTERNAL_SYSCALL_NCS (syscall_number, 7, arg1, arg2, arg3, arg4, - arg5, arg6, arg7); - - if (INTERNAL_SYSCALL_ERROR_P (ret)) - return __syscall_error (ret); - - return ret; + va_list args; + + va_start (args, number); + long int arg0 = va_arg (args, long int); + long int arg1 = va_arg (args, long int); + long int arg2 = va_arg (args, long int); + long int arg3 = va_arg (args, long int); + long int arg4 = va_arg (args, long int); + long int arg5 = va_arg (args, long int); + va_end (args); + + long int ret = INTERNAL_SYSCALL_NCS (number, 6, arg0, arg1, arg2, + arg3, arg4, arg5); + return INTERNAL_SYSCALL_ERROR_P (ret) + ? SYSCALL_ERROR_LABEL (INTERNAL_SYSCALL_ERRNO (ret)) + : ret; }