On Wed, Jun 27, 2007 at 02:06:52PM -0700, Garrett D'Amore wrote:
> It seems to me like if it is in TSD data then the macro for setting it
> should be in errno.h.
>
> I'm surprised that it is defined as a function in errno.h.... since
> functions can't be lvalues.
It's not a function call, it's the value at the location returned by
the function call, which is an lvalue.
Regardless of the values of _REENTRANT or _TS_ERRNO, simply doing
errno = mumble;
should work fine.
> Of course, assignment to errno from a separate library probably isn't
> such a hot idea. Better, IMO, to pass an error number on a stack
> somewhere (or in a register) than relying on global variables...
When the software accessing errno is not compiled with _REENTRANT or
_TS_ERRNO, then it will access the variable "errno" instead, which
happens to be at the same location pointed to by the return value of
___errno() when invoked in the first (or only) thread.
In other words, if your application is multithreaded and you don't
compile it properly, every thread will get the same errno value, and
setting it will take effect globally for all threads as well.
--
Keith M Wesolowski "Sir, we're surrounded!"
FishWorks "Excellent; we can attack in any direction!"
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code