Boost logo

Boost :

From: Boris Gubenko (Boris.Gubenko_at_[hidden])
Date: 2007-11-15 00:26:00


Ion Gaztanaga wrote:
> Ok, I see. Detecting POSIX conformance is really a nightmare ;-) I think
> I should just check for _POSIX_SHARED_MEMORY_OBJECTS, because I don't
> want to miss native shared memory for systems that support it.

As far as I can see, Interprocess library uses the following _POSIX_*
feature test macros:

_POSIX_BARRIERS
_POSIX_SEMAPHORES
_POSIX_SHARED_MEMORY_OBJECTS
_POSIX_THREAD_PROCESS_SHARED
_POSIX_TIMEOUTS

In theory, a check for these macros should be accompanied by the check
of the value of _XOPEN_SOURCE feature test macro because different
releases of X/Open Specs define these _POSIX_* feature test macros
differently. Using _POSIX_SHARED_MEMORY_OBJECTS as an example, I'd
suggest the following check:

#if defined(_POSIX_SHARED_MEMORY_OBJECTS)
# if !((_XOPEN_SOURCE >= 600) && (_POSIX_SHARED_MEMORY_OBJECTS - 0 <= 0))
# define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
# endif
#endif

I verified that the check above works in a default compilation on Linux,
Tru64 and HP-UX, i.e. BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS macro
gets defined.

VMS supports shared memory objects but it does not define
_POSIX_SHARED_MEMORY_OBJECTS macro, so you can define
BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS on VMS as the following
(70200000 is the first version of libc on VMS having shm_*() functions):

#if defined(__vms)
# if __CRTL_VER >= 70200000
# define BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
# endif
#endif

Currently, VMS does not support other _POSIX_* features used by the
Interprocess library, so, BOOST_INTERPROCESS_POSIX_SHARED_MEMORY_OBJECTS
should be the only macro defined on this platform.

> I suppose I have the same problem for other posix features like
> _POSIX_THREAD_PROCESS_SHARED. So if I understand it correctly, checking
> only for the existence of option macros should be enough if I want to
> support SUSV2 systems, right?

Right, but, I think, you also want to support XPG6 systems where the
feature test macro can be defined with a value of -1 or 0. The check
above takes it into account.

Thanks,
  Boris


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk