itimerfix() fix for time validity check

Alexey Dokuchaev danfe at nsu.ru
Mon Mar 31 13:30:14 PST 2003


On Mon, Mar 31, 2003 at 02:14:54PM -0600, Dan Nelson wrote:
> In the last episode (Apr 01), Alexey Dokuchaev said:
> > While porting some apps written for Linux to FreeBSD, I've
> > encountered the fact that, while under Linux it's quite appropriate
> > (and possible) to pass million and more milliseconds as tv_usec value
> > in
> > 
> > struct timeval {
> > 	long tv_sec;
> > 	long tv_usec;
> > };
> > 
> > used in functions like setitimer(), it's not like that in FreeBSD.
> > 
> > Brief investigation showed that itimerfix() treats tv_usec >= 1000000
> > invalid.  On contrary, Linux recalculates the values (and eventually,
> > tv_usec is indeed less than 1000000.
> 
> Then it is violating the SUSV3/POSIX 1003.1-2001 standard:
> 
>      The setitimer() function shall fail if:
> 
>      [EINVAL]
>          The value argument is not in canonical form. (In canonical form,
>          the number of microseconds is a non-negative integer less than
>          1000000 and the number of seconds is a non-negative integer.)
> 
> Free registration to access the standard is at
> http://www.unix.org/online.html

Thanks for clarification.
I think the issue can now be withdrawn.

> 
> > Since I'm unaware of what does any particular standard say on this
> > issue, but since the dominant number of apps are being written (and
> > designed) for Linux, this seems to cause run-time compatibility problem;
> > quite a few apps in out ports collection might need special patching.
> 
> Those programs will also fail on Solaris, which fails on invalid
> timeval values.

Yes, indeed, I've just checked it.

./danfe



More information about the freebsd-arch mailing list