Path: utzoo!attcan!uunet!van-bc!ubc-cs!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!uflorida!travis!tom From: tom@ssd.csd.harris.com (Tom Horsley) Newsgroups: comp.lang.c Subject: Re: re-entrant libraries - is C deficient? Message-ID: Date: 3 Oct 90 11:18:29 GMT References: <3154@bruce.cs.monash.OZ.AU> Sender: news@travis.csd.harris.com Organization: Harris Computer Systems Division Lines: 40 In-reply-to: alanf@bruce.cs.monash.OZ.AU's message of 2 Oct 90 15:21:42 GMT >>>>> Regarding re-entrant libraries - is C deficient?; alanf@bruce.cs.monash.OZ.AU (Alan Grant Finlay) adds: alanf> I'm sure there are other languages that provide a solution to this alanf> problem. For example in Pascal I can have nested procedures (I know alanf> this is not quite a solution since the application must be compiled alanf> in the scope of the nested procedures - but it is part way to a alanf> solution). I would guess that the majority of all Pascal implementations (or any other language that allows nested procedure definitions) implement nested procedures via static links. When it comes right down to it, a static link is nothing more that a hidden parameter passed in to every routine that points to the lexically correct parent stack frame (which can be thought of as a structure). In other words, just because Pascal hides all the mechanism does not mean that it is any lower overhead. I hasten to add (before I get flamed to death) that many compilers may reduce this overhead considerably by passing the static link in a register rather than on the stack, but then on most RISC machines these days, most arguments are passed in registers anyway. I also hasten to add that the above comment is not an endorsment of C over Pascal - if you need nested procedures it is obviously simpler to use a language that actually supports them directly rather than having to create artificial structures with extra arguments, etc. Back to the original point - the C library is definitely deficient when it comes to being re-entrant. The standard AT&T and/or Berkely source is chock full of global variables being used to pass junk around between internal static routines, etc. This becomes a real drag when you try to implement threads. The C library needs lots of work before it can be used safely from multiple threads of control... -- ====================================================================== domain: tahorsley@csd.harris.com USMail: Tom Horsley uucp: ...!uunet!hcx1!tahorsley 511 Kingbird Circle Delray Beach, FL 33444 +==== Censorship is the only form of Obscenity ======================+ | (Wait, I forgot government tobacco subsidies...) | +====================================================================+