Date: Tue, 10 Mar 1998 17:41:15 -0800 (PST) Message-Id: <199803110141.RAA22234@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" To: Eli Zaretskii , Vik Heyndrickx From: Nate Eldredge Subject: Re: errno constants in Cc: "Salvador Eduardo Tropea (SET)" , djgpp-workers AT delorie DOT com Precedence: bulk At 01:10 3/10/1998 +0200, Eli Zaretskii wrote: >> BTW, does anyone whether know whether assigning to errno by a user >> program is portable behaviour? From what I have read, errno could even >> be the result of a function call (i.e. an r-value) > >Yes, errno doesn't have to be an lvalue. A case in point is a >multi-threaded environment, where you'd like each thread to have its own >errno. *Really?* But I believe there are cases where there's no other option. This is from memory, but imagine a case where you are using `sqrt', and there are no exceptions for math errors. Also, `errno' might already have been EDOM. The scheme I saw suggested was to do: errno = 0; /* or EOK */ y = sqrt(x); if (errno == EDOM) ... I see your point about multi-threading, but that needn't exclude `errno' being an lvalue. For instance, the GNU libc implements it like this: extern int *__errno_location(); #define errno (*__errno_location()) Then the `__errno_location' function takes care of acquiring the lock or whatever, then returns `errno's address. Does the ANSI standard really say `errno' need not be an lvalue?? Nate Eldredge eldredge AT ap DOT net