Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!natinst!sequoia!rpp386!jfh From: jfh@rpp386.cactus.org (John F Haugh II) Newsgroups: comp.unix.internals Subject: Re: Shared Lib Question (ISC) Message-ID: <19261@rpp386.cactus.org> Date: 12 May 91 18:14:47 GMT References: <19252@rpp386.cactus.org> <19255@rpp386.cactus.org> <1991May10.192648.3147@Think.COM> Reply-To: jfh@rpp386.cactus.org (John F Haugh II) Organization: Lone Star Cat Emporium and BBQ Grill Lines: 35 X-Clever-Slogan: Help Prevent Robbery. Tax the IRS. In article <1991May10.192648.3147@Think.COM> barmar@think.com writes: >In article <19255@rpp386.cactus.org> jfh@rpp386.cactus.org (John F Haugh II) writes: >> Name a single library function >>which cannot be implemented well without global variables. > >Malloc() needs a global variable that points to the arena. > >Stdio uses the global variables stdin, stdout, and stderr. > >Errno is a global variable, and some library routines set it. The key word was "well", not "at all". malloc() can be implemented as a function which is bound static and has a single pointer to all the private data that it requires. It then calls the real routine which takes a pointer to the arena glarp and size of the desired object. Likewise for the stdio library. Functions which have implied (FILE *) objects can be re-implemented as wrappers for the versions which require the explicit argument. The FILE _iob[] Given that the functions were =designed= with the notion of shared global data, I don't see any reason not to cheat and leave certain parts =out= of the shared library. I'll leave errno as an exercise for the reader. [ Hint: How does the system get errno out of the kernel and into the user space, if it is a user space global variable? ] -- John F. Haugh II | Distribution to | UUCP: ...!cs.utexas.edu!rpp386!jfh Ma Bell: (512) 255-8251 | GEnie PROHIBITED :-) | Domain: jfh@rpp386.cactus.org "If liberals interpreted the 2nd Amendment the same way they interpret the rest of the Constitution, gun ownership would be mandatory."