1998-07-16 20:08:44 +00:00
|
|
|
Conformance of the GNU libc with various standards
|
|
|
|
==================================================
|
|
|
|
|
|
|
|
The GNU libc is designed to be conformant with existing standard as
|
1999-01-24 11:09:07 +00:00
|
|
|
far as possible. To ensure this I've run various tests. The results
|
1998-07-16 20:08:44 +00:00
|
|
|
are presented here.
|
|
|
|
|
|
|
|
|
|
|
|
Open Group's hdrchk
|
2000-08-16 02:05:38 +00:00
|
|
|
===================
|
1998-07-16 20:08:44 +00:00
|
|
|
|
|
|
|
The hdrchk test suite is available from the Open Group at
|
|
|
|
|
|
|
|
ftp://ftp.rdg.opengroup.org/pub/unsupported/stdtools/hdrchk/
|
|
|
|
|
2000-08-14 04:57:27 +00:00
|
|
|
I've last run the suite on 2000-08-13 on a Linux/ix86 system with the
|
1998-07-16 20:08:44 +00:00
|
|
|
following results [*]:
|
|
|
|
|
|
|
|
FIPS No reported problems
|
|
|
|
|
|
|
|
POSIX90 No reported problems
|
|
|
|
|
|
|
|
XPG3 No reported problems
|
|
|
|
|
2000-08-14 04:57:27 +00:00
|
|
|
XPG4 No reported problems
|
1998-07-16 20:08:44 +00:00
|
|
|
|
2000-08-14 04:57:27 +00:00
|
|
|
POSIX96 Same as for UNIX98 (see below).
|
|
|
|
UNIX98 The message queue implementation is missing:
|
1998-07-16 20:08:44 +00:00
|
|
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
2000-08-14 04:57:27 +00:00
|
|
|
/****** <mqueue.h> - Missing include file ******/
|
|
|
|
/****** Start of Definitions for file mqueue.h ******/
|
|
|
|
extern int mq_close();
|
|
|
|
extern int mq_getattr();
|
|
|
|
extern int mq_notify();
|
|
|
|
extern mqd_t mq_open();
|
|
|
|
extern ssize_t mq_receive();
|
|
|
|
extern int mq_send();
|
|
|
|
extern int mq_setattr();
|
|
|
|
extern int mq_unlink();
|
|
|
|
typedef <type> mqd_t;
|
|
|
|
struct mq_attr { <members> };
|
|
|
|
struct sigevent { <members> };
|
|
|
|
/****** End of Definitions for file mqueue.h ******/
|
1998-07-16 20:08:44 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
[*] Since the scripts are not clever enough for the way gcc handles
|
|
|
|
include files (namely, putting some of them in gcc-local directory) I
|
|
|
|
copied over the iso646.h, float.h, and stddef.h headers and ignored the
|
|
|
|
problems resulting from the splitted limits.h file).
|
2000-08-16 02:05:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
Technical C standards conformance issues in glibc
|
|
|
|
=================================================
|
|
|
|
|
|
|
|
If you compile programs against glibc with __STRICT_ANSI__ defined
|
|
|
|
(as, for example, by gcc -ansi, gcc -std=c89, gcc -std=iso1990:199409
|
|
|
|
or gcc -std=c99), and use only the headers specified by the version of
|
|
|
|
the C standard chosen, glibc will attempt to conform to that version
|
|
|
|
of the C standard (as indicated by __STDC_VERSION__):
|
|
|
|
|
|
|
|
GCC options Standard version
|
|
|
|
-ansi ISO/IEC 9899:1990
|
|
|
|
-std=c89 ISO/IEC 9899:1990
|
2000-10-09 15:37:39 +00:00
|
|
|
-std=iso9899:199409 ISO/IEC 9899:1990 as amended by Amd.1:1995 *
|
2000-08-16 02:05:38 +00:00
|
|
|
-std=c99 ISO/IEC 9899:1999
|
|
|
|
|
2000-10-09 15:37:39 +00:00
|
|
|
* glibc does not support this standard version.
|
|
|
|
|
2000-08-16 02:05:38 +00:00
|
|
|
(Note that -std=c99 is not available in GCC 2.95.2, and that no
|
|
|
|
version of GCC presently existing implements the full C99 standard.)
|
|
|
|
|
|
|
|
You may then define additional feature test macros to enable the
|
|
|
|
features from other standards, and use the headers defined in those
|
|
|
|
standards (for example, defining _POSIX_C_SOURCE to be 199506L to
|
|
|
|
enable features from ISO/IEC 9945-1:1996).
|
|
|
|
|
|
|
|
There are some technical ways in which glibc is known not to conform
|
|
|
|
to the supported versions of the C standard, as detailed below. Some
|
|
|
|
of these relate to defects in the standard that are expected to be
|
|
|
|
fixed, or to compiler limitations.
|
|
|
|
|
|
|
|
|
|
|
|
Defects in the C99 standard
|
|
|
|
===========================
|
|
|
|
|
2003-12-31 23:53:18 +00:00
|
|
|
Some defects in C99 were corrected in Technical Corrigendum 1 to that
|
|
|
|
standard. glibc follows the corrected specification.
|
2000-08-16 02:05:38 +00:00
|
|
|
|
|
|
|
|
|
|
|
Implementation of library functions
|
|
|
|
===================================
|
|
|
|
|
|
|
|
The implementation of some library functions does not fully follow the
|
|
|
|
standard specification:
|
|
|
|
|
|
|
|
C99 added additional forms of floating point constants (hexadecimal
|
|
|
|
constants, NaNs and infinities) to be recognised by strtod() and
|
|
|
|
scanf(). The effect is to change the behavior of some strictly
|
|
|
|
conforming C90 programs; glibc implements the C99 versions only
|
|
|
|
irrespective of the standard version selected.
|
|
|
|
|
|
|
|
C99 added %a as another scanf format specifier for floating point
|
|
|
|
values. This conflicts with the glibc extension where %as, %a[ and
|
|
|
|
%aS mean to allocate the string for the data read. A strictly
|
|
|
|
conforming C99 program using %as, %a[ or %aS in a scanf format string
|
|
|
|
will misbehave under glibc.
|
|
|
|
|
|
|
|
|
|
|
|
Compiler limitations
|
|
|
|
====================
|
|
|
|
|
|
|
|
The macros __STDC_IEC_559__, __STDC_IEC_559_COMPLEX__ and
|
|
|
|
__STDC_ISO_10646__ are properly supposed to be defined by the
|
|
|
|
compiler, and to be constant throughout the translation unit (before
|
|
|
|
and after any library headers are included). However, they mainly
|
|
|
|
relate to library features, and the necessary magic has yet to be
|
|
|
|
implemented for GCC to predefine them to the correct values for the
|
|
|
|
library in use, so glibc defines them in <features.h>. Programs that
|
|
|
|
test them before including any standard headers may misbehave.
|
|
|
|
|
|
|
|
GCC doesn't support the optional imaginary types. Nor does it
|
2000-10-09 15:37:39 +00:00
|
|
|
understand the keyword _Complex before GCC 3.0. This has the
|
|
|
|
corresponding impact on the relevant headers.
|
2000-08-16 02:05:38 +00:00
|
|
|
|
|
|
|
glibc's use of extern inline conflicts with C99: in C99, extern inline
|
|
|
|
means that an external definition is generated as well as possibly an
|
|
|
|
inline definition, but in GCC it means that no external definition is
|
|
|
|
generated. When GCC's C99 mode implements C99 inline semantics, this
|
|
|
|
will break the uses of extern inline in glibc's headers. (Actually,
|
|
|
|
glibc uses `extern __inline', which is beyond the scope of the
|
|
|
|
standard, but it would clearly be very confusing for `__inline' and
|
|
|
|
plain `inline' to have different meanings in C99 mode.)
|
|
|
|
|
|
|
|
glibc's <tgmath.h> implementation is arcane but thought to work
|
|
|
|
correctly; a clean and comprehensible version requires compiler
|
|
|
|
builtins.
|
|
|
|
|
|
|
|
For most of the headers required of freestanding implementations,
|
|
|
|
glibc relies on GCC to provide correct versions. (At present, glibc
|
2003-12-31 23:53:18 +00:00
|
|
|
provides <stdint.h>, and GCC doesn't.)
|
2000-08-16 02:05:38 +00:00
|
|
|
|
|
|
|
Implementing MATH_ERRNO, MATH_ERREXCEPT and math_errhandling in
|
|
|
|
<math.h> needs compiler support: see
|
|
|
|
|
|
|
|
http://sources.redhat.com/ml/libc-hacker/2000-06/msg00008.html
|
|
|
|
http://sources.redhat.com/ml/libc-hacker/2000-06/msg00014.html
|
|
|
|
http://sources.redhat.com/ml/libc-hacker/2000-06/msg00015.html
|
|
|
|
|
|
|
|
|
|
|
|
Issues with headers
|
|
|
|
===================
|
|
|
|
|
|
|
|
There are various technical issues with the definitions contained in
|
2003-12-31 23:53:18 +00:00
|
|
|
glibc's headers, listed below. The list below assumes GCC 3.3.2, and
|
|
|
|
relates to i686-linux; older GCC may lead to more problems in the
|
|
|
|
headers.
|
2000-10-09 15:37:39 +00:00
|
|
|
|
|
|
|
Note that the _t suffix is reserved by POSIX, but not by pure ISO C.
|
2001-01-11 17:50:24 +00:00
|
|
|
Also, the Single Unix Specification generally requires more types to
|
2000-10-09 15:37:39 +00:00
|
|
|
be included in headers (if _XOPEN_SOURCE is defined appropriately)
|
|
|
|
than ISO C permits.
|
|
|
|
|
|
|
|
<ctype.h> should not declare size_t.
|
|
|
|
|
|
|
|
<signal.h> should not declare size_t.
|
|
|
|
|
2001-01-11 17:24:47 +00:00
|
|
|
<stdio.h> should not declare or use wchar_t or wint_t.
|
2000-10-09 15:37:39 +00:00
|
|
|
|
|
|
|
<wchar.h> does not support AMD1; to support it, the functions
|
|
|
|
fwprintf, fwscanf, wprintf, wscanf, swprintf, swscanf, vfwprintf,
|
|
|
|
vwprintf, vswprintf and fwide would need to be declared when
|
|
|
|
__STDC_VERSION__ >= 199409L and not just for C99.
|
2000-08-16 02:05:38 +00:00
|
|
|
|
2000-10-09 15:37:39 +00:00
|
|
|
<wctype.h> should not declare size_t.
|