Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Mar 2002 13:33:32 -0800
From:      Terry Lambert <tlambert2@mindspring.com>
To:        Craig Rodrigues <crodrigu@bbn.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: How to correctly detect POSIX 1003.1b features on FreeBSD?
Message-ID:  <3C8E742C.7C2E63B8@mindspring.com>
References:  <20020312140904.A799@bbn.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Craig Rodrigues wrote:
> I am currently using FreeBSD 4.3, and am working with
> ACE, a cross-platform C++ library for doing systems
> programming (networking, threading, I/O, etc.).
> I am having problems with the configuration of ACE
> on FreeBSD, related to POSIX 1003.1b features.
> 
> Can someone tell me how a user can, at compile time, determine
> the presence or absence of POSIX 1003.1b features
> such as:
> 
> sigwaitinfo
> sigtimedwait
> sigqueue
> 
> Currently, I have some code that does:
> 
> #if (__FreeBSD_version > 440000)
> # define _P1003_1B_VISIBLE

You are not allowed to define this.  It is defined by the
system or not at all.  It is for use by programs to do
feature testing, not for you to define to cause interfaces
to be exposed that would not otherwise be exposed.


> This test is wrong, because it fails on FreeBSD 4.5.

Yes.  You are telling the header file that it should
expose prototypes for functions that aren't exposed.  The
result, although you do not post about it, will be an
undefined symbol error for each use of these routines.


> If I read the posix4(9) man page, it says that
> I need to check _POSIX_VERSION, _POSIX_C_SOURCE, and
> _POSIX_SOURCE macros to detect what POSIX features
> are available.

THat's *CHECK*, _not_ *SET*.  If something begins with an "_",
it's for you to check, not for you to set.


> #if (!defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)) || \
>  (_POSIX_VERSION  >= 199309L && defined(_POSIX_C_SOURCE) && \
>   _POSIX_C_SOURCE >= 199309L)
> #define _P1003_1B_VISIBLE
> #define _P1003_1B_VISIBLE_HISTORICALLY
> #endif

Yes.  You should *CHECK* _P1003_1B_VISIBLE to see if you should
use those interfaces:

#ifdef _P1003_1B_VISIBLE

	/* OK to use POSIX 1003 B functions */

#else	/* !_P1003_1B_VISIBLE */

	/*
	 * Have to figure out how to get the same effect some
	 * other way
	 */

#endif	/* !_P1003_1B_VISIBLE */


> Can I re-use this test to determine if I have the POSIX 1003.1b
> functions: sigwaitinfo, sigtimedwait, sigqueue available?
> 
> In <signal.h>, I see the following:
> 
> #ifdef _P1003_1B_VISIBLE
> 
> __BEGIN_DECLS
> int sigqueue __P((_BSD_PID_T_, int, const union sigval));
> int sigtimedwait __P((const sigset_t *, siginfo_t *, const struct timespec *));
> int sigwaitinfo __P((const sigset_t *, siginfo_t *));
> __END_DECLS
> 
> #endif

The only thing you are allowed to do is to use the same #ifdef
they are using before the prototype declarations to determine
in your own code if you can use these functions.  The manifest
constant is a feature-test macro.

-- Terry

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?3C8E742C.7C2E63B8>