Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site ucla-cs.ARPA Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!ittatc!dcdwest!sdcsvax!sdcrdcf!ucla-cs!jimc From: jimc@ucla-cs.UUCP Newsgroups: net.lang.c++ Subject: Re: Re-entrancy Re-visited Message-ID: <9691@ucla-cs.ARPA> Date: Thu, 6-Mar-86 20:35:31 EST Article-I.D.: ucla-cs.9691 Posted: Thu Mar 6 20:35:31 1986 Date-Received: Sun, 9-Mar-86 00:22:10 EST References: <34200005@orstcs.UUCP> Reply-To: jimc@ucla-cs.UUCP (Jim Carter) Organization: UCLA Computer Science Department Lines: 31 In article <34200005@orstcs.UUCP> nathan@orstcs.UUCP (nathan) writes: >Under certain C compilers, I can write a complex-number library >whose functions are usable both in main-line code and in signal >routines. It would not be at all portable. C is not a fully >re-entrant language. > >What galls is that *most* of the language is! It's only in the >area of structure handling that the specification is too loose >to permit portability of programs which need re-entrancy. > >If, in the language specification, it doesn't say that >interrupts won't mess up mainline code's variables, then I as >a programmer can't count on that fact -- and any program I write >which needs it is immediately, irreparably nonportable. > The draft "C" standard, X3J11/85-138, section B.2.3 "Signals and Exceptions", states: Functions must be implemented such that they may be interrupted at any time by a signal, and may be called by a signal handler with no alteration to data with automatic storage duration belonging to earlier invocations... The functions in the standard library are not guaranteed to be reentrant... As for the latter part, I believe it refers to things like asctime that store results in a static string. I have recommended a wording change to "Certain library functions, explicitly noted in the standard, may not be reentrant." -- James F. Carter (213) 206-1306 UCLA-SEASnet; 2567 Boelter Hall; 405 Hilgard Ave.; Los Angeles, CA 90024 UUCP:...!{ihnp4,ucbvax,{hao!cepu}}!ucla-cs!jimc ARPA:jimc@locus.UCLA.EDU