Re: [PATCH newlib 0/1] sys/signal.h needs sys/_intsup.h

C Howland <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <CANk6obQYxYsk6HjtUE6o7UqFstumf8=fdJc-fHLPSezFf5foEg@mail.gmail.com>
On Fri, 27 Aug 2021 at 12:17, Joel Sherrill <[email protected]> wrote:

>
>
> On Fri, Aug 27, 2021, 10:12 AM C Howland <[email protected]> wrote:
>
>> >
>> >
>> > ------------------------------
>> > *From:* Newlib <[email protected]>
>> on
>> > behalf of Joel Sherrill <[email protected]>
>> > *Sent:* Friday, August 27, 2021 9:47 AM
>> > *To:* Newlib <[email protected]>
>> > *Subject:* Re: Fw: [PATCH newlib 0/1] sys/signal.h needs sys/_intsup.h
>> >
>> >
>> > On Fri, Aug 27, 2021 at 5:16 AM Corinna Vinschen <[email protected]>
>> > wrote:
>> > >
>> > > On Aug 26 18:28, Joel Sherrill wrote:
>> > > > We recently added this to sys/signal.h:
>> > > >
>> > > > #if __STDINT_EXP(INT_MAX) > 0x7fff
>> > > > #define SIG2STR_MAX (sizeof("RTMAX+") + sizeof("4294967295") - 1)
>> > > > #else
>> > > > #define SIG2STR_MAX (sizeof("RTMAX+") + sizeof("65535") - 1)
>> > > > #endif
>> > > >
>> > > > And -ffreestanding breaks that. I see two solutions:
>> > > >
>> > > > (1) Add __STDINT_EXP to gcc's stdint-gcc.h
>> > > > (2) Switch that #if to something else
>> > > >
>> > > > I think something like this is an OK substitute works equivalently:
>> > > >
>> > > > #if __SIZEOF_INT__ > 2
>> > >
>> > > or even __SIZEOF_INT__ >= 4 to be extra *extra* paranoid, but yeah,
>> > > sure, go ahead.  The commmit message should just briefly explain the
>> > > freestanding implementation issue.
>> >
>> > Patch posted. Hopefully the commit message is clear enough.
>> >
>> > This one definitely is in the land of subtle small things.
>> >
>> > Thanks for the feedback and push to look for a deeper explanation.
>> >
>> > --joel
>> >
>> > >
>> > > Corinna
>> >
>>
>>  Just to close out the details on this more-esoteric subject:
>> -ffreestanding is improper for using Newlib, so we don't need to account
>> for it in general.  (A freestanding implementation may only use a subset
>> of
>> the library, and stdint.h is not one of that list--which in C11 is
>> <float.h>, <iso646.h>, <limits.h>, <stdalign.h>, <stdarg.h>, <stdbool.h>,
>> <stddef.h>, <stdint.h>,and <stdnoreturn.h>.)
>
>
> You have stdint.h in the allowed list. :)
>
>
Oops, typo, sorry about that:  signal.h is not in the list.
OK, granted, a subset being used for that special purpose with freestanding
then does need to support that, so knowing that list I had included becomes
of more interest.
(The references for it are the C standard section 4, or several paragraphs
in the GCC manuals-search for freestanding.)

So the original is fine, but
>> so is the tweak.
>>
>
> Better to avoid any dependency on something newlib specific in favor of
> something gcc provides.
>
> FWIW the freestanding option is used to compile the FreeBSD kernel code
> RTEMS uses for tcpip, USB, etc. We are currently using about 4000 files
> from them between the kernel and commands. I don't know the origin of using
> that compile option but do know the FreeBSD kernel is guilty of using names
> like malloc with different signatures.
>
> --joel
>
> Craig
>>
>
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.