Shared Lib Question (ISC)

Jim Balter jim at segue.segue.com
Tue May 14 10:42:00 AEST 1991


In article <19256 at rpp386.cactus.org> jfh at rpp386.cactus.org (John F Haugh II) writes:
>There is a difference between `state' and `global variables'.  For example,
>the stdio library you mention, could keep its state in the (FILE *) object
>you pass as its argument in the `no global variables' version of our
>stdio library.

However, ANSI mandates that fclose(NULL) close all open FILEs, which requires
a global pointing to the list of FILEs.  Of course, fopen could be a non-shared
wrapper around a shared global routine; you would also need fopen and fdopen to
be wrappers, since they need to hang new FILEs on the list.  So, one can
implement the C library as a shared library without globals if one is willing
to claim that the wrappers and the overhead they require isn't part of the
implementation, but that is stretching it.

The obvious other C library routine that requires globals is malloc.
You could pass it an arena descriptor, but that would require that any library
routine that ever possibly might be shared and use malloc to be passed the
descriptor.  Making malloc take an arena descriptor is bad library design.
However, it is again possible to have the internal version of malloc accept
such a descriptor, and have the wrapper for malloc, as well as the wrapper for
any shared routine that uses malloc, pass the a global descriptor to malloc.
Of course, any shared library routine that does not get passed the descriptor
can never be reimplemented to use malloc, at least not compatibly with old
executables (but then, that's what library version numbers are for).

It is far better to either keep a register pointing to a global data area,
as mentioned in my previous note, or to support shared libraries with
private data, with all the attendant complexity, than to cripple a library
specification on the basis of a misapplication of CS principles.

>"If liberals interpreted the 2nd Amendment the same way they interpret the
> rest of the Constitution, gun ownership would be mandatory."

Actually, they would merely oppose gun control.  But why be honest when you
can be hyperbolic?  Whereas liberals want to ignore the 2nd while honoring
the rest, reactionaries want to honor the 2nd and ignore the rest, and call
liberals hypocrites while they are at it.  And then there are the centrists,
who consider themselves superior by virtue of too little knowledge or concern
to take any position.  But the less one recognizes one's own hypocrisy,
the more hypocritical one is.

P.S.  If you don't want your propaganda discussed here, don't post it.

"Guard against the impostures of pretended patriotism."

"Overgrown military establishments are under any form of government
inauspicious to liberty ..."

	-- George Washington



More information about the Comp.unix.internals mailing list