Re: [PATCH v2] newlib: fix build with <gcc-5 versions

Richard Earnshaw <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>

On 15/03/2022 03:25, Mike Frysinger wrote:
> __builtin_mul_overflow showed up with gcc-5, so stub it out for older
> versions.
> ---
>   newlib/libc/include/sys/cdefs.h | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h
> index da729092185c..e51f7f4b873a 100644
> --- a/newlib/libc/include/sys/cdefs.h
> +++ b/newlib/libc/include/sys/cdefs.h
> @@ -416,6 +416,10 @@
>   #define	__unreachable()	((void)0)
>   #endif
>   
> +#if !__GNUC_PREREQ__(5, 0)
> +#define __builtin_mul_overflow(a, b, size) ({ *(size) = (a) * (b); 0; })

Wouldn't
(*(size) = (a) * (b), 0)

be more portable (avoiding the GNU statement expression extension)?

R.

> +#endif
> +
>   /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
>   #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
>   #define	__func__	NULL
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.