From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from cloud.peff.net (cloud.peff.net [217.216.95.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 164EF4BC032 for ; Fri, 15 May 2026 16:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.216.95.84 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778864007; cv=none; b=QgU6U+yhl/EmsUDdsv/8v4R2xw4GhdoAeg6JB7Y9hqulQmyrg8SQYG9CfE95uFO5o2BUt7psmdy7ami+p+SKQaB7zv1MkQZXai3nmP+K2NdtuMfIaK7m3OQoCZWedwop5KOHwbB+5IARMFmdjqPD/nnVYq80GaEZ4MCMv8VYvPo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778864007; c=relaxed/simple; bh=PLVO2DUV1l5Lwk4CSydWgyTtO4okG+S6GK4Ir9b33S4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Gkw495zLrLiqUkZr9zu5IqOJW8Totjz29M7qg+xnGJT3+0AxG4HQEHJ+pRhjqiqYY1ke3nZ46cXIHeLXND+v+XToDusdjS31t1Jj9StDu7d7NaI5R4dW7vQ5gHhj48EEVNrxbswdWZwbsg23oopph7IDrrBBE0BxFT9RGCxnv4g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peff.net; spf=pass smtp.mailfrom=peff.net; dkim=pass (2048-bit key) header.d=peff.net header.i=@peff.net header.b=gHrQdO6M; arc=none smtp.client-ip=217.216.95.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=peff.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=peff.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=peff.net header.i=@peff.net header.b="gHrQdO6M" Received: (qmail 55987 invoked by uid 106); 15 May 2026 16:53:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=peff.net; h=date:from:to:cc:subject:message-id:references:mime-version:content-type:content-transfer-encoding:in-reply-to; s=20240930; bh=PLVO2DUV1l5Lwk4CSydWgyTtO4okG+S6GK4Ir9b33S4=; b=gHrQdO6MUT49bLUCDbkZszRAdO4l45DxDRdLKdSjUg+L2myrpkXpm1gHrGqGQdOdVQKXpJPS+5V3kX06uf94YCwC2ur9jnjidOchgJ04Azg5HRsYfzcNkMnKpahN+Xq5U+jZZQzOE/AhyPWp3bpayWFMJw8DuYS1CsrBLP7tz2CfvRgiGgY9syEBaMvCAvgddPlTAQzb361oZqTYrglE81X7FcjBiQLOjZiENwBUiGPa0TBvPisBQP82jJuJvrw5FELADk9HJsVyXsUcghF0Gqzrh9WQixbtX7M2CIRMzr+V6xVArN/FoQ2Wm9Yi/FjlLBpp4682ddnrLCQtk7SZJQ== Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Fri, 15 May 2026 16:53:25 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 103978 invoked by uid 111); 15 May 2026 16:53:24 -0000 Received: from coredump.intra.peff.net (HELO coredump.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Fri, 15 May 2026 12:53:24 -0400 Authentication-Results: peff.net; auth=none Date: Fri, 15 May 2026 12:53:24 -0400 From: Jeff King To: =?utf-8?B?UmVuw6k=?= Scharfe Cc: Git List Subject: Re: [PATCH 2/2] use __builtin_add_overflow() in st_add() with Clang Message-ID: <20260515165324.GB88375@coredump.intra.peff.net> References: <0ded6062-f66a-4713-af24-d1b5aa654823@web.de> <20260515044059.GB83595@coredump.intra.peff.net> <26b71f9c-0cc5-4bfd-9175-f45b584e202e@web.de> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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