public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* misleading statement in bugs.html#known
@ 2001-12-05 13:16 Per Bothner
  2001-12-05 13:52 ` Geoff Keating
  2001-12-05 14:38 ` Andreas Schwab
  0 siblings, 2 replies; 10+ messages in thread
From: Per Bothner @ 2001-12-05 13:16 UTC (permalink / raw)
  To: gcc

The bugs.html files says 'FILE *yyin = stdin' "will not compile with GNU 
libc (GNU/Linux libc6), because stdin is not a constant. This was done 
deliberately, in order for there to be no limit on the number of open 
FILE objects."

The latter has nothing to do with it.  It is easy to make stdin be
a constant while still having no limit on the number of open FILE
objects.  For example:

	extern FILE __stdin;
         @define stdin (&__stdin)

The point is that glibc allows you to *assign* to stdin, so it is
no longer constant.  This is a questionable feature..
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: misleading statement in bugs.html#known
  2001-12-05 13:16 misleading statement in bugs.html#known Per Bothner
@ 2001-12-05 13:52 ` Geoff Keating
  2001-12-06 12:33   ` Per Bothner
  2001-12-05 14:38 ` Andreas Schwab
  1 sibling, 1 reply; 10+ messages in thread
From: Geoff Keating @ 2001-12-05 13:52 UTC (permalink / raw)
  To: Per Bothner; +Cc: gcc

Per Bothner <per@bothner.com> writes:

> The bugs.html files says 'FILE *yyin = stdin' "will not compile with GNU 
> libc (GNU/Linux libc6), because stdin is not a constant. This was done 
> deliberately, in order for there to be no limit on the number of open 
> FILE objects."
> 
> The latter has nothing to do with it.  It is easy to make stdin be
> a constant while still having no limit on the number of open FILE
> objects.  For example:
> 
> 	extern FILE __stdin;
>          @define stdin (&__stdin)
> 
> The point is that glibc allows you to *assign* to stdin, so it is
> no longer constant.  This is a questionable feature..

Actually, neither of these are the real reason.  I believe the
definition of stdin was changed so that user programs didn't need to
know the size of 'FILE'.  If a user program writes

printf (&__stdin, ...)

then this works with dynamic linking by creating space in the
executable for '__stdin', resolving the address of __stdin at link
time, and copying at startup time the initial contents of __stdin to
that space (this is done because addresses in applications are not
resolved at run time).  If __stdin grows in size in future glibc
versions, the space reserved in old applications will be too small,
and special compatibility code is required.  So instead, 'stdin' is
made a variable of type 'FILE *', which is not likely to change in
size in future versions.

-- 
- Geoffrey Keating <geoffk@geoffk.org> <geoffk@redhat.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: misleading statement in bugs.html#known
  2001-12-05 13:16 misleading statement in bugs.html#known Per Bothner
  2001-12-05 13:52 ` Geoff Keating
@ 2001-12-05 14:38 ` Andreas Schwab
  2001-12-06  4:31   ` Gerald Pfeifer
  1 sibling, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2001-12-05 14:38 UTC (permalink / raw)
  To: Per Bothner; +Cc: gcc

Per Bothner <per@bothner.com> writes:

|> The bugs.html files says 'FILE *yyin = stdin' "will not compile with GNU
|> libc (GNU/Linux libc6), because stdin is not a constant. This was done
|> deliberately, in order for there to be no limit on the number of open FILE
|> objects."
|> 
|> The latter has nothing to do with it.  It is easy to make stdin be
|> a constant while still having no limit on the number of open FILE
|> objects.  For example:
|> 
|> 	extern FILE __stdin;
|>          @define stdin (&__stdin)
|> 
|> The point is that glibc allows you to *assign* to stdin, so it is
|> no longer constant.  This is a questionable feature..

No.  The real reason is that using the address of a static object is a
nightmare in context of maintaining binary compatibility.  Platforms that
use copy relocations will lose if the size of the FILE type changes.

