difference in compilers leads to stat() confusion

Steve Dyer dyer at spdcc.COM
Wed Sep 19 03:40:15 AEST 1990


In article <3437 at dftsrv.gsfc.nasa.gov> jim at 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 at ursa-major.spdcc.com aka {ima,harvard,rayssd,linus,m2c}!spdcc!dyer
dyer at arktouros.mit.edu, dyer at hstbme.mit.edu



More information about the Comp.unix.aux mailing list