[PATCH 1/1] libc: Added implementations and prototypes for
Matthew Joyce
mfjoyce2004@gmail.com
Fri Jul 23 05:44:01 GMT 2021
Hi Corinna,
Thanks again for the explanation! I think I had just failed to include stdint.h.
Now that it's working, I'd like to clarify: If SIG2STR_MAX is now 17,
this will impact the message "Unknown signal <signum>" in case the
signum isn't a valid, recognized signal number.
Is it better to change the error message (by taking out the <signum>
part) or make SIG2STR_MAX larger?
Thank you!
Sincerely,
Matt
On Thu, Jul 22, 2021 at 9:55 AM Corinna Vinschen <vinschen@redhat.com> wrote:
>
> Hi Matt,
>
> On Jul 22 07:14, Matthew Joyce wrote:
> > Hi Corinna,
> >
> > I've made the changes you recommended but I'm running into a problem
> > with the definition of SIG2STR_MAX. You suggested:
> >
> > #if __STDINT_EXP(INT_MAX) > 0x7fff
> > #define SIG2STR_MAX (sizeof ("RTMAX+") + sizeof ("4294967295") - 1)
> > #else #define SIG2STR_MAX (sizeof ("RTMAX+") + sizeof ("65535") - 1)
>
> These are actually two lines, right? It's just a copy/paste glitch,
> I guess.
>
> > #endif
> >
> > I've tried it both in newlib and natively but I get the error:
> > " missing binary operator before token '(' "
> > (In the first line of the block)
>
> I hacked a STC:
>
> ----------------------------------
> #include <stdio.h>
> #include <string.h>
> #include <stdint.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
>
> void
> foo (int sig, char *out)
> {
> char buf[SIG2STR_MAX];
>
> if (sig > SIG2STR_MAX)
> return;
> snprintf (buf, SIG2STR_MAX, "FOO+%d", sig);
> memcpy (out, buf, SIG2STR_MAX);
> }
> ----------------------------------
>
> $ gcc -g -O2 -c -Wall foo.c
>
> No error or warning is generated, so I'm puzzled about your problem.
>
> Would you mind to paste the affected code snippet and the full gcc error
> output?
>
>
> Corinna
>
More information about the Newlib
mailing list