In any way, the C standard does not *require* stdin to be a constant.
Thus using it as an initializer at file scope is broken no matter what.

Andreas.

-- 
Andreas Schwab                                  "And now for something
Andreas.Schwab@suse.de				completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: misleading statement in bugs.html#known
  2001-12-05 14:38 ` Andreas Schwab
@ 2001-12-06  4:31   ` Gerald Pfeifer
  2001-12-06  4:46     ` Andreas Schwab
  0 siblings, 1 reply; 10+ messages in thread
From: Gerald Pfeifer @ 2001-12-06  4:31 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Per Bothner, gcc

On 5 Dec 2001, Andreas Schwab wrote:
>|> The point is that glibc allows you to *assign* to stdin, so it is
>|> no longer constant.  This is a questionable feature..
> No.  The real reason is that using the address of a static object is a
> nightmare in context of maintaining binary compatibility.  Platforms that
> use copy relocations will lose if the size of the FILE type changes.

Would (one of) you (who knows this stuff) mind updating bugs.html?

Gerald
-- 
Gerald "Jerry" pfeifer@dbai.tuwien.ac.at http://www.dbai.tuwien.ac.at/~pfeifer/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: misleading statement in bugs.html#known
  2001-12-06  4:31   ` Gerald Pfeifer
@ 2001-12-06  4:46     ` Andreas Schwab
  2001-12-06  7:18       ` Gerald Pfeifer
  0 siblings, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2001-12-06  4:46 UTC (permalink / raw)
  To: Gerald Pfeifer; +Cc: Per Bothner, gcc

Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> writes:

|> On 5 Dec 2001, Andreas Schwab wrote:
|> >|> The point is that glibc allows you to *assign* to stdin, so it is
|> >|> no longer constant.  This is a questionable feature..
|> > No.  The real reason is that using the address of a static object is a
|> > nightmare in context of maintaining binary compatibility.  Platforms that
|> > use copy relocations will lose if the size of the FILE type changes.
|> 
|> Would (one of) you (who knows this stuff) mind updating bugs.html?

How about this:

--- bugs.html.~1.45.~	Sun Nov  4 00:14:32 2001
+++ bugs.html	Thu Dec  6 13:29:35 2001
@@ -276,10 +276,10 @@
 </code></blockquote>
 
 will not compile with GNU libc (GNU/Linux libc6), because
-<code>stdin</code> is not a constant.  This was done deliberately, in
-order for there to be no limit on the number of open <code>FILE</code>
-objects.  It is surprising for people used to traditional Unix C
-libraries, but it is permitted by the C standard.</p>
+<code>stdin</code> is not a constant.  This was done deliberately, to make
+it easier to maintain binary compatibility when the type <code>FILE</code>
+needs to be changed.  It is surprising for people used to traditional Unix
+C libraries, but it is permitted by the C standard.</p>
 
 <p>This construct commonly occurs in code generated by old versions of
 lex or yacc.  We suggest you try regenerating the parser with a

Andreas.

-- 
Andreas Schwab                                  "And now for something
Andreas.Schwab@suse.de				completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: misleading statement in bugs.html#known
  2001-12-06  4:46     ` Andreas Schwab
@ 2001-12-06  7:18       ` Gerald Pfeifer
  2001-12-06  7:35         ` Andreas Schwab
  0 siblings, 1 reply; 10+ messages in thread
From: Gerald Pfeifer @ 2001-12-06  7:18 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Per Bothner, gcc

On 6 Dec 2001, Andreas Schwab wrote:
> How about this:

This looks fine, thanks!

> +C libraries, but it is permitted by the C standard.</p>
                                          ^^^
Perhaps we should mention *which* C standard? ISO C?

Gerald
-- 
Gerald "Jerry" pfeifer@dbai.tuwien.ac.at http://www.dbai.tuwien.ac.at/~pfeifer/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: misleading statement in bugs.html#known
  2001-12-06  7:18       ` Gerald Pfeifer
@ 2001-12-06  7:35         ` Andreas Schwab
  2001-12-06 10:08           ` Gerald Pfeifer
  0 siblings, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2001-12-06  7:35 UTC (permalink / raw)
  To: Gerald Pfeifer; +Cc: Per Bothner, gcc

Gerald Pfeifer <pfeifer@dbai.tuwien.ac.at> writes:

|> On 6 Dec 2001, Andreas Schwab wrote:
|> > How about this:
|> 
|> This looks fine, thanks!
|> 
|> > +C libraries, but it is permitted by the C standard.</p>
|>                                           ^^^
|> Perhaps we should mention *which* C standard? ISO C?

Is there any other C standard?  Even C89 had this.

Andreas.

-- 
Andreas Schwab                                  "And now for something
Andreas.Schwab@suse.de				completely different."
SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: misleading statement in bugs.html#known
  2001-12-06  7:35         ` Andreas Schwab
@ 2001-12-06 10:08           ` Gerald Pfeifer
  0 siblings, 0 replies; 10+ messages in thread
From: Gerald Pfeifer @ 2001-12-06 10:08 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Per Bothner, gcc

On 6 Dec 2001, Andreas Schwab wrote:
>|>> +C libraries, but it is permitted by the C standard.</p>
>|>                                           ^^^
>|> Perhaps we should mention *which* C standard? ISO C?
> Is there any other C standard?  Even C89 had this.

This I didn't know. In that case, the patch seems fine as is.

Thanks,
Gerald
-- 
Gerald "Jerry" pfeifer@dbai.tuwien.ac.at http://www.dbai.tuwien.ac.at/~pfeifer/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: misleading statement in bugs.html#known
  2001-12-05 13:52 ` Geoff Keating
@ 2001-12-06 12:33   ` Per Bothner
  2001-12-06 15:48     ` Richard Henderson
  0 siblings, 1 reply; 10+ messages in thread
From: Per Bothner @ 2001-12-06 12:33 UTC (permalink / raw)
  To: Geoff Keating; +Cc: gcc

Geoff Keating wrote:

> printf (&__stdin, ...)
> 
> then this works with dynamic linking by creating space in the
> executable for '__stdin', resolving the address of __stdin at link
> time, and copying at startup time the initial contents of __stdin to
> that space


Ugh.  Ick.  This is unfortunate mechanism, not that I know enough
about dynamic linking to know if there is (or could be) a better
way.  But it seems we're stuck with it.

Thanks for the replies and explanations.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: misleading statement in bugs.html#known
  2001-12-06 12:33   ` Per Bothner
@ 2001-12-06 15:48     ` Richard Henderson
  0 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2001-12-06 15:48 UTC (permalink / raw)
  To: Per Bothner; +Cc: Geoff Keating, gcc

On Thu, Dec 06, 2001 at 12:14:55PM -0800, Per Bothner wrote:
> Ugh.  Ick.  This is unfortunate mechanism, not that I know enough
> about dynamic linking to know if there is (or could be) a better
> way.  But it seems we're stuck with it.

The "better way" is defaulting to PIC for any symbol not known
to be defined locally.  We do this on Alpha and IA-64.  It's not
really practical to do the same for x86 though.  :-/


r~

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2001-12-06 23:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-05 13:16 misleading statement in bugs.html#known Per Bothner
2001-12-05 13:52 ` Geoff Keating
2001-12-06 12:33   ` Per Bothner
2001-12-06 15:48     ` Richard Henderson
2001-12-05 14:38 ` Andreas Schwab
2001-12-06  4:31   ` Gerald Pfeifer
2001-12-06  4:46     ` Andreas Schwab
2001-12-06  7:18       ` Gerald Pfeifer
2001-12-06  7:35         ` Andreas Schwab
2001-12-06 10:08           ` Gerald Pfeifer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).