Date: Thu, 10 Oct 2002 21:31:56 +1000 (EST) From: Bruce Evans <bde@zeta.org.au> To: Craig Rodrigues <rodrigc@attbi.com> Cc: freebsd-standards@FreeBSD.ORG, <freebsd-hackers@FreeBSD.ORG> Subject: Re: Problem detecting POSIX symbolic constants Message-ID: <20021010205529.M8598-100000@gamplex.bde.org> In-Reply-To: <20021009232056.A10429@attbi.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 9 Oct 2002, Craig Rodrigues wrote: > On Wed, Oct 09, 2002 at 07:29:48PM -0700, Terry Lambert wrote: > > To be totally correct, you will need to: > > > > #ifdef _POSIX_REALTIME_SIGNALS > > #if (_POSIX_REALTIME_SIGNALS != -1) > > > > ... > > > > #endif > > #endif > > > > It's annoying, but doing this will ensure that there are no > > gaps through which some system other than FreeBSD might fall. In Standard C, this is equivalent to the non-verbose version: #if _POSIX_REALTIME_SIGNALS != -1 ... #endif since if _POSIX_REALTIME_SIGNALS is not defined then it is equivalent to 0 in cpp expressions. The problem cases are if _POSIX_REALTIME_SIGNALS is defined to <empty> or <garbage>, but these are not permitted in POSIX.1-2001. These cases were permitted for many feature test macros in POSIX.1-1990. > Sigh. Why did the POSIX guys do this? :( Perhaps because they wanted you to use sysconf() instead of these mistakes. Actually, they didn't do this. _POSIX_REALTIME_SIGNALS is specified to have value 0, -1 or 200xxxL (draft 7 says xxx; I think the final standard says 112). > BTW, I think that: > #if defined(_POSIX_REALTIME_SIGNALS) && (_POSIX_REALTIME_SIGNALS != -1 ) > > should suffice, but I'll double-check with one of my portability gurus > to see if that is OK for ACE. This is variant of the above verbose version. It requires slightly more modern compilers, so it might fail for some 20-year old pre-Standard C compilers instead of only for some 25-year old ones. > I have another request. Even though my preprocessor check was bogus, > ACE still compiled, and I did not discover that there were any problems > until link time, ie. I had a libACE.so library which could not > link with anything because of unresolved symbols. This was very annoying. > It would have been nicer if this could have been caught earlier in the > compile stage. > Since sigqueue(), sigwait(), sigwaitinfo() are not implemented in FreeBSD, > is this patch OK? > > --- src/include/signal.h.orig Wed Oct 9 23:15:21 2002 > +++ src/include/signal.h Wed Oct 9 23:15:31 2002 > @@ -76,13 +76,6 @@ > int sigwait(const sigset_t *, int *); > #endif > > -#if __BSD_VISIBLE || __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 600 > -int sigqueue(__pid_t, int, const union sigval); > -int sigtimedwait(const sigset_t * __restrict, siginfo_t * __restrict, > - const struct timespec * __restrict); > -int sigwaitinfo(const sigset_t * __restrict, siginfo_t * __restrict); > -#endif > - > #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE > int killpg(__pid_t, int); > int sigaltstack(const stack_t * __restrict, stack_t * __restrict); > > At some point in the future when POSIX RT signals are implemented > in FreeBSD (I'm not volunteering :), then > _POSIX_REALTIME_SIGNALS can be defined to 200112L in unistd.h, and > these three prototypes can be put back into <signal.h>. > > Is this OK? I used a variant your patch for this in PR 35924 until recently when I noticed that it usually worked for the bogus reason that <unistd.h> is not included, then _POSIX_REALTIME_SIGNALS is only defined accidentally (to whatever value). I now use just #if 0 and an XXX comment as a reminder to fix this someday: %%% Index: signal.h =================================================================== RCS file: /home/ncvs/src/include/signal.h,v retrieving revision 1.19 diff -u -2 -r1.19 signal.h --- signal.h 6 Oct 2002 21:54:08 -0000 1.19 +++ signal.h 7 Oct 2002 07:06:19 -0000 @@ -78,9 +79,18 @@ #if __BSD_VISIBLE || __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 600 +#if 0 +/* + * PR: 35924 + * XXX we don't actually have these. We set _POSIX_REALTIME_SIGNALS to + * -1 to show that we don't have them, but this symbol is not necessarily + * in scope (in the current implementation), so we can't use it here. + */ int sigqueue(__pid_t, int, const union sigval); +struct timespec; int sigtimedwait(const sigset_t * __restrict, siginfo_t * __restrict, const struct timespec * __restrict); int sigwaitinfo(const sigset_t * __restrict, siginfo_t * __restrict); #endif +#endif #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE %%% The patch also moves the forward declaration of struct timespec near to the one place that it is used (related patches not included). This mainly makes it obvious that the messy visibility for it is the same as the one for the function that uses it. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021010205529.M8598-100000>