Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Nov 1996 06:41:25 -0600 (CST)
From:      Chris Csanady <ccsanady@friley216.res.iastate.edu>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   misc/2007: /usr/include/sys lacking timer arithmetic functions..
Message-ID:  <199611141241.GAA01965@friley216.res.iastate.edu>
Resent-Message-ID: <199611141250.EAA06739@freefall.freebsd.org>

index | next in thread | raw e-mail


>Number:         2007
>Category:       misc
>Synopsis:       /usr/include/sys lacking timer arithmetic functions..
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Nov 14 04:50:00 PST 1996
>Last-Modified:
>Originator:     Chris Csanady
>Organization:
>Release:        FreeBSD 3.0-CURRENT i386
>Environment:

	

>Description:

	

It would be nice if there were more timer arithmetic functions in sys/time.h.
The following is a patch from the relevent portion which I have taken from
NetBSD's.

>How-To-Repeat:

	

>Fix:
	
	

--- time.h.new	Thu Nov 14 06:30:41 1996
***************
*** 84,89 ****
--- 84,107 ----
  	(((tvp)->tv_sec == (uvp)->tv_sec) ?				\
  	    ((tvp)->tv_usec cmp (uvp)->tv_usec) :			\
  	    ((tvp)->tv_sec cmp (uvp)->tv_sec))
+ #define timeradd(tvp, uvp, vvp)						\
+ 	do {								\
+ 		(vvp)->tv_sec = (tvp)->tv_sec + (uvp)->tv_sec;		\
+ 		(vvp)->tv_usec = (tvp)->tv_usec + (uvp)->tv_usec;	\
+ 		if ((vvp)->tv_usec >= 1000000) {			\
+ 			(vvp)->tv_sec++;				\
+ 			(vvp)->tv_usec -= 1000000;			\
+ 		}							\
+ 	} while (0)
+ #define timersub(tvp, uvp, vvp)						\
+         do {								\
+ 		(vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec;		\
+ 		(vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec;	\
+ 		if ((vvp)->tv_usec < 0) {				\
+ 			(vvp)->tv_sec--;				\
+ 			(vvp)->tv_usec += 1000000;			\
+ 		}							\
+ 	} while (0)
  
  /*
   * Names of the interval timers, and structure
>Audit-Trail:
>Unformatted:


home | help

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