From owner-freebsd-hackers Tue Mar 12 13:33:56 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from harrier.prod.itd.earthlink.net (harrier.mail.pas.earthlink.net [207.217.120.12]) by hub.freebsd.org (Postfix) with ESMTP id A844C37B405 for ; Tue, 12 Mar 2002 13:33:52 -0800 (PST) Received: from pool0291.cvx40-bradley.dialup.earthlink.net ([216.244.43.36] helo=mindspring.com) by harrier.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16ktu2-00033c-00; Tue, 12 Mar 2002 13:33:50 -0800 Message-ID: <3C8E742C.7C2E63B8@mindspring.com> Date: Tue, 12 Mar 2002 13:33:32 -0800 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Craig Rodrigues Cc: freebsd-hackers@freebsd.org Subject: Re: How to correctly detect POSIX 1003.1b features on FreeBSD? References: <20020312140904.A799@bbn.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 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 , 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