From patchwork Wed Nov 18 19:55:52 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: 41127 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 D8331394B01F; Wed, 18 Nov 2020 19:56:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D8331394B01F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1605729402; bh=qf6kb9Hw2TbDJsoU56DF7i9oYonfRTGY0GBJXK7Y1Uc=; 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=d4Q8IAPSttwFpdRJjNWk4UBZWPUTQP3Wy2LpDmI3Amji8FrtexfmmHCSZjK7KG2g3 ueHtmZZJ6NT8gUAfi86LMgJThazO5JeFUucaZwEyYXs68F4osUv9qYp4rjiaiSFaU+ tGLHrGaTZOiXuFe6vnHRXO6E5w37Y/XiVHbL/MQc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by sourceware.org (Postfix) with ESMTPS id 942F03948A7B for ; Wed, 18 Nov 2020 19:56:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 942F03948A7B Received: by mail-qv1-xf34.google.com with SMTP id ec16so1694098qvb.0 for ; Wed, 18 Nov 2020 11:56:38 -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=qf6kb9Hw2TbDJsoU56DF7i9oYonfRTGY0GBJXK7Y1Uc=; b=GWkqMDybjSiRz1q4iSA4PmkJzL4O6Sn/loTNR0wXFbAYQvzFy0pOZxM9HDuW2V3AEi rrN6ygPZjxqRoAWz1ghwHlGiHGQfbuHAPa+6L/XVLc89vBv4HWnDbOYwdJBVdfjTTGHF fugwhFY4g1I+vaxQN4G7UOlDIiWK6N86HfDFjULgRJCfJaozUGIij2qFATySJR5tOiLy E61Zq3g0esdjg4QhHQT+svKlTnJ6BdJCSBiXq4GlJzGBC1MNjYabm5fWQCgSKHlDEGIp TldtJh7Ij7Lyj07hhS/3awfcLaAH8oGq+XoWGeaqNxpYgirCZuf809GpMPRgMAUcikAF kStQ== X-Gm-Message-State: AOAM532oQIM0iFSZByg12RmSeohmn7o0vY1OOqkldFqJaZ8tJxxyI9/n yyDrRx7Uy9BGWYLz/jUBRyXA8Hg2KkvUNA== X-Google-Smtp-Source: ABdhPJyMEnTUvKW6J/g7aImgglNixl3pOctiuc1r/DKfraBmn3SCZZyjqO9MOFY5IKvUCnPshSK0Og== X-Received: by 2002:a0c:bda2:: with SMTP id n34mr6463369qvg.28.1605729397654; Wed, 18 Nov 2020 11:56:37 -0800 (PST) Received: from localhost.localdomain ([177.194.48.209]) by smtp.googlemail.com with ESMTPSA id f27sm6538775qtv.95.2020.11.18.11.56.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Nov 2020 11:56:37 -0800 (PST) To: libc-alpha@sourceware.org Subject: [PATCH 28/28] alpha: Move implementations to C Date: Wed, 18 Nov 2020 16:55:52 -0300 Message-Id: <20201118195552.2687336-29-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" Move alpha specific the feraiseexcept, getegid, geteuid, getppid, eee_get_fp_control, ieee_set_fp_control, and setcontext to C implementations. Checked on alpha-linux-gnu. --- .../alpha/{fraiseexcpt.S => fraiseexcpt.c} | 37 ++++------------ .../sysv/linux/alpha/{getegid.S => getegid.c} | 15 ++++--- .../sysv/linux/alpha/{geteuid.S => geteuid.c} | 15 ++++--- .../sysv/linux/alpha/{getppid.S => getppid.c} | 15 ++++--- ...get_fp_control.S => ieee_get_fp_control.c} | 43 ++++++------------- ...set_fp_control.S => ieee_set_fp_control.c} | 35 ++++----------- .../alpha/{setcontext.S => setcontext.c} | 27 ++++++------ sysdeps/unix/sysv/linux/alpha/sysdep.h | 21 +++++++++ 8 files changed, 87 insertions(+), 121 deletions(-) rename sysdeps/unix/sysv/linux/alpha/{fraiseexcpt.S => fraiseexcpt.c} (66%) rename sysdeps/unix/sysv/linux/alpha/{getegid.S => getegid.c} (79%) rename sysdeps/unix/sysv/linux/alpha/{geteuid.S => geteuid.c} (79%) rename sysdeps/unix/sysv/linux/alpha/{getppid.S => getppid.c} (79%) rename sysdeps/unix/sysv/linux/alpha/{ieee_get_fp_control.S => ieee_get_fp_control.c} (61%) rename sysdeps/unix/sysv/linux/alpha/{ieee_set_fp_control.S => ieee_set_fp_control.c} (62%) rename sysdeps/unix/sysv/linux/alpha/{setcontext.S => setcontext.c} (62%) diff --git a/sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S b/sysdeps/unix/sysv/linux/alpha/fraiseexcpt.c similarity index 66% rename from sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S rename to sysdeps/unix/sysv/linux/alpha/fraiseexcpt.c index 8c4b933749..903eaebb66 100644 --- a/sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S +++ b/sysdeps/unix/sysv/linux/alpha/fraiseexcpt.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2004-2020 Free Software Foundation, Inc. +/* 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,37 +15,16 @@ License along with the GNU C Library. If not, see . */ +#include #include #include "kernel_sysinfo.h" - - .text - -ENTRY(__feraiseexcept) - cfi_startproc - PSEUDO_PROLOGUE - - lda sp, -16(sp) - cfi_adjust_cfa_offset(16) - - ldi v0, __NR_osf_setsysinfo - stq a0, 0(sp) - mov sp, a1 - ldi a0, SSI_IEEE_RAISE_EXCEPTION - call_pal PAL_callsys - - lda sp, 16(sp) - cfi_adjust_cfa_offset(-16) - - /* Here in libm we can't use SYSCALL_ERROR_LABEL. Nor is it clear - that we'd want to set errno anyway. All we're required to do is - return non-zero on error. Which is exactly A3. */ - mov a3, v0 - ret - -END(__feraiseexcept) - cfi_endproc - +int +__feraiseexcept (int excepts) +{ + return -INTERNAL_SYSCALL_CALL (osf_setsysinfo, SSI_IEEE_RAISE_EXCEPTION, + &excepts, 0, 0, 0); +} #if IS_IN (libm) # include # if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2) diff --git a/sysdeps/unix/sysv/linux/alpha/getegid.S b/sysdeps/unix/sysv/linux/alpha/getegid.c similarity index 79% rename from sysdeps/unix/sysv/linux/alpha/getegid.S rename to sysdeps/unix/sysv/linux/alpha/getegid.c index 72a941210a..9aeccd5ba9 100644 --- a/sysdeps/unix/sysv/linux/alpha/getegid.S +++ b/sysdeps/unix/sysv/linux/alpha/getegid.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1991-2020 Free Software Foundation, Inc. +/* Get effective group identity. Linux/Alpha. + 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,12 +16,12 @@ License along with the GNU C Library. If not, see . */ +#include #include - -PSEUDO (__getegid, getxgid, 0) - MOVE (r1, r0) - ret -PSEUDO_END (__getegid) - +gid_t +__getegid (void) +{ + return __internal_syscall_pair (__NR_getxgid).sc_20; +} weak_alias (__getegid, getegid) diff --git a/sysdeps/unix/sysv/linux/alpha/geteuid.S b/sysdeps/unix/sysv/linux/alpha/geteuid.c similarity index 79% rename from sysdeps/unix/sysv/linux/alpha/geteuid.S rename to sysdeps/unix/sysv/linux/alpha/geteuid.c index a6db15d55c..63d73ac5d1 100644 --- a/sysdeps/unix/sysv/linux/alpha/geteuid.S +++ b/sysdeps/unix/sysv/linux/alpha/geteuid.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1991-2020 Free Software Foundation, Inc. +/* Get effective user identity. Linux/Alpha. + 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,12 +16,12 @@ License along with the GNU C Library. If not, see . */ +#include #include - -PSEUDO (__geteuid, getxuid, 0) - MOVE (r1, r0) - ret -PSEUDO_END (__geteuid) - +uid_t +__geteuid (void) +{ + return __internal_syscall_pair (__NR_getxuid).sc_20; +} weak_alias (__geteuid, geteuid) diff --git a/sysdeps/unix/sysv/linux/alpha/getppid.S b/sysdeps/unix/sysv/linux/alpha/getppid.c similarity index 79% rename from sysdeps/unix/sysv/linux/alpha/getppid.S rename to sysdeps/unix/sysv/linux/alpha/getppid.c index ae5cfc03aa..968b2a96a7 100644 --- a/sysdeps/unix/sysv/linux/alpha/getppid.S +++ b/sysdeps/unix/sysv/linux/alpha/getppid.c @@ -1,4 +1,5 @@ -/* Copyright (C) 1991-2020 Free Software Foundation, Inc. +/* Get parent process identification. Linux/Alpha. + 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,12 +16,12 @@ License along with the GNU C Library. If not, see . */ +#include #include - -PSEUDO (__getppid, getxpid, 0) - MOVE (r1, r0) - ret -PSEUDO_END (__getppid) - +pid_t +__getppid (void) +{ + return __internal_syscall_pair (__NR_getxpid).sc_20; +} weak_alias (__getppid, getppid) diff --git a/sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S b/sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.c similarity index 61% rename from sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S rename to sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.c index 72c2fbfc10..44e467f927 100644 --- a/sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S +++ b/sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.c @@ -1,6 +1,5 @@ -/* Copyright (C) 1993-2020 Free Software Foundation, Inc. +/* Copyright (C) 2020 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by David Mosberger , 1995. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -16,35 +15,19 @@ License along with the GNU C Library. If not, see . */ +#include #include #include "kernel_sysinfo.h" - - .text - -ENTRY(__ieee_get_fp_control) - cfi_startproc - PSEUDO_PROLOGUE - - lda sp, -16(sp) - cfi_adjust_cfa_offset(16) - - mov sp, a1 - ldi a0, GSI_IEEE_FP_CONTROL - ldi v0, __NR_osf_getsysinfo - call_pal PAL_callsys - - ldq t0, 0(sp) - lda sp, 16(sp) - cfi_adjust_cfa_offset(-16) - - bne a3, SYSCALL_ERROR_LABEL - - mov t0, v0 - ret - -PSEUDO_END(__ieee_get_fp_control) - cfi_endproc - -libc_hidden_def(__ieee_get_fp_control) +unsigned long int +__ieee_get_fp_control (void) +{ + unsigned long int env; + int r = INLINE_SYSCALL_CALL (osf_getsysinfo, GSI_IEEE_FP_CONTROL, &env, 0, + 0, 0); + if (r != 0) + return r; + return env; +} +libc_hidden_def (__ieee_get_fp_control) weak_alias (__ieee_get_fp_control, ieee_get_fp_control) diff --git a/sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S b/sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.c similarity index 62% rename from sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S rename to sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.c index 9e80346b3e..0a85ff1b64 100644 --- a/sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S +++ b/sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.c @@ -1,6 +1,5 @@ -/* Copyright (C) 1993-2020 Free Software Foundation, Inc. +/* Copyright (C) 2020 Free Software Foundation, Inc. This file is part of the GNU C Library. - Contributed by David Mosberger , 1995. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -16,31 +15,15 @@ License along with the GNU C Library. If not, see . */ +#include #include #include "kernel_sysinfo.h" - -ENTRY(__ieee_set_fp_control) - cfi_startproc - PSEUDO_PROLOGUE - - lda sp, -16(sp) - cfi_adjust_cfa_offset(16) - - ldi v0, __NR_osf_setsysinfo - stq a0, 0(sp) - mov sp, a1 - ldi a0, SSI_IEEE_FP_CONTROL - call_pal PAL_callsys - - lda sp, 16(sp) - cfi_adjust_cfa_offset(-16) - - bne a3, SYSCALL_ERROR_LABEL - ret - -PSEUDO_END(__ieee_set_fp_control) - cfi_endproc - -libc_hidden_def(__ieee_set_fp_control) +void +__ieee_set_fp_control (unsigned long int env) +{ + INLINE_SYSCALL_CALL (osf_setsysinfo, SSI_IEEE_FP_CONTROL, &env, 0, + 0, 0); +} +libc_hidden_def (__ieee_set_fp_control) weak_alias (__ieee_set_fp_control, ieee_set_fp_control) diff --git a/sysdeps/unix/sysv/linux/alpha/setcontext.S b/sysdeps/unix/sysv/linux/alpha/setcontext.c similarity index 62% rename from sysdeps/unix/sysv/linux/alpha/setcontext.S rename to sysdeps/unix/sysv/linux/alpha/setcontext.c index 734f3d5109..4478bef26b 100644 --- a/sysdeps/unix/sysv/linux/alpha/setcontext.S +++ b/sysdeps/unix/sysv/linux/alpha/setcontext.c @@ -1,5 +1,5 @@ -/* Install given context. - Copyright (C) 2004-2020 Free Software Foundation, Inc. +/* Set the user context. Linux/Alpha 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,16 @@ License along with the GNU C Library. If not, see . */ +#include #include -#include - -/* In case the user fiddled it, copy the "official" signal mask - from the ucontext_t into the sigcontext structure. */ -#undef PSEUDO_PREPARE_ARGS -#define PSEUDO_PREPARE_ARGS \ - ldq $0, UC_SIGMASK($16); \ - stq $0, UC_SIGCTX+SC_MASK($16); \ - lda $16, UC_SIGCTX($16); - -PSEUDO(__setcontext, sigreturn, 1) - ret -PSEUDO_END(__setcontext) +int +__setcontext (const ucontext_t *ucp) +{ + /* In case the user fiddled it, copy the "official" signal mask + from the ucontext_t into the sigcontext structure. */ + ucontext_t *ucp_noconst = (ucontext_t *) ucp; + ucp_noconst->uc_mcontext.sc_mask = *((long int *)&ucp_noconst->uc_sigmask); + return INLINE_SYSCALL_CALL (sigreturn, &ucp->uc_mcontext); +} weak_alias (__setcontext, setcontext) diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep.h b/sysdeps/unix/sysv/linux/alpha/sysdep.h index 7daf445068..6d5458e2d8 100644 --- a/sysdeps/unix/sysv/linux/alpha/sysdep.h +++ b/sysdeps/unix/sysv/linux/alpha/sysdep.h @@ -314,6 +314,27 @@ __LABEL(name) \ : : internal_syscall_clobbers); \ _sc_19 != 0 ? -_sc_0 : _sc_0; \ }) + +struct pair_t +{ + long int sc_0; + long int sc_20; +}; + +static inline struct pair_t +__internal_syscall_pair (long int name) +{ + register long int sc_19 asm ("$19"); + register long int sc_20 asm ("$20"); + register long int sc_0 = name; + asm volatile ("callsys # %0 %1 <= %2" + : "+v" (sc_0), "=r" (sc_19), "=r" (sc_20) + : + : internal_syscall_clobbers, + "$16", "$17", "$18", "$21"); + return (struct pair_t) { sc_0, sc_20 }; +} + #endif /* ASSEMBLER */ /* Pointer mangling support. Note that tls access is slow enough that