Re: funny gettimeofday



On Sun, Jul 23, 2006 at 09:40:29PM +0200, Nicolas George wrote:
> > Always check return codes. gettimeofday() *can* fail (most likely,
> > tv1 and/or tv2 are bum pointers that don't point where you think).
> 
> As a matter of fact, no, it can not, at least as long as its second argument
> is NULL:
> 
> # RETURN VALUE
> # 
> #     The gettimeofday() function shall return 0 and no value shall be
> #     reserved to indicate an error.
> 
> (Single Unix version 3)
> 
> If the provided buffer is invalid, the error will be reported through a
> signal (SIGSEGV or maybe SIGBUS if it is an alignment problem).

Well, on *Linux* it says:

ERRORS
       EFAULT One of tv or tz pointed outside the accessible address space.
       ...

And other systems (*BSD, Darwin, HP-UX, IRIX) indicate
similar possibilities for EFAULT.  It seems EFAULT appeared
in the BSD branch of Unix.

Yeti


--
Anonyms eat their boogers.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]