From patchwork Mon Feb 10 19:20:30 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: 183254 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4417332ile; Mon, 10 Feb 2020 11:21:53 -0800 (PST) X-Google-Smtp-Source: APXvYqzzkWKl1UHrxHXT2Sv3k+8rYN7Ybjz3RCh8gYHUy48cqFxW26idQJrItAnEeON2i6AjEiwt X-Received: by 2002:a05:6830:1047:: with SMTP id b7mr2327946otp.77.1581362513849; Mon, 10 Feb 2020 11:21:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581362513; cv=none; d=google.com; s=arc-20160816; b=yYe//wAecn6SR5Ud0b198ljo2/TMhNa+wgk4xUx6fhEq8RrG51/qMHNKgxwc+LtIdZ hIj82Ecfnqbc0eN6iquHtLE/1Tdmlp9t4NC4ShBtpnHLIA5qlGcnkIjbgTqw4k9cQbYN tNbGDB1kqqCJI74CNaWqo62Qd79izn03Y91Jhgg1v4N1Fa1VsFxWZiNBlYdDNMa/dHL7 Llv2Mnul/PrhsJkBxQoVO5B2WbWATrNtDTePyOheEMcnLQ9K2qjGlcb7+dZv77D0sVj0 oqsuu48Ksf+R7/ZFfUC8Lixy83en9nZ5nHHgPJLV9vrFJbH6PpHcm521mDAJY4Y3JvCe j+XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=00Usgue9kav1exiPt1vt3OwI2iREsWGpuCq1RfxXffU=; b=Wm9Z9uvNxfDIYkFJ/UT9A8uKA9u0JuPEDHqqGpQ6SyRrbWye2DAY5O7luUAQM7o+45 oXv5POEOEESMMQxQgLsXi+rHMY6B0oiINDwM4yc/nKhm/6BP/6U882gdQcETzsdDyYFp pYsiYlC0+gA0SRfh9VCanpDgN4Oa1fexk6UUCOTZ+MJeueU62Wx8RV7oNHofMEPzl/bK zE73TwM8CH2NhS35rhjK9Y5yVDVyhHFeutP/7VrJflQTRSOMRlMwK0h6Q6jGrxCEAEft LarY75iK1+YhUiLH6AfRSvn3qfn6LJ++8uqP9XfS/tnPhmkzpydR+junHW9YtCNQzJKM tWSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ZPT94NQG; dkim=pass header.i=@linaro.org header.s=google header.b=FUpBzcKu; spf=pass (google.com: domain of libc-alpha-return-109391-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-109391-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n20si586455oig.53.2020.02.10.11.21.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Feb 2020 11:21:53 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-109391-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ZPT94NQG; dkim=pass header.i=@linaro.org header.s=google header.b=FUpBzcKu; spf=pass (google.com: domain of libc-alpha-return-109391-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-109391-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=hBxN4lMedUVvBduW/gioh2Nn1PmRaIb hdb3ldZJg4vhKM5QGiMQ1Gtiwno+/XSdScyhCnJAfrV2sYDBG3H2IMK5ipPE13ur pt3U70JOgkzlsBAH0yjSyVipyV3O3wsl2+m1cGMK3Zx7FzEI2OTsI2FbkF5L93qo dijbdp+X3bXU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=FLbULjimT9DjZYl5jmFcpNikHLQ=; b=ZPT94 NQGN9COqSZvDk7C5ahlJmAFQJ5oTDHL0VEnghXyBf8WXHYFFYymN2vfEkD8UELgC poWh7n9Y5/ayzFmiNK26KqQnZsYL93PHttFoGwLafPNo4DVtq5Cl6R0/WBhtb3q+ xiK436/8uvHZNYR3wXHD6OZUbqFjcjc7q4yyno= Received: (qmail 100060 invoked by alias); 10 Feb 2020 19:20:56 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 99948 invoked by uid 89); 10 Feb 2020 19:20:55 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qt1-f196.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=00Usgue9kav1exiPt1vt3OwI2iREsWGpuCq1RfxXffU=; b=FUpBzcKu8pzMsYZCbL1TNcYlF1oXyv4eVAY/EUQPrx9myNOyyYVVU0mIHSS86W0rav BH7TqRxCr7pJcQFOiGLCjBVlDpBnBb9bmE8Xz2kJvbDj+d3ZFLuXhCIY7970HE7KMuvn WE4YzBAl2YEynLR68Xvnfv4fvt7xXXupuTHhUzh7lXODEAVFHXm7yDRQPdlDjtHzbk+y 7XuSbWqs9mRVctuQI+8BqqiypxU2F3CXzZRlXhJzetJvMKmLvkhbD4BwoONXq4u1iXVN yF9hsgBzeIl1fdx8gHbmbzkMglDOeXvNaX+PVU2YqQQ06Fe24WWV/Sn/08CGgMOM5iMy zBfA== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 07/15] mips: Use Linux kABI for syscall return Date: Mon, 10 Feb 2020 16:20:30 -0300 Message-Id: <20200210192038.23588-7-adhemerval.zanella@linaro.org> In-Reply-To: <20200210192038.23588-1-adhemerval.zanella@linaro.org> References: <20200210192038.23588-1-adhemerval.zanella@linaro.org> It changes the mips INTERNAL_SYSCALL* and internal_syscall* macros to return a negative value instead of 'a3' register value on 'err' macro argument. The macro INTERNAL_SYSCALL_DECL is no longer required, and the INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS. The redefinition of INTERNAL_VSYSCALL_CALL is also no longer required. Checked on mips64-linux-gnu, mips64n32-linux-gnu, and mips-linux-gnu. --- sysdeps/unix/sysv/linux/mips/mips32/sysdep.h | 32 ++++++++------------ sysdeps/unix/sysv/linux/mips/mips64/sysdep.h | 28 +++++++---------- sysdeps/unix/sysv/linux/mips/sysdep.h | 16 ---------- 3 files changed, 23 insertions(+), 53 deletions(-) -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h index beefcf284b..6842ff5211 100644 --- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h @@ -61,13 +61,14 @@ result_var; }) #undef INTERNAL_SYSCALL_DECL -#define INTERNAL_SYSCALL_DECL(err) long err __attribute__ ((unused)) +#define INTERNAL_SYSCALL_DECL(err) do { } while (0) #undef INTERNAL_SYSCALL_ERROR_P -#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (long) (err)) +#define INTERNAL_SYSCALL_ERROR_P(val, err) \ + ((unsigned long) (val) >= (unsigned long) -4095) #undef INTERNAL_SYSCALL_ERRNO -#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val) +#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) /* Note that the original Linux syscall restart convention required the instruction immediately preceding SYSCALL to initialize $v0 with the @@ -128,7 +129,6 @@ union __mips_syscall_return ({ \ union __mips_syscall_return _sc_ret; \ _sc_ret.val = __mips16_syscall##nr (args, number); \ - err = _sc_ret.reg.v1; \ _sc_ret.reg.v0; \ }) @@ -167,8 +167,7 @@ union __mips_syscall_return : "=r" (__v0), "=r" (__a3) \ : input \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -191,8 +190,7 @@ union __mips_syscall_return : "=r" (__v0), "=r" (__a3) \ : input, "r" (__a0) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -216,8 +214,7 @@ union __mips_syscall_return : "=r" (__v0), "=r" (__a3) \ : input, "r" (__a0), "r" (__a1) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -243,8 +240,7 @@ union __mips_syscall_return : "=r" (__v0), "=r" (__a3) \ : input, "r" (__a0), "r" (__a1), "r" (__a2) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -270,8 +266,7 @@ union __mips_syscall_return : "=r" (__v0), "+r" (__a3) \ : input, "r" (__a0), "r" (__a1), "r" (__a2) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -300,8 +295,7 @@ libc_hidden_proto (__mips_syscall5, nomips16) (long) (arg4), \ (long) (arg5), \ (long) (number)); \ - err = _sc_ret.reg.v1; \ - _sc_ret.reg.v0; \ + _sc_ret.reg.v1 != 0 ? -_sc_ret.reg.v0 : _sc_ret.reg.v0; \ }) long long __nomips16 __mips_syscall6 (long arg1, long arg2, long arg3, @@ -320,8 +314,7 @@ libc_hidden_proto (__mips_syscall6, nomips16) (long) (arg5), \ (long) (arg6), \ (long) (number)); \ - err = _sc_ret.reg.v1; \ - _sc_ret.reg.v0; \ + _sc_ret.reg.v1 != 0 ? -_sc_ret.reg.v0 : _sc_ret.reg.v0; \ }) long long __nomips16 __mips_syscall7 (long arg1, long arg2, long arg3, @@ -342,8 +335,7 @@ libc_hidden_proto (__mips_syscall7, nomips16) (long) (arg6), \ (long) (arg7), \ (long) (number)); \ - err = _sc_ret.reg.v1; \ - _sc_ret.reg.v0; \ + _sc_ret.reg.v1 != 0 ? -_sc_ret.reg.v0 : _sc_ret.reg.v0; \ }) #if __mips_isa_rev >= 6 diff --git a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h index 617e229a67..072016f07e 100644 --- a/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/mips64/sysdep.h @@ -69,13 +69,14 @@ typedef long int __syscall_arg_t; result_var; }) #undef INTERNAL_SYSCALL_DECL -#define INTERNAL_SYSCALL_DECL(err) long err __attribute__ ((unused)) +#define INTERNAL_SYSCALL_DECL(err) do { } while (0) #undef INTERNAL_SYSCALL_ERROR_P -#define INTERNAL_SYSCALL_ERROR_P(val, err) ((void) (val), (long) (err)) +#define INTERNAL_SYSCALL_ERROR_P(val, err) \ + ((unsigned long) (val) >= (unsigned long) -4095) #undef INTERNAL_SYSCALL_ERRNO -#define INTERNAL_SYSCALL_ERRNO(val, err) ((void) (err), val) +#define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) /* Note that the original Linux syscall restart convention required the instruction immediately preceding SYSCALL to initialize $v0 with the @@ -133,8 +134,7 @@ typedef long int __syscall_arg_t; : "=r" (__v0), "=r" (__a3) \ : input \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -157,8 +157,7 @@ typedef long int __syscall_arg_t; : "=r" (__v0), "=r" (__a3) \ : input, "r" (__a0) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -182,8 +181,7 @@ typedef long int __syscall_arg_t; : "=r" (__v0), "=r" (__a3) \ : input, "r" (__a0), "r" (__a1) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -209,8 +207,7 @@ typedef long int __syscall_arg_t; : "=r" (__v0), "=r" (__a3) \ : input, "r" (__a0), "r" (__a1), "r" (__a2) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -236,8 +233,7 @@ typedef long int __syscall_arg_t; : "=r" (__v0), "+r" (__a3) \ : input, "r" (__a0), "r" (__a1), "r" (__a2) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -264,8 +260,7 @@ typedef long int __syscall_arg_t; : "=r" (__v0), "+r" (__a3) \ : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) @@ -294,8 +289,7 @@ typedef long int __syscall_arg_t; : input, "r" (__a0), "r" (__a1), "r" (__a2), "r" (__a4), \ "r" (__a5) \ : __SYSCALL_CLOBBERS); \ - err = __a3; \ - _sys_result = __v0; \ + _sys_result = __a3 != 0 ? -__v0 : __v0; \ } \ _sys_result; \ }) diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h index cdfc0b1b58..877768a249 100644 --- a/sysdeps/unix/sysv/linux/mips/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/sysdep.h @@ -28,19 +28,3 @@ #endif #define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" #define HAVE_CLOCK_GETRES_VSYSCALL "__vdso_clock_getres" - -#ifndef __ASSEMBLER__ - -/* Standard MIPS syscalls have an error flag, and return a positive errno - when the error flag is set. Emulate this behaviour for vsyscalls so that - the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly. */ -#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \ - ({ \ - long _ret = funcptr (args); \ - err = ((unsigned long) (_ret) >= (unsigned long) -4095L); \ - if (err) \ - _ret = -_ret; \ - _ret; \ - }) - -#endif /* __ASSEMBLER__ */