itimerfix() fix for time validity check

Dan Nelson dnelson at allantgroup.com
Mon Mar 31 12:14:57 PST 2003


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

> 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.

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-arch mailing list