Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!ncar!zaphod.mps.ohio-state.edu!wuarchive!uunet!snorkelwacker!mintaka!spdcc!dyer From: dyer@spdcc.COM (Steve Dyer) Newsgroups: comp.unix.aux Subject: Re: difference in compilers leads to stat() confusion Message-ID: <4075@ursa-major.SPDCC.COM> Date: 18 Sep 90 17:40:15 GMT References: <3437@dftsrv.gsfc.nasa.gov> Reply-To: dyer@ursa-major.spdcc.com.spdcc.COM (Steve Dyer) Distribution: na Organization: S.P. Dyer Computer Consulting, Cambridge MA Lines: 34 In article <3437@dftsrv.gsfc.nasa.gov> jim@jagmac2.gsfc.nasa.gov (Jim Jagielski) writes: ]"For compatibility with the pcc implementation of C, returning a structure ] or union from a function is performed in a 'non-reentrant' fashion. A struct ] or union return value is returned by copying the return value into a static ] variable in the fucntion. A pointer to this variable is then returned. If a ] pointer was used as an argument to the function, then the pointer is set ] equal to the returned value. If the argument was a structure, the calling ] function will use the returned pointer to copy the static variable." Sigh. This has nothing to do with stat or lstat. *NEITHER* returns a struct-- both return ints, like all system calls. They take a pointer to a struct as their second argument. This is NOT addressed by the paragraph you quote here. The "reentrancy" problem refers to subroutines which have a struct as their returned value. stat and lstat and all system calls do not behave that way. >Hence, it made no difference WHERE the pointer pointed, it was set equal >to the struct that stat and lstat return. So the pointing to NULL is >not it at all, but in the way the compiler returns structs. No. You're wrong. You're confusing what "return" means. >10 minutes after the posting I started figuring out what was going on... Not yet you haven't. >of course, by then it was too late. Still is. -- Steve Dyer dyer@ursa-major.spdcc.com aka {ima,harvard,rayssd,linus,m2c}!spdcc!dyer dyer@arktouros.mit.edu, dyer@hstbme.mit.edu