qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH] include/qemu/host-utils: Remove the *_overflow wrappers


From: Thomas Huth
Subject: Re: [RFC PATCH] include/qemu/host-utils: Remove the *_overflow wrappers
Date: Fri, 24 Jun 2022 07:40:53 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0

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 via email to

[Prev in Thread] Current Thread [Next in Thread]