This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: PATCH: Add tgmath.h



On 14/08/2004, at 6:01 PM, Joseph S. Myers wrote:


On Sat, 14 Aug 2004, Geoffrey Keating wrote:

In practise, though, the most common thing is that the system does not
provide one, because it expects the compiler to provide it.  Indeed, I
believe that the only library that does provide one which works for
GCC is glibc, and its version is very similar to this one.

I rather had the impression that non-GNU systems were more closely coupled
to expect a particular compiler and even included various headers such as
stddef.h and stdarg.h. Even when the system compiler is GCC some BSD
systems include their own copies of the headers GCC provides (for use with
the system GCC that is; they may or may not use USER_H in FSF GCC). That
the non-glibc systems I have access to don't include tgmath.h I'd think is
them simply not yet having implemented it; I don't suppose the BSDs that
now have their own <stddef.h> etc. would want GCC's <tgmath.h>.

Could you name some of these non-GNU systems that provide a /usr/include/tgmath.h? If you can find one, does its tgmath.h work with gcc?


I just checked on Solaris, and it doesn't provide a tgmath.h. I believe the BSDs do not yet provide a tgmath.h, and I'm sure they would really like the compiler to provide one. Darwin expects the compiler to provide a tgmath.h.

glibc deliberately directs calls with long double types on some platforms
where long double has the same representation as double to the double
versions of the functions. This is conforming under the "as if" rule.
What isn't conforming is that glibc in such circumstances doesn't declare
the long double versions of the functions at all in math.h and complex.h.
I am however sure that Uli has his reasons for this (which might relate to
reducing ABI breakage if future versions of those CPUs acquire a long
double type). It looks to me like this patch would instead direct to the
undeclared versions, and there is a clear choice made by the library
implementation that is being overridden here.

It seems like that is more of a bug in the current implementation, and easily fixed.


This header is certainly a useful contribution as a specimen to system
implementors using GCC of how they could implement <tgmath.h>.  Such a
file could certainly go in contrib for implementor reference and use.

So, you expect that Sun will copy this header into their /usr/include? Does that sound likely to you?


It's simply a question of the strategy of what headers GCC is in the
business of providing (at present, de facto and as documented, those
required of freestanding implementations plus some compiler intrinsic
headers externally specified for particular targets).

If the patch included a documentation change to say that GCC now supplies tgmath.h, as well, would that answer this objection?


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.


It seems that this would reinforce the need to provide this header in
GCC.  When such future improvements are made, it would be annoying to
have to change glibc and GCC simultaneously to use them, especially
when required to keep backwards compatibility in glibc.

That could apply to almost any header; there are plenty of features in GCC
that can optionally be used by system headers, e.g. various built-in
functions.

No, I don't think it could apply to 'almost any header'. Could you name another header that's in glibc, is as ugly as tgmath.h, uses a deprecated gcc feature, and could reasonably be supplied by the compiler?


[The strange macros in string.h do not count, because the compiler could not 'reasonably' provide them; the compiler handles string functions by builtins.]

The versions being cleanly decoupled seems to work fine;

I can't find context for this phrase. The versions of what are cleanly decoupled how?


 and I
don't think those users who are choosing to upgrade the components
manually rather than upgrading to a newer whole system version are the
sort to get annoyed at needing to do so (nor that many users upgrade
specifically for a better <tgmath.h>).

I don't believe we usually say "sorry, you must upgrade your glibc if you wish to build gcc 3.x".


I agree that this header is not very clean, but when compared with the
existing situation of nothing, it is an improvement.  In addition, it

You can also compare it to the existing situation of a working if obscure
header in glibc, the part of the GNU system that is tasked with providing
headers required only of hosted implementations, and enough features in
GCC to provide more than one way for other systems using GCC to implement
the header.

A situation which has not led to actual GCC-suitable implementations of tgmath.h on every system that GCC supports, which is corrected by this patch.


It
does, however, effect a change to the strategy of what library facilities
are provided where, without associated documentation changes.

So, again, would a documentation change answer this objection?


Now, the relation of GCC to glibc and other system libraries for GCC-based
systems, what is provided where, what adaptations glibc should make for
new GCC versions, when GCC should consider overriding something in glibc,
etc., is not fixed and certainly something that can be discussed - more
generally than the matter of this particular patch and in the hope of
concluding more general principles.

What about non-GCC-based systems? That is the primary consideration of this patch. (For these purposes, Darwin is not GCC-based; GCC just happens to be the compiler used to build the system, but I am trying to ensure it has no special place other than that.)


I just think that in this particular
case, the question of what headers go where, we already have a working,
documented (in standards.texi and at a lower level in sourcebuild.texi)
principle for which headers are the responsibility of what part of the
system, which has the merit of simplicity (after all, both <math.h> and
<complex.h> include compiler-specific definitions, of type-generic macros,
the macro I, and others, but we leave them to the library). As this
principle is simple, working and documented, I don't feel the need for it
to change at present.

It is simple but wrong. It is not working in the case of tgmath.h.


Although __builtin_classify_type needs to stay supported thanks to the
deployed glibc using it in tgmath.h, I don't think we want to introduce
new uses of that undocumented extension.

The only way to remove the extension would be to have gcc provide its own tgmath.h, which this does. So again, I think this speaks in

Or to fixinclude the existing headers, as and when there are better built-in functions.

This *does* fixinclude the existing header, by completely replacing it. That is the best kind of fixinclude.

Attachment: smime.p7s
Description: S/MIME cryptographic signature


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