Shared Lib Question (ISC)

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Thu May 16 08:13:22 AEST 1991


In article <7516 at segue.segue.com> jim at segue.segue.com (Jim Balter) writes:
> 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.

Yeah. I've been arguing this with John via e-mail. He keeps repeating
the same old description of how to separate a library into a sharable
part and the part with the global variables. I keep pointing out that
the global variables are still there. We all know how to write a shared
library under the *constraint* of no static data, but the issue here is
whether that is a real constraint---i.e., whether good libraries can use
globals. John keeps ignoring the fact that malloc() does use globals.

C'mon, John, would you just admit that eliminating global variables is
not always a good idea, and that requiring that shared libraries be pure
is a real constraint?

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

Even worse, it requires that any library routine that might *use* one of
those malloc-using routines must also take the pointer. So much for
separating interface from implementation.

Even worse than that, if you want to keep the same interface forever,
you have to predict all libraries that the implementation might use,
directly or indirectly, not just now but in the far future. So much for
finite argument lists. :-(

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

Amen.

---Dan



More information about the Comp.unix.internals mailing list