This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Defining C99 predefined macros for whole translation unit


This pair of patches, to GCC and glibc, together fix the issue that
the predefined macros __STDC_IEC_559__, __STDC_IEC_559_COMPLEX__ and
__STDC_ISO_10646__ should be constant throughout the translation unit,
rather than being undefined before any system headers are included and
defined only after a system header has been included.  This is an area
where the compiler and library need to cooperate the implement the
correct semantics for the implementation as a whole; it's not suitable
for GCC to hardcode the definitions of the macros because they may
depend on the library version (especially __STDC_ISO_10646__).

The approach chosen is one I've previously mentioned: glibc provides a
header <stdc-predef.h>, split out of <features.h>, with just these
definitions, and GCC preincludes this header if it exists, while
silently ignoring its nonexistence so it continues to work with older
glibc; glibc includes the header from <features.h> so the macros will
still be defined after the first system header inclusion when building
with an older GCC.  The glibc patch updates the CONFORMANCE file
regarding this and other issues mentioned therein.

I strongly suspect that the value of __STDC_ISO_10646__ in glibc is
out of date (the comment says Unicode 3.1 and the value is 200009L,
but there have been subsequent changes updating glibc to Unicode 5).
Updating this (in features.h before this patch or stdc-predef.h after
it) is clearly independent of this patch.

This header could also be used to implement something like the
predefined macros proposed in N1348
<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1348.htm> (I wasn't
at the Markham meeting so don't know what the WG14 reaction to that
was), where macros would be defined to say what standard headers are
available, and would allow the decimal floating-point work to address
the issue of not defining __STDC_DEC_FP__ (the DFP library would
provide its own version of stdc-predef.h that defines that macro).

The patches can be used independently in that new GCC will work with
old glibc and old GCC will work with new glibc, but the GCC patch is
useless without the glibc patch and GCC needs to know the name of the
header in glibc and the GCC testcase needs to know the version in
which the header was added, so I don't propose to commit the GCC patch
without some form of the glibc patch being committed first.  If the
patches go in I'll update c99status.html accordingly as a followup.

(The GCC patch has been bootstrapped with no regressions on
i686-pc-linux-gnu and I've also verified that glibc builds and passes
its tests with the glibc patch applied.)

-- 
Joseph S. Myers
joseph@codesourcery.com

Attachment: c99-preinc-gcc
Description: Text document

Attachment: c99-preinc-glibc
Description: Text document


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