Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Oct 2002 22:23:07 -0400
From:      Craig Rodrigues <rodrigc@attbi.com>
To:        freebsd-standards@freebsd.org
Cc:        freebsd-hackers@freebsd.org
Subject:   Problem detecting POSIX symbolic constants
Message-ID:  <20021009222307.A9894@attbi.com>

next in thread | raw e-mail | index | archive | help
Hi,

Earlier this year on the FreeBSD hackers mailing list:
http://docs.freebsd.org/cgi/getmsg.cgi?fetch=278142+0+/usr/local/www/db/text/2002/freebsd-hackers/20020317.freebsd-hackers

I was advised by Terry Lambert to use:
#ifdef _POSIX_REALTIME_SIGNALS

to detect if sigqueue(), sigtimedwait, sigwaitinfo() were defined.

I made this change to the FreeBSD configuration for ACE, a C++
library used for systems programming ( http://www.cs.wustl.edu/~schmidt/ACE.html ).

The change I made worked fine in -STABLE.
However, in -CURRENT, this test breaks, because _POSIX_REALTIME_SIGNALS
is defined, but it is -1.

According to the letter of the law:
http://www.opengroup.org/onlinepubs/007904975/basedefs/xbd_chap02.html

"The following symbolic constants shall either be undefined or defined
 with a value other than -1."

So, this is legal way to implement these macros.  It just breaks my code. :)

Can I appeal to the freebsd-standards team to leave these macros undefined
instead of defining them to -1?  #ifdef/#ifndef is a pretty common way
to detect if a feature is available on a system, especially when used
in conjunction with something like autoconf.

If that is not an option, then what is the correct way for me to write
my code?  Keep in mind that code in ACE must be very portable, and work
on platforms which may not adhere 100% to the letter of the POSIX law.
Unfortunately ACE does not use autoconf, so these configurations need to
be hardcoded.  Here is my code, from config-freebsd-pthread.h from 
ACE:

    210 #include <unistd.h>
    211 #include <signal.h>
    212 /* POSIX Realtime signals are not fully implemented in FreeBSD.
    213    When they are implemented, then _POSIX_REALTIME_SIGNALS will be
    214    defined, as specified in the POSIX standard.
    215    Refer to e-mail thread on freebsd-hackers mailing list, March 2002. */
    216 #ifdef _POSIX_REALTIME_SIGNALS
    217 #    define ACE_HAS_AIO_CALLS
    218 #    ifndef SIGRTMIN
    219 #       define SIGRTMIN 32
    220 #    endif /* SIGRTMIN */
    221 #    ifndef SIGRTMAX
    222 #       define SIGRTMAX (_SIG_MAXSIG - 1)
    223 #    endif /* SIGRTMAX */
    224 #endif  /* _POSIX_REALTIME_SIGNALS */



Thanks.

-- 
Craig Rodrigues        
http://www.gis.net/~craigr    
rodrigc@attbi.com

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?20021009222307.A9894>