On 12/28/22 01:07, Ondrej Valousek wrote:
I was actually wondering why did not you reuse the suggestion from Andreas:
#  define ROUNDUP(x, y)                  (((x) + (y) - 1) & - (y))

It didn't work when the + overflowed, and it assumed two's complement. The latter assumption is pretty safe nowadays (and will be required by C23, finally!) but I have a thing about portability. Although these issues are fixable the particular situation here (where values close to 2**32-1 really do represent 2**32 bytes, and where gcc incorrectly complains about adding aligned byte counts to aligned pointers) suggested special code.


Reply via email to