Re: Re: [PATCH v2] newlib: fix build with <gcc-5 versions
Eric Bresie <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <6924e8ab-3322-4e4a-a9b1-1156a637a0a3@iPad> |
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? Eric Bresie [email protected] (mailto:[email protected]) > On March 15, 2022 at 6:54:00 PM CDT, Mike Frysinger <[email protected] (mailto:[email protected])> 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)