From: Jeff King Date: Fri, 15 May 2026 16:53:24 GMT Subject: Re: [PATCH 2/2] use __builtin_add_overflow() in st_add() with Clang Message-ID: <20260515165324.GB88375@coredump.intra.peff.net> In-Reply-To: <26b71f9c-0cc5-4bfd-9175-f45b584e202e@web.de> On Fri, May 15, 2026 at 04:36:15PM +0200, René Scharfe wrote: > > I guess the ideal primitive is probably a wrapper with the same > > interface as __builtin_add_overflow(), which could then be used > > everywhere that unsigned_add_overflows() with some minor conversion. > > Junio said the same. :) > > But it gets awkward to do as a macro, and using an inline function runs > > into type questions. > Indeed. If it was easy then this wouldn't exist as a builtin. We > can approximate it somewhat, but will it be robust enough? I always thought it was a builtin because the most efficient way involves checking the carry flag, which can't be accessed from C. But yeah, the type issues are real, too. ;) I think we should take what you posted for now, and we can iterate on a more general add-and-check interface later (or never if it's too tricky). -Peff