From: David Hildenbrand <david@redhat.com>
To: Gautam Agrawal <gautamnagrawal@gmail.com>, qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, thuth@redhat.com, cohuck@redhat.com,
richard.henderson@linaro.org
Subject: Re: [PATCH] tests/tcg/s390x: Test overflow conditions
Date: Mon, 30 May 2022 11:50:10 +0200 [thread overview]
Message-ID: <9337daf2-57bf-d2ee-6731-8f10251fbf17@redhat.com> (raw)
In-Reply-To: <20220527101104.26679-1-gautamnagrawal@gmail.com>
On 27.05.22 12:11, Gautam Agrawal wrote:
> Add a test to check for overflow conditions in s390x.
> This patch is based on the following patches :
> * https://git.qemu.org/?p=qemu.git;a=commitdiff;h=5a2e67a691501
> * https://git.qemu.org/?p=qemu.git;a=commitdiff;h=fc6e0d0f2db51
>
> Signed-off-by: Gautam Agrawal <gautamnagrawal@gmail.com>
> ---
> tests/tcg/s390x/Makefile.target | 1 +
> tests/tcg/s390x/overflow.c | 58 +++++++++++++++++++++++++++++++++
> 2 files changed, 59 insertions(+)
> create mode 100644 tests/tcg/s390x/overflow.c
>
> diff --git a/tests/tcg/s390x/Makefile.target b/tests/tcg/s390x/Makefile.target
> index 3124172736..7f86de85b9 100644
> --- a/tests/tcg/s390x/Makefile.target
> +++ b/tests/tcg/s390x/Makefile.target
> @@ -16,6 +16,7 @@ TESTS+=shift
> TESTS+=trap
> TESTS+=signals-s390x
> TESTS+=branch-relative-long
> +TESTS+=overflow
>
> VECTOR_TESTS=vxeh2_vs
> VECTOR_TESTS+=vxeh2_vcvt
> diff --git a/tests/tcg/s390x/overflow.c b/tests/tcg/s390x/overflow.c
> new file mode 100644
> index 0000000000..ea8a410b1a
> --- /dev/null
> +++ b/tests/tcg/s390x/overflow.c
> @@ -0,0 +1,58 @@
> +#include <stdio.h>
> +
> +int overflow_add_32(int x, int y)
> +{
> + int sum;
> + return __builtin_add_overflow(x, y, &sum);
> +}
> +
> +int overflow_add_64(long long x, long long y)
> +{
> + long sum;
Just wondering, why "long long" in input and "long" in output?
> + return __builtin_add_overflow(x, y, &sum);
> +}
> +
> +int overflow_sub_32(int x, int y)
> +{
> + int sum;
> + return __builtin_sub_overflow(x, y, &sum);
> +}
> +
> +int overflow_sub_64(long long x, long long y)
> +{
> + long sum;
> + return __builtin_sub_overflow(x, y, &sum);
nit: I'd call all local variables "ret" or "res".
Apart from that LGTM.
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2022-05-30 9:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-27 10:11 [PATCH] tests/tcg/s390x: Test overflow conditions Gautam Agrawal
2022-05-27 13:51 ` Alex Bennée
2022-05-30 9:50 ` David Hildenbrand [this message]
2022-05-30 10:35 ` Thomas Huth
2022-05-30 19:20 ` Gautam Agrawal
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=9337daf2-57bf-d2ee-6731-8f10251fbf17@redhat.com \
--to=david@redhat.com \
--cc=cohuck@redhat.com \
--cc=gautamnagrawal@gmail.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
/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).