[PATCH 1/1] libc: Added implementations and prototypes for
Corinna Vinschen
vinschen@redhat.com
Wed Jul 28 18:40:42 GMT 2021
On Jul 28 11:11, Corinna Vinschen wrote:
> Hi Matt,
>
> thanks for this v2.
>
> On Jul 24 10:37, Matt Joyce wrote:
> > Added implementations for sig2str() and str2sig() in libc/signal in order
> > to improve POSIX compliance. Added function prototypes to sys/signal.h.
> > Added Makefile.am entries to build the new file.
> > ---
> > [...]
> > +#if __GNU_VISIBLE
>
> I think this needs discussion. The sig2str/str2sig API has not been
> provided yet by GLibC. Using __GNU_VISIBLE in this context looks wrong.
> What we need, in fact, is a __POSIX_VISIBLE guard, but here's the
> problem: As far as I can see, the Issue 8 draft does not yet define a
> version number.
>
> If anybody has better information or a good idea how to guard this new
> API in the meantime, I'm all ears.
>
> >
> > include $(srcdir)/../../Makefile.shared
> >
> > -CHEWOUT_FILES = psignal.def raise.def signal.def
> > +CHEWOUT_FILES = psignal.def raise.def signal.def sig2str.def
>
> If you add this, you also have to provide a header allowing to create
> a man page. See, for instance, newlib/signal/raise.c.
>
> > +int
> > +sig2str(int signum, char *str)
> > [...]
> > + /* If signum is not a recognized signal number, store this message in str. */
> > + sprintf(str, "Unknown signal");
>
> Just drop this sprintf, as I just wrote in my other mail. There's no
> expectation that the incoming buffer gets changed if the function
> returns with error.
Additionally, there's a RATIONALE section in the draft, which describes
how "historical versions of these functions translated a signum value 0
to "EXIT" (and vice versa), so that they could be used by the shell for
the trap utility."
While this isn't going to become part of the standard, I wonder if we
should follow suite, for maximum compatibility.
Corinna
More information about the Newlib
mailing list