bug-gnulib
[Top][All Lists]
Advanced

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

Re: xsize and flexmember


From: Paul Eggert
Subject: Re: xsize and flexmember
Date: Fri, 1 May 2020 14:08:33 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 5/1/20 2:09 AM, Bruno Haible wrote:
> I'm open to this. What prefix would you propose instead of 'x'?

The usual English-language name for this sort of thing is "saturation
arithmetic", but SATURATED_ADD is kind of long. LLVM uses "sat" for saturated
operations, perhaps the prefix "SAT" will do.

I could probably find uses for a new intprops.h macro INT_ADD_SAT (a, b) macro
that would behave like INT_ADD_WRAPV (a, b, r) except it would return a
saturated result instead of storing a wraparound-on-overflow result into *R and
returning an overflow indicator. This would be more general than a size_t-only
approach. It would be a little tricky, though, since A and B might not be the
same type and then how does one define saturation? would it be relative to the
type of A+B?



reply via email to

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