From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 80F3C3858C74 for ; Sun, 20 Mar 2022 14:15:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 80F3C3858C74 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id E9E9E342AB4; Sun, 20 Mar 2022 14:15:52 +0000 (UTC) Date: Sun, 20 Mar 2022 10:16:03 -0400 From: Mike Frysinger To: Eric Bresie Cc: Newlib Subject: Re: [PATCH v2] newlib: fix build with Mail-Followup-To: Eric Bresie , Newlib References: <6924e8ab-3322-4e4a-a9b1-1156a637a0a3@iPad> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="SJSih/Vp63UDVqVV" Content-Disposition: inline In-Reply-To: <6924e8ab-3322-4e4a-a9b1-1156a637a0a3@iPad> X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 20 Mar 2022 14:15:55 -0000 --SJSih/Vp63UDVqVV Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 20 Mar 2022 07:52, Eric Bresie wrote: > My C is a little rusty so forgive me up front if I=E2=80=99m not reading = something quite right=E2=80=A6 >=20 > Trying to understand the basic logic, the macro is expected to return Boo= lean but the expression is assigning the multiplication results to the size= and then always returning 0 (false). Is that flow correct? Should there be= some form of =E2=80=9C=3D=3D=E2=80=9C involved and/or ever return non-zero= number? it returns a bool to indicate whether there was overflow, but the result of= the actual multiplication of the first two operands is stored in the 3rd arg. a return value of true means "the value overflowed", not "the multiplication was successful". hence returning false is what the stub should do. https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html Built-in Function: bool __builtin_mul_overflow (type1 a, type2 b, type3 *re= s) These built-in functions promote the first two operands into infinite preci= sion signed type and perform multiplication on those promoted operands. The resu= lt is then cast to the type the third pointer argument points to and stored there= =2E If the stored result is equal to the infinite precision result, the built-in functions return false, otherwise they return true. As the multiplication is performed in infinite signed precision, these built-in functions have fully defined behavior for all argument values. -mike --SJSih/Vp63UDVqVV Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmI3NyMACgkQQWM7n+g3 9YEzqxAA4UKZxm4DQrhtLl/DZRmja8Z888MFc3Gsb552ar6AFpsa/lXQ3f+ysWIz 5HO/kywaGEF38By+4wK9zXezjJ/5sbMJPA51j3zUr9lT+WtOFpISm8r5jP0SuYRF Z+ienYJMBOaUTVMF2B1GObJ55wwMv15oxUDt9w3aUYyij6ExwhxufvRplqc8ny4e YsWKP683RtQVOIwvSUQBvXp5MYHaAXs9r991ULCXW25z+0P3RQXCinU3JCZlp3dT ysEThzHRJ+dtCx7hixVIOqU17Qlr6D74NOpV8Xk9oHeTHzJzQHjbDFDFM2kPd4jV ftmfvCEPGlNN7c4k3iR6AEgNRuj4PA+T/eNdQ3XeIBvgMssaIMnrsc/4ARvPkIhC lFFnuE2AZ54Vqs5pWsxBrfmBD2NlEO9TkQbCicftAcQQjYnGIBrLLTa7+KZwTymP l5SKoHBvFusgxSOFmdfnbABLuMQivqQlD1lZGhD2OiURa7yEbHlck0pYfBcO4D9h y4GcJbG52R5N+X2QtH63WVtGTHjhoZtyI/GJA0M2q61nFLUvlvMxrkXV5NsMTxaN QZLHps6I53U9aQQpHBblkegqaIitIUk5XSrJ9SgRjVxw8rmMLhFf964O7JyW0iiC oyDBvmfzCnzUIRorir5LxRqfQ6UK6BABMFKMC52uslbLDh98xXI= =f3tB -----END PGP SIGNATURE----- --SJSih/Vp63UDVqVV--