From: Laurent Desnogues <laurent.desnogues@gmail.com>
To: Aurelien Jarno <aurelien@aurel32.net>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] target-arm: fix sdiv helper
Date: Sun, 18 Oct 2009 16:29:00 +0200 [thread overview]
Message-ID: <761ea48b0910180729s1221bf45m4c38303ca2f44657@mail.gmail.com> (raw)
In-Reply-To: <20091015210846.GB7071@volta.aurel32.net>
On Thu, Oct 15, 2009 at 11:08 PM, Aurelien Jarno <aurelien@aurel32.net> wrote:
> (INT32_MIN / -1) triggers an overflow, and the result depends on the
> host architecture (INT32_MIN on arm, -1 on ppc, SIGFPE on x86). Use a
> test to output the correct value.
>
> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
> ---
> target-arm/helper.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/target-arm/helper.c b/target-arm/helper.c
> index 701629a..b3d6198 100644
> --- a/target-arm/helper.c
> +++ b/target-arm/helper.c
> @@ -404,6 +404,8 @@ int32_t HELPER(sdiv)(int32_t num, int32_t den)
> {
> if (den == 0)
> return 0;
> + if (num == INT_MIN && den == -1)
> + return INT_MIN;
> return num / den;
> }
>
> --
> 1.6.1.3
Acked-by: Laurent Desnogues <laurent.desnogues@gmail.com>
That is provided we accept the behaviour for division by zero is
not strictly conforming to what the ARM ARM says.
Also note this instruction is not available on v7-A CPU's (Cortex-A8
for instance). It's part of v7-R (Cortex R4).
Laurent
prev parent reply other threads:[~2009-10-18 14:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-15 21:08 [Qemu-devel] [PATCH] target-arm: fix sdiv helper Aurelien Jarno
2009-10-18 14:29 ` Laurent Desnogues [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=761ea48b0910180729s1221bf45m4c38303ca2f44657@mail.gmail.com \
--to=laurent.desnogues@gmail.com \
--cc=aurelien@aurel32.net \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).