public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] newlib: fix build with <gcc-5 versions
@ 2022-03-14  3:25 Mike Frysinger
  2022-03-14  7:36 ` Sebastian Huber
                   ` (2 more replies)
  0 siblings, 3 replies; 23+ messages in thread
From: Mike Frysinger @ 2022-03-14  3:25 UTC (permalink / raw)
  To: newlib

__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..9ab0fc1e16f4 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) 0
+#endif
+
 /* XXX: should use `#if __STDC_VERSION__ < 199901'. */
 #if !__GNUC_PREREQ__(2, 7) && !defined(__INTEL_COMPILER)
 #define	__func__	NULL
-- 
2.34.1


^ permalink raw reply	[flat|nested] 23+ messages in thread
* Re: Re: [PATCH v2] newlib: fix build with <gcc-5 versions
@ 2022-03-20 12:39 Eric Bresie
  0 siblings, 0 replies; 23+ messages in thread
From: Eric Bresie @ 2022-03-20 12:39 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: Richard Earnshaw, newlib

Interesting was not familiar with either of these
https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
https://gcc.gnu.org/onlinedocs/gcc/Integer-Overflow-Builtins.html

Eric Bresie
Ebresie@gmail.com (mailto:Ebresie@gmail.com)

> On March 15, 2022 at 6:54:00 PM CDT, Mike Frysinger <vapier@gentoo.org (mailto:vapier@gentoo.org)> wrote:
> On 15 Mar 2022 12:41, Richard Earnshaw wrote:
> > 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)?
>
> sure, that works too, thanks
> -mike
> signature.asc849 bytes (#attachment-1)

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2022-03-20 14:15 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-14  3:25 [PATCH] newlib: fix build with <gcc-5 versions Mike Frysinger
2022-03-14  7:36 ` Sebastian Huber
2022-03-14 16:58   ` Mike Frysinger
2022-03-15  3:25 ` [PATCH v2] " Mike Frysinger
2022-03-15 12:41   ` Richard Earnshaw
2022-03-15 23:54     ` Mike Frysinger
2022-03-16  7:12       ` R. Diez
2022-03-16  8:30         ` Mike Frysinger
2022-03-16  9:17           ` R. Diez
2022-03-17  2:41             ` Mike Frysinger
2022-03-17  9:49               ` Corinna Vinschen
2022-03-17 11:26                 ` Richard Earnshaw
2022-03-18  7:24                   ` Corinna Vinschen
2022-03-18  8:30                     ` R. Diez
2022-03-18  9:26                       ` Corinna Vinschen
2022-03-18  9:45                         ` R. Diez
2022-03-20  1:22                           ` Mike Frysinger
2022-03-20  1:21                 ` Mike Frysinger
2022-03-20 13:57                   ` Jordi Sanfeliu
2022-03-20 12:52       ` Eric Bresie
2022-03-20 14:16         ` Mike Frysinger
2022-03-15 23:53 ` [PATCH v3] " Mike Frysinger
2022-03-20 12:39 Re: [PATCH v2] " Eric Bresie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).