qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: Richard Henderson <richard.henderson@linaro.org>,
	Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Aurelien Jarno" <aurelien@aurel32.net>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [RFC PATCH] include/qemu/host-utils: Remove the *_overflow wrappers
Date: Fri, 24 Jun 2022 07:40:53 +0200	[thread overview]
Message-ID: <d2dc72e9-3393-f7c2-f79f-2021d47c44b9@redhat.com> (raw)
In-Reply-To: <0a1ecd14-69a8-afc6-f74c-18d5abf2e4d0@linaro.org>

On 23/06/2022 23.29, Richard Henderson wrote:
> On 6/23/22 12:30, Peter Maydell wrote:
>>> -static inline bool sadd32_overflow(int32_t x, int32_t y, int32_t *ret)
>>> -{
>>> -#if __has_builtin(__builtin_add_overflow) || __GNUC__ >= 5
>>> -    return __builtin_add_overflow(x, y, ret);
>>> -#else
>>> -    *ret = x + y;
>>> -    return ((*ret ^ x) & ~(x ^ y)) < 0;
>>> -#endif
>>> -}
>>
>> I think I'd prefer to keep the wrapper functions and just delete
>> the fallback ifdeffery, but I guess I don't feel really strongly
>> about it. Richard, do you have an opinion?
> 
> Likewise I don't feel strongly, but lean toward keeping the names.  I will 
> point out that without these names, one has to track down the type of each 
> argument to figure out what is, or is not, overflowing.

Yes, I checked the calling sites, and some do use different types indeed, 
but as far as I understood the __builtin_add_overflow(), it should be ok in 
our cases. Anyway, it's maybe less error prone to keep the wrapper with the 
fixed parameter types, so I'll send a v2 that just removes the #ifs instead.

  Thomas



      reply	other threads:[~2022-06-24  5:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-23 16:40 [RFC PATCH] include/qemu/host-utils: Remove the *_overflow wrappers Thomas Huth
2022-06-23 19:30 ` Peter Maydell
2022-06-23 21:29   ` Richard Henderson
2022-06-24  5:40     ` Thomas Huth [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=d2dc72e9-3393-f7c2-f79f-2021d47c44b9@redhat.com \
    --to=thuth@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=aurelien@aurel32.net \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).