From owner-freebsd-hackers Thu Oct 10 4:21:58 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 22D9B37B401; Thu, 10 Oct 2002 04:21:55 -0700 (PDT) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id CF9F143E9E; Thu, 10 Oct 2002 04:21:53 -0700 (PDT) (envelope-from bde@zeta.org.au) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id VAA08746; Thu, 10 Oct 2002 21:21:47 +1000 Date: Thu, 10 Oct 2002 21:31:56 +1000 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Craig Rodrigues Cc: freebsd-standards@FreeBSD.ORG, Subject: Re: Problem detecting POSIX symbolic constants In-Reply-To: <20021009232056.A10429@attbi.com> Message-ID: <20021010205529.M8598-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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 or , 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 . > > 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 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