From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F661C433EF for ; Sun, 26 Sep 2021 17:16:45 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B204160F48 for ; Sun, 26 Sep 2021 17:16:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B204160F48 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=bsdimp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:48886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mUXlb-0003hC-K5 for qemu-devel@archiver.kernel.org; Sun, 26 Sep 2021 13:16:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mUXjp-00024k-T6 for qemu-devel@nongnu.org; Sun, 26 Sep 2021 13:14:53 -0400 Received: from mail-ua1-x933.google.com ([2607:f8b0:4864:20::933]:37554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mUXjn-0005y0-9H for qemu-devel@nongnu.org; Sun, 26 Sep 2021 13:14:52 -0400 Received: by mail-ua1-x933.google.com with SMTP id p9so10522269uak.4 for ; Sun, 26 Sep 2021 10:14:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Jnxm+fFaZHpp7Zl/vSt0U7fn8D/GF8HVqbsT8xZg4co=; b=nPNET2wwikxjGNXnEHSF7Bgr921xoQ23+QKcI1PNtgkazj0yesD3j4ImWZp8u1cp/b HH3ROZjSENYJ6F8IUlyrDn2pVsE/dimbFM5mQGLvG/qFRFArHVRWL32aKsV1gmE9E+Ng tTakck0+kzw1xhFwc6v9eZHJLMN8ez8lV8X7n3RdChS6xNSgI6nzwxELMQWI3Y8zxXEi LdT3JscRvdR66Am2eM486q0HoeACMdxLc98x8Nghmq67hC42ollLd63iaSNrtk+Vs9tD fdpg53PMxWeDIuPxPbbuc6/17OdpbtiuRZzHlR8jJhTNPfbJ3od1JFtU/O6DcDucDtVb B9yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Jnxm+fFaZHpp7Zl/vSt0U7fn8D/GF8HVqbsT8xZg4co=; b=o7xY3Pfq0gUtixmzEi5rxjMkQgfuhhBee44ZHukPU3FxqHWjOU6v/1NpFHcHPM5rGC q2R/vE5+ClgNOZbEEgaB83U2EgNZx8dzbQE4Xy0T9M531P2bWKgYUPSnBQ03LrSfF6Vc RPa1Z/KttJo9o34p6xhXqXQT7hyw0adZla95GlOzsWjlUZpgkpXmTraSDUqVxWN2fI62 LUGulu0WdIZftmFt4/DslXbJD7Six6XIcWe8u52C9N06JyFfeMJ/Kkg/m4EBaaG3P72i cf1v/ihgYD2uRFR7le4dJomwgRlvPkVqMyxCgcHlsso/yl6lBMa9gAHEmf6jlcKXIeMe 97wQ== X-Gm-Message-State: AOAM5338c46vuWPjJ96C2By6ItqsBhqBFt4OxQaa5j0qOUO6z7+guyJt 0XI40qHwqOsz29NkQCiPpeJulLkKlDaR4AqCMAKoag== X-Google-Smtp-Source: ABdhPJyhvRbGyru9H7HNhCeKxbgJ77xsbmk9hqaJHx9yWR1E0gwqMHNDwcFRw1yu8nqc+QR/dtoIgUR3/aQSjZJKHgk= X-Received: by 2002:ab0:5b5d:: with SMTP id v29mr8472690uae.85.1632676489980; Sun, 26 Sep 2021 10:14:49 -0700 (PDT) MIME-Version: 1.0 References: <20210922061438.27645-1-imp@bsdimp.com> <20210922061438.27645-5-imp@bsdimp.com> <10bb09fe-8995-29ab-e719-616d1a7e6114@amsat.org> In-Reply-To: <10bb09fe-8995-29ab-e719-616d1a7e6114@amsat.org> From: Warner Losh Date: Sun, 26 Sep 2021 11:14:39 -0600 Message-ID: Subject: Re: [PATCH 04/14] bsd-user: export get_errno and is_error from syscall.c To: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= Content-Type: multipart/alternative; boundary="0000000000003800df05cce91ea6" Received-SPF: none client-ip=2607:f8b0:4864:20::933; envelope-from=wlosh@bsdimp.com; helo=mail-ua1-x933.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kyle Evans , Richard Henderson , QEMU Developers Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --0000000000003800df05cce91ea6 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sat, Sep 25, 2021 at 4:33 AM Philippe Mathieu-Daud=C3=A9 wrote: > On 9/22/21 08:14, Warner Losh wrote: > > Make get_errno and is_error global so files other than syscall.c can us= e > > them. > > > > Signed-off-by: Warner Losh > > --- > > bsd-user/qemu.h | 4 ++++ > > bsd-user/syscall.c | 10 +++++----- > > 2 files changed, 9 insertions(+), 5 deletions(-) > > > > diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h > > index 522d6c4031..22fc3a6c30 100644 > > --- a/bsd-user/qemu.h > > +++ b/bsd-user/qemu.h > > @@ -235,6 +235,10 @@ extern unsigned long target_dflssiz; > > extern unsigned long target_maxssiz; > > extern unsigned long target_sgrowsiz; > > > > +/* syscall.c */ > > +abi_long get_errno(abi_long ret); > > +int is_error(abi_long ret); > > + > > /* user access */ > > > > #define VERIFY_READ PAGE_READ > > diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c > > index 372836d44d..a579d52ede 100644 > > --- a/bsd-user/syscall.c > > +++ b/bsd-user/syscall.c > > @@ -33,18 +33,18 @@ > > static abi_ulong target_brk; > > static abi_ulong target_original_brk; > > > > -static inline abi_long get_errno(abi_long ret) > > +abi_long get_errno(abi_long ret) > > { > > - if (ret =3D=3D -1) > > + if (ret =3D=3D -1) { > > /* XXX need to translate host -> target errnos here */ > > return -(errno); > > - else > > - return ret; > > + } > > + return ret; > > } > > > > #define target_to_host_bitmask(x, tbl) (x) > > > > -static inline int is_error(abi_long ret) > > +int is_error(abi_long ret) > > Since you are modifying this, do you mind having it return > a boolean type instead? > Nah, don't mind. There were no problems caused by making that change. > > { > > return (abi_ulong)ret >=3D (abi_ulong)(-4096); > > } > > > > Preferably having is_error() returning bool: > Reviewed-by: Philippe Mathieu-Daud=C3=A9 > Thanks for the suggestion. Warner --0000000000003800df05cce91ea6 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Sat, Sep 25, 2021 at 4:33 AM Phili= ppe Mathieu-Daud=C3=A9 <f4bug@amsat.o= rg> wrote:
imp@bsdimp.com>
> ---
>=C2=A0 =C2=A0bsd-user/qemu.h=C2=A0 =C2=A0 |=C2=A0 4 ++++
>=C2=A0 =C2=A0bsd-user/syscall.c | 10 +++++-----
>=C2=A0 =C2=A02 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> index 522d6c4031..22fc3a6c30 100644
> --- a/bsd-user/qemu.h
> +++ b/bsd-user/qemu.h
> @@ -235,6 +235,10 @@ extern unsigned long target_dflssiz;
>=C2=A0 =C2=A0extern unsigned long target_maxssiz;
>=C2=A0 =C2=A0extern unsigned long target_sgrowsiz;
>=C2=A0 =C2=A0
> +/* syscall.c */
> +abi_long get_errno(abi_long ret);
> +int is_error(abi_long ret);
> +
>=C2=A0 =C2=A0/* user access */
>=C2=A0 =C2=A0
>=C2=A0 =C2=A0#define VERIFY_READ=C2=A0 PAGE_READ
> diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c
> index 372836d44d..a579d52ede 100644
> --- a/bsd-user/syscall.c
> +++ b/bsd-user/syscall.c
> @@ -33,18 +33,18 @@
>=C2=A0 =C2=A0static abi_ulong target_brk;
>=C2=A0 =C2=A0static abi_ulong target_original_brk;
>=C2=A0 =C2=A0
> -static inline abi_long get_errno(abi_long ret)
> +abi_long get_errno(abi_long ret)
>=C2=A0 =C2=A0{
> -=C2=A0 =C2=A0 if (ret =3D=3D -1)
> +=C2=A0 =C2=A0 if (ret =3D=3D -1) {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* XXX need to translate host = -> target errnos here */
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0return -(errno);
> -=C2=A0 =C2=A0 else
> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 return ret;
> +=C2=A0 =C2=A0 }
> +=C2=A0 =C2=A0 return ret;
>=C2=A0 =C2=A0}
>=C2=A0 =C2=A0
>=C2=A0 =C2=A0#define target_to_host_bitmask(x, tbl) (x)
>=C2=A0 =C2=A0
> -static inline int is_error(abi_long ret)
> +int is_error(abi_long ret)

Since you are modifying this, do you mind having it return
a boolean type instead?

Nah, don't = mind. There were no problems caused by making that change.
=C2=A0=
>=C2=A0 =C2=A0{
>=C2=A0 =C2=A0 =C2=A0 =C2=A0return (abi_ulong)ret >=3D (abi_ulong)(-4= 096);
>=C2=A0 =C2=A0}
>

Preferably having is_error() returning bool:
Reviewed-by: Philippe Mathieu-Daud=C3=A9 <f4bug@amsat.org>

Thanks for the suggestion.

Warner=C2=A0
--0000000000003800df05cce91ea6--