From kbyanc@kronos.alcnet.com Sun Aug 22 16:59:30 1999
Return-Path: <kbyanc@kronos.alcnet.com>
Received: from kronos.alcnet.com (kronos.alcnet.com [63.69.28.22])
	by hub.freebsd.org (Postfix) with ESMTP id BAF3D14BED
	for <FreeBSD-gnats-submit@freebsd.org>; Sun, 22 Aug 1999 16:59:29 -0700 (PDT)
	(envelope-from kbyanc@kronos.alcnet.com)
Received: (from kbyanc@localhost)
	by kronos.alcnet.com (8.9.3/8.9.3/antispam) id TAA26773;
	Sun, 22 Aug 1999 19:59:19 -0400 (EDT)
Message-Id: <199908222359.TAA26773@kronos.alcnet.com>
Date: Sun, 22 Aug 1999 19:59:19 -0400 (EDT)
From: Kelly Yancey <kbyanc@kronos.alcnet.com>
Reply-To: kbyanc@kronos.alcnet.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: additional timeval interfaces for <sys/time.h>
X-Send-Pr-Version: 3.2

>Number:         13326
>Category:       kern
>Synopsis:       [headers] [patch] additional timespecs interfaces for <sys/time.h>
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          suspended
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Sun Aug 22 17:00:00 PDT 1999
>Closed-Date:    
>Last-Modified:  Wed Jun 01 20:32:20 UTC 2011
>Originator:     Kelly Yancey
>Release:        FreeBSD 3.2-STABLE i386
>Organization:
>Environment:
>Description:

	2 new interfaces for manipulating timeval structures in addition to
	those provided for NetBSD/OpenBSD compatibility in <sys/time.h>

	Admittingly, they aren't strickly necissary, but seeing as how they
	increase readability of code which manipulates timevals, don't add
	any bloat unless they are used (in which care they aren't bloat),
	and extend functionality already provided by <sys/time.h>, I think
	that they would make good additions to FreeBSD.


--- /usr/include/sys/time.h.orig	Sun Aug 22 18:33:57 1999
+++ /usr/include/sys/time.h		Sun Aug 22 18:45:12 1999
@@ -224,6 +224,23 @@
 	} while (0)
 #endif
 
+#ifndef KERNEL			/* additional timeval manipulations */
+#define timermul(tvp, uvp, x)						\
+	do {								\
+		(uvp)->tv_sec = (tvp)->tv_sec * x;			\
+		(uvp)->tv_usec = (tvp)->tv_usec * x;			\
+		while((uvp)->tv_usec > 1000000) {			\
+			(uvp)->tv_sec++;				\
+			(uvp)->tv_usec -= 1000000;			\
+		}							\
+	} while(0)
+#define timerdiv(tvp, uvp, x)						\
+	do {								\
+		(uvp)->tv_sec = (tvp)->tv_sec / x;			\
+		(uvp)->tv_usec = (tvp)->tv_usec / x;			\
+	} while(0)
+#endif
+
 /*
  * Names of the interval timers, and structure
  * defining a timer setting.

>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: FreeBSD-gnats-submit@FreeBSD.ORG, kbyanc@kronos.alcnet.com
Cc:  
Subject: Re: misc/13326: additional timeval interfaces for <sys/time.h>
Date: Mon, 23 Aug 1999 18:05:02 +1000

 >	2 new interfaces for manipulating timeval structures in addition to
 >	those provided for NetBSD/OpenBSD compatibility in <sys/time.h>
 >
 >	Admittingly, they aren't strickly necissary, but seeing as how they
 >	increase readability of code which manipulates timevals, don't add
 >	any bloat unless they are used (in which care they aren't bloat),
 >	and extend functionality already provided by <sys/time.h>, I think
 >	that they would make good additions to FreeBSD.
 
 timevals have been obsolescent for 3-4 years since POSIX blessed timespecs.
 New interfaces for dealing with them shouldn't be added.
 
 Bruce
 

From: "Kelly Yancey" <kbyanc@alcnet.com>
To: <freebsd-gnats-submit@freebsd.org>, <kbyanc@kronos.alcnet.com>
Cc:  
Subject: Re: misc/13326: additional timeval interfaces for <sys/time.h>
Date: Thu, 2 Sep 1999 15:14:00 -0400

   Per Bruce's comments, here is a revised patch which rather than adding
 interfaces for obsolete timeval structures, instead makes the timespec
 operations available to user programs (basically just pulling them out of
 the #ifdef KERNEL restriction). In addition, I made 4 new interfaces
 including:
 	multiplying and dividing timespec's by integral factors to get new
 timespecs
 	converting timespecs to/from quad_t's representing raw nanosecond counts.
 
   The latter stemmed from a recent discussion on -current where Julian
 Elischer (Mon, 30 Aug 1999 17:10:03 -0700 (PDT), RE: HEADS UP) points out
 that working with timevals/timespecs is messy because of having to deal with
 2 variables (actually, I've seen it griped about before, but this one made
 me feel like doing something about it :) ). In any event, the hope here is
 to make dealing with timespecs a little easier. If people need to deal with
 timevals, they are welcome to use TIMEVAL_TO_TIMESPEC and
 TIMESPEC_TO_TIMEVAL to convert to timespecs before doing the
 operations...or, of course, roll their own.
 
   Kelly
  ~kbyanc@posi.net~
   FreeBSD - The Power To Serve - http://www.freebsd.org/
   Join Team FreeBSD - http://www.posi.net/freebsd/Team-FreeBSD/
 
  "The ultimate result of shielding men from the effects of
   folly is to fill the world with fools." - Herbert Spencer
 
 
 --- /usr/include/sys/time.h.orig	Thu Sep  2 14:35:53 1999
 +++ /usr/include/sys/time.h	Thu Sep  2 14:55:59 1999
 @@ -155,8 +155,6 @@
  	struct timecounter	*tc_tweak;
  };
 
 -#ifdef KERNEL
 -
  /* Operations on timespecs */
  #define	timespecclear(tvp)	((tvp)->tv_sec = (tvp)->tv_nsec = 0)
  #define	timespecisset(tvp)	((tvp)->tv_sec || (tvp)->tv_nsec)
 @@ -182,6 +180,35 @@
  			(vvp)->tv_nsec += 1000000000;			\
  		}							\
  	} while (0)
 +#define timespecmul(tvp, uvp, x)					\
 +	do {								\
 +		(uvp)->tv_sec = (tvp)->tv_sec * x;			\
 +		(uvp)->tv_nsec = (tvp)->tv_nsec * x;			\
 +		while((uvp)->tv_nsec > 1000000000) {			\
 +			(uvp)->tv_sec++;				\
 +			(uvp)->tv_nsec -= 1000000000;			\
 +		}							\
 +	} while(0)
 +#define timespecdiv(tvp, uvp, x)					\
 +	do {								\
 +		(uvp)->tv_sec = (tvp)->tv_sec / x;			\
 +		(uvp)->tv_nsec = (tvp)->tv_nsec / x;			\
 +	} while(0)
 +
 +/*
 + * Operations for converting timespecs to/from quad_t's representing
 + * times in nanoseconds.
 + */
 +#define tstoq(tvp, q)							\
 +	do {								\
 +		q = ((tvp)->tv_sec * 1000000000) + (tvp)->tv_nsec;	\
 +	} while(0)
 +#define qtots(q, tvp)							\
 +	do {								\
 +		(tvp)->tv_sec = q / 1000000000;				\
 +		(tvp)->tv_nsec = q % 1000000000;			\
 +	} while(0)
 +#ifdef KERNEL
 
  /* Operations on timevals. */
 
 
 

From: "Kelly Yancey" <kbyanc@alcnet.com>
To: <freebsd-gnats-submit@freebsd.org>, <kbyanc@kronos.alcnet.com>
Cc:  
Subject: Re: misc/13326: additional timeval interfaces for <sys/time.h>
Date: Thu, 2 Sep 1999 17:26:46 -0400

   Updates to previous patch per suggestions by Poul-Henning Kamp...
 
   Kelly
  ~kbyanc@posi.net~
   FreeBSD - The Power To Serve - http://www.freebsd.org/
   Join Team FreeBSD - http://www.posi.net/freebsd/Team-FreeBSD/
 
  "The ultimate result of shielding men from the effects of
   folly is to fill the world with fools." - Herbert Spencer
 
 
 --- /usr/include/sys/time.h.orig	Thu Sep  2 14:35:53 1999
 +++ /usr/include/sys/time.h	Thu Sep  2 16:41:25 1999
 @@ -155,8 +155,6 @@
  	struct timecounter	*tc_tweak;
  };
  
 -#ifdef KERNEL
 -
  /* Operations on timespecs */
  #define	timespecclear(tvp)	((tvp)->tv_sec = (tvp)->tv_nsec = 0)
  #define	timespecisset(tvp)	((tvp)->tv_sec || (tvp)->tv_nsec)
 @@ -182,6 +180,32 @@
  			(vvp)->tv_nsec += 1000000000;			\
  		}							\
  	} while (0)
 +#define timespecmul(tvp, uvp, x)					\
 +	do {								\
 +		(uvp)->tv_sec = ((tvp)->tv_sec * x) +			\
 +				(quad_t)(tvp)->tv_nsec * x / 1000000000;\
 +		(uvp)->tv_nsec = (quad_t)(tvp)->tv_nsec * x % 1000000000;\
 +	} while(0)
 +#define timespecdiv(tvp, uvp, x)					\
 +	do {								\
 +		(uvp)->tv_sec = (tvp)->tv_sec / x;			\
 +		(uvp)->tv_nsec = (tvp)->tv_nsec / x;			\
 +	} while(0)
 +
 +/*
 + * Operations for converting timespecs to/from quad_t's representing
 + * times in nanoseconds.
 + */
 +#define tstoq(tvp, q)							\
 +	do {								\
 +		q = ((tvp)->tv_sec * 1000000000) + (tvp)->tv_nsec;	\
 +	} while(0)
 +#define qtots(q, tvp)							\
 +	do {								\
 +		(tvp)->tv_sec = q / 1000000000;				\
 +		(tvp)->tv_nsec = q % 1000000000;			\
 +	} while(0)
 +#ifdef KERNEL
  
  /* Operations on timevals. */
 
 
State-Changed-From-To: open->feedback 
State-Changed-By: kmacy 
State-Changed-When: Fri Nov 16 08:33:17 UTC 2007 
State-Changed-Why:  

awaiting a response from phk in a separate mail 


Responsible-Changed-From-To: freebsd-bugs->kmacy 
Responsible-Changed-By: kmacy 
Responsible-Changed-When: Fri Nov 16 08:33:17 UTC 2007 
Responsible-Changed-Why:  

awaiting a response from phk in a separate mail  

http://www.freebsd.org/cgi/query-pr.cgi?pr=13326 

From: Alexander Best <arundel@freebsd.org>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: kern/13326: [headers] [patch] additional timeval interfaces for <sys/time.h>
Date: Tue, 7 Sep 2010 00:00:48 +0000

 any news on this ancient PR's status?
 
 cheers.
 alex
 
 -- 
 a13x
State-Changed-From-To: feedback->suspended 
State-Changed-By: arundel 
State-Changed-When: Wed Sep 22 02:27:36 UTC 2010 
State-Changed-Why:  
It seems the idea of having new timespecs interfaces never really caught on. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=13326 
Responsible-Changed-From-To: kmacy->freebsd-bugs 
Responsible-Changed-By: gavin 
Responsible-Changed-When: Wed Jun 1 20:29:31 UTC 2011 
Responsible-Changed-Why:  
kmacy has asked for all of his PRs to be reassigned, put back into the 
pool. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=13326 
>Unformatted:
