PATCH: Add tgmath.h

Matt Austern austern@apple.com
Sun Aug 15 08:41:00 GMT 2004


On Aug 14, 2004, at 9:24 PM, Gabriel Dos Reis wrote:

> Geoff Keating <geoffk@geoffk.org> writes:
>
> [...]
>
> | I don't believe the current situation is the result of a conscious
> | decision to not provide particular headers simply because they are 
> not
> | part of a freestanding implementation.  Indeed, the documentation 
> says
> | that
> |
> | > GCC aims towards being usable as a conforming freestanding
> | > implementation, or as the compiler for a conforming hosted
> | > implementation.
> |
> | and as the compiler for a conforming implementation, it is properly
> | responsible for certain compiler-specific header files, like 
> tgmath.h.
>
> I guess I disagree with the assertion that the current situation is
> not a conscious decision. It has always been the case that, for hosted
> implementations, GCC explicitly expects the target to provide a C
> library implementation. Only in few occasions do we provide our own
> headers -- and they mostly derive from fixincludes or are required
> for freestandaning implementation.

My feeling is that hosted vs freestanding is the wrong distinction.
Yes, obviously we need to provide all the headers that are required
for a freestanding implementation.  But we also need to provide
headers that a compiler-neutral C library implementation can't
reasonably provide on its own.

At present, I believe the only such header is tgmath.h.  There just
isn't any way to write it in portable C; it requires compiler magic.
It tells the compiler to use Fortran-like overload resolution rules
when processing certain kinds of function calls, instead of normal
C.  It just doesn't make sense to expect that a C library, written in
isolation from a compiler and intended to work with multiple
compilers, should do that.

I simply see no advantage to our saying that providing tgmath.h
is the OS vendors' responsibility.  The practical consequence of
that will be that lots of OSs won't provide one at all, that others
will provide a tgmath that's unusable with gcc, and that still others
will provide poor implementations that don't use gcc extensions
as well as they might.

(And if this sounds like a messy distinction, instead of the simple
hosted-vs-freestanding criterion---well, that's because it is.  The
C standard has some features that can't be classified cleanly as
compiler or library.  This is one of them.)

			--Matt



More information about the Gcc-patches mailing list