This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Use of _XOPEN_SOURCE?


For the XSI extensions that POSIX.1 adds to what the C standard
requires,
POSIX requires that they are gated by an appropriate definition of
_XOPEN_SOURCE.  See
http://www.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#
tag_15_02
 
For an example of where it is required, see
http://www.opengroup.org/onlinepubs/9699919799/basedefs/math.h.html,
where the symbolic constants M_E, M_PI, etc., are marked as XSI
extensions.
 
In summary, the XSI extension stuff is only to be made visible in the
headers if _XOPEN_SOURCE has been defined by the user before the header
has been included.  The value of it matters, depending upon the version
of POSIX.1 being examined.  (e.g. 2008 requires the value 700, while
2004 requires 600.)  So in math.h, it might look something like:

#if defined(_XOPEN_SOURCE) && _XOPEN_SOURCE > 0
  #define M_E	2.71828182845904523536028
  ...
#endif
 
Newlib presently does not really attempt to do this at all.  (Only
libc/include/grp.h and libc/sys/linux/include/netinet6/in6.h have
_XOPEN_SOURCE in them (no .c files at all).)
 
Two questions arise.  (I'm working on a cleanup of math.h, and to
be the cleanest this would need to be done, which is why it has come
up.)
 
1)  Should we even consider adding _XOPEN_SOURCE gates?  (Doing so
could cause things to break for people, unless we were to also define
_XOPEN_SOURCE by default in some place like config.h or newlib.h.
But then that would defeat the intention of the POSIX requirement
that the user define _XOPEN_SOURCE to get the extensions.)
 
2)  What value would we want to look for?  (Is my example above the
right way?  Or would we attempt to tie ourselves to a single version
like POSIX.1-2008 and use fixed 700?  etc.)
 
Craig


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]