Re: [PATCH v2] newlib: fix build with <gcc-5 versions
Mike Frysinger <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <Yjc3IxJbYF+yRpJS@vapier> |
On 20 Mar 2022 07:52, Eric Bresie wrote: > My C is a little rusty so forgive me up front if I’m not reading something quite right… > > Trying to understand the basic logic, the macro is expected to return Boolean 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 “==“ 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 *res) These built-in functions promote the first two operands into infinite precision signed type and perform multiplication on those promoted operands. The result is then cast to the type the third pointer argument points to and stored there. 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
signature.asc
(application/pgp-signature, 833 B)
-----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-----