public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: Matthew Joyce <mfjoyce2004@gmail.com>
To: Newlib <newlib@sourceware.org>, Joel Sherrill <joel@rtems.org>,
	 Matt Joyce <mfjoyce2004@gmail.com>
Subject: Re: [PATCH 1/1] libc: Added implementations and prototypes for
Date: Thu, 22 Jul 2021 07:14:34 +0200	[thread overview]
Message-ID: <CALo2L3MqT7wKo=48FYkR8Q6tJAUrV2X2TaM=crPv3FfuifPs5Q@mail.gmail.com> (raw)
In-Reply-To: <YPWMtGnhbibkG9Ym@calimero.vinschen.de>

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)
#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)

At first I thought it might be a problem with using 'sizeof' in the
definition. But I get the same error even if I hard-code the define
values after #if  __STDINT_EXP....

Could you please advise on what I might be doing wrong? Completely
hard coding the value as 16 (the length of the larger string) works
without error.

Thank you very much for your time!

Sincerely,

Matt

On Mon, Jul 19, 2021 at 4:31 PM Corinna Vinschen <vinschen@redhat.com> wrote:
>
> On Jul 19 08:19, Joel Sherrill wrote:
> > On Mon, Jul 19, 2021 at 4:48 AM Corinna Vinschen <vinschen@redhat.com> wrote:
> > > #if __STDINT_EXP(INT_MAX) > 0x7fff
> > > #define SIG2STR_MAX (sizeof ("RTMAX+") + sizeof ("4294967295") - 1)
> > > #else
> > > #define SIG2STR_MAX (sizeof ("RTMAX+") + sizeof ("65535") - 1)
> > > #endif
> >
> > Just checking here about the terminating NUL. The sizeof("RTMAX+") includes
> > a NUL so the -1 at the end of the expression subtracts the one from the
> > sizeof("NUM"). Is that right?
> >
> > An off by one error here would be hard to catch if it slipped through.
>
> Writing a simple test program and attaching it to the patchset would be a
> good idea anyway.
>
> > > This is not entirely correct.  The POSIX draft requires the signal
> > > string to be returned for RT signals to be expressed as either "RTMIN+x"
> > > and "RTMAX-x", dependent on the signal number.  Please see
> > > https://www.opengroup.org/austin/docs/austin_1110.pdf, page 85, the two
> > > paragraphs starting at line 61678 (unfortunately copy/paste from this
> > > doc doesn't work nicely).
> >
> > He implemented it this way initially but it looks like I optimistically misread
> > "the paragraph at line 61681 which gives an option on how to do the upper
> > half of the RT signals and thought/hoped it let the code have to produce
> > one format. But reading it again, there is a clear qualifier:
> >
> > "If signum is between (SIGRTMIN+SIGRTMAX)/2 + 1 and SIGRTMAX−1
> > inclusive, ..."
>
> But then again...
>
> ...on rereading the text it appears the intention was to allow both ways
> of expressing the signal, whichever is preferred by the implementation.
>
> Checking gnulib, they use RTMAX-x for the upper half of the range.
>
> The Oracle website expresses it in terms of 8 RT sigs and claims
>
>   For access to the signals in the range SIGRTMIN to SIGRTMAX, the
>   first four signals match the strings "RTMIN", "RTMIN+1", "RTMIN+2",
>   and "RTMIN+3" and the last four match the strings "RTMAX-3",
>   "RTMAX-2", "RTMAX-1", and "RTMAX".
>
> So it looks like there's some kind of consensus to do it that way.
> I guess we should follow suit.
>
> > > We have a special problem here.  i686 Cygwin only supports a single RT
> > > signal.  For historical reasons, don't ask.
> > >
> > > I. e., SIGRTMIN == SIGRTMAX.  This special case should be checked here,
> > > to make sure the code works with this very special, very non-POSIX
> > > behaviour.  I think the easiest way to handle that is to skip the
> > > entire "RTMIN+"/"RTMAX-" code if SIGRTMIN == SIGRTMAX.  There just is
> > > no such valid value in this case.
> >
> > Do I interpret this as adding a conditionally compiled block to handle the
> > special case when SIGRTMIN == SIGRTMAX?
>
> Just skip the RT sigs handling code block.
>
> > Is it possible for a target OS not to define any real-time signals?
>
> For bare-metal and embedded targets it's probably a good idea to assume
> just that.  Per POSIX, 4 RT sigs are required, but that's often no
> concern for small targets, and for i686 Cygwin we simply screwed up.
>
>
> Corinna
>

  parent reply	other threads:[~2021-07-22  5:14 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-17 10:10 [PATCH 0/1] Implementation of sig2str/str2sig Matt Joyce
2021-07-17 10:10 ` [PATCH 1/1] libc: Added implementations and prototypes for Matt Joyce
2021-07-19  9:47   ` Corinna Vinschen
2021-07-19 13:19     ` Joel Sherrill
2021-07-19 14:31       ` Corinna Vinschen
2021-07-20  5:11         ` Matthew Joyce
2021-07-22  5:14         ` Matthew Joyce [this message]
2021-07-22  7:55           ` Corinna Vinschen
2021-07-23  5:44             ` Matthew Joyce
2021-07-28  8:44               ` Corinna Vinschen
2021-07-24  8:37 [PATCH 0/1] V2 Implementation of sig2str/str2sig Matt Joyce
2021-07-24  8:37 ` [PATCH 1/1] libc: Added implementations and prototypes for Matt Joyce
2021-07-28  9:11   ` Corinna Vinschen
2021-07-28 15:25     ` Brian Inglis
2021-07-28 18:46       ` Corinna Vinschen
2021-07-28 19:42         ` Joel Sherrill
     [not found]           ` <DM3P110MB0522CE441CAB289B69DE18B49AEA9@DM3P110MB0522.NAMP110.PROD.OUTLOOK.COM>
2021-07-28 19:54             ` Fw: " C Howland
2021-07-28 20:13               ` Joel Sherrill
2021-07-29  9:23                 ` Corinna Vinschen
2021-07-29 15:29                   ` Brian Inglis
2021-07-29 15:45                     ` Corinna Vinschen
2021-07-29 15:29                   ` Brian Inglis
2021-07-29  2:51         ` Brian Inglis
2021-07-28 18:40     ` Corinna Vinschen
2021-07-29  4:59       ` Matthew Joyce
2021-07-29  9:27         ` Corinna Vinschen
2021-07-29 14:41     ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CALo2L3MqT7wKo=48FYkR8Q6tJAUrV2X2TaM=crPv3FfuifPs5Q@mail.gmail.com' \
    --to=mfjoyce2004@gmail.com \
    --cc=joel@rtems.org \
    --cc=newlib@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).