Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 23 Jan 2005 22:17:29 -0500 (EST)
From:      Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
To:        Matthias Andree <matthias.andree@gmx.de>
Cc:        current@FreeBSD.ORG
Subject:   Re: Implementation errors in strtol()
Message-ID:  <200501240317.j0O3HTGu077135@khavrinen.lcs.mit.edu>
In-Reply-To: <m3acr31yhc.fsf@merlin.emma.line.org>
References:  <20050120192324.GA30862@uriah.heep.sax.de> <20050120205501.GA69123@nagual.pp.ru> <20050120211449.GC30862@uriah.heep.sax.de> <20050120214406.GA70088@nagual.pp.ru> <20050120222137.GE30862@uriah.heep.sax.de> <20050120224017.GA71573@nagual.pp.ru> <m3acr31yhc.fsf@merlin.emma.line.org>

next in thread | previous in thread | raw e-mail | index | archive | help
<<On Fri, 21 Jan 2005 00:18:07 +0100, Matthias Andree <matthias.andree@gmx.de> said:

[Apologies for joining this discussion late; I was on vacation.]

> I do not have a place of discovery handy, but wasn't POSIX explicitly
> deferring in to the C standard and giving it precedence for any
> conflicts between the C standard library and POSIX?

POSIX/SUSv3 defers to C99.  However, POSIX significantly extends C99
by explicitly defining behavior that C99 leaves undefined or
implementation-defined.  In places where C is silent, POSIX is free to
make additional requirements on an implementation.

In the specific case of errors, POSIX observes the following three
principles (which you can find in the introductory material to either
XSI or XBD, I forget which):

- If POSIX says that function X "shall" set errno to a particular
value when a particular condition holds, implementations have no
freedom of action: they must detect that condition and set errno as
specified.

- If POSIX says that a function X "may" set errno to a particular
value when a particular condition holds, implementations are free not
to detect that condition, but if they do, they must set errno to that
value.

- Unless a function is specified as not setting errno, a function may
set errno to any nonzero value, regardless of whether it succeeds or
fails.

It then follows that:

- If a function detects an error condition which is not explicitly
enumerated in the standard, and which is not explicitly excluded by
the definition of that function, it may set errno to an
implementation-defined value and return an error indication.

-GAWollman



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200501240317.j0O3HTGu077135>