This is the mail archive of the
mailing list for the GCC project.
Re: [RFC Patch]: Implement remainder() as built-in function [PR fortran/24518]
- From: Mike Stump <mrs at apple dot com>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: "Kaveh R. GHAZI" <ghazi at caip dot rutgers dot edu>, Richard Guenther <richard dot guenther at gmail dot com>, Uros Bizjak <ubizjak at gmail dot com>, FX Coudert <fxcoudert at gmail dot com>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 25 Oct 2006 14:17:52 -0700
- Subject: Re: [RFC Patch]: Implement remainder() as built-in function [PR fortran/24518]
- References: <Pine.LNX.email@example.com>
On Oct 25, 2006, at 12:49 PM, Roger Sayle wrote:
However, it then occured to me that we can be even cleverer still:
extern FILE *__libgcc_stdout = stdout;
Too cleaver by 1, in:
stdout = fopen ();
the second printf has to go to the fopen file; if you _save_ away the
_previous_ value of stdout, you will use the _previous_ value of
stdout. Now, before you say, but that's not legal or some such mumbo
jumbo, realize that can be an internal implementation detail of _any_
software on the system, and that software _is_ valid. The _value_ of
stdout has to be refetched in general. Now, if there is something in
the language spec that said that stdout will always point to the exact
same place in the language standards, then you could rely upon that to
save the value away. I just don't recall any such requirement in the
standard. If a system wanted to make that guarantee, it could.
Tthe original legacy of C had stdout being a reference to a specific
array element of a file scope array of FILEs, and this created the
freopen api, but realize that the language standard doesn't restrict
the implementation to that legacy.
Our issue is that libc's stdout isn't guaranteed to be mapped to a
single simple symbol, and is often #defined to something cryptic.
Are you talking about theory or practice? If practice, what system
and what does it map to? My take is that such systems can add a hook
(or an md fragment) to explain how to get the value, if they want the
The usual definition of the form you describe is:
&ios, given something like:
where _ios is an external symbol and there is just a fixed integral
offset from that symbol where stdout is. If these systems are still
common today, certainly even they could be autoconfed for.