This is the mail archive of the 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: [RFC Patch]: Implement remainder() as built-in function [PR fortran/24518]

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 transformation.

The usual definition of the form you describe is:

&ios[1], given something like:

FILE _ios[3];

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.

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