>>>>> "Rob" == Rob Warnock <rpw3@rigden.engr.sgi.com> writes:
Rob> Friedrich Dominicus <frido@q-software-solutions.com> wrote:
Rob> +---------------
Rob> | sperber@informatik.uni-tuebingen.de
Rob> | (Michael Sperber [Mr. Preprocessor]) writes:
Rob> ...
Rob> | > errno = 0;
Rob> | > t = time(NULL);
Rob> | > if( t == -1 && errno ) return ENTER_FIXNUM(errno);
Rob> ...
Rob> | > I believe this to be wrong for several reaons:
Rob> | > - errno is not guaranteed to be an lvalue. In fact, several Unices
Rob> | > define errno to be a macro for a function call.
Rob> |
Rob> | Are you sure? In most of my Unix books the schem for accessing errno
Rob> | is always the same. Assign 0 to errno run the system call check errno.
Rob> | This is so common that I can not believe that it could be differently.
Rob> +---------------
Rob> Indeed. You *MUST* be able to store a zero [at least] into "errno", because
Rob> the Unix kernel does *NOT* clear it on success, and there are some system
Rob> calls which *can* return "-1" on success! If you could not store a zero
Rob> into errno, you would have *no* way to tell if those system calls failed.
Such as? The systems I have access to are pretty explicit about the
fact that errno can only indicate the nature, but not the presence of
an error.
The Single UNIX Specification, Version 2 has this wording, for
instance:
> The value of errno should only be examined when it is indicated to
> be valid by a function's return value.
Even without this bit, the rest of the argument stands.
--
Cheers =8-} Mike
Friede, Völkerverständigung und überhaupt blabla
|