bug-gnulib
[Top][All Lists]
Advanced

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

xtime.h's xtime_nsec: s/int/long int/?


From: Jim Meyering
Subject: xtime.h's xtime_nsec: s/int/long int/?
Date: Wed, 14 Dec 2005 15:25:44 +0100

Hi Paul, I noticed that xtime.h's xtime_nsec function uses/returns `int': static inline int xtime_nsec (xtime_t t) { int ns = t % XTIME_PRECISION; if (ns < 0) ns += XTIME_PRECISION; return ns; } Shouldn't it use/return `long int', to be consistent with the type of the tv_nsec member of struct timespec? From timespec.h: struct timespec { time_t tv_sec; long tv_nsec; }; The same goes for xtime_make's `ns' paramter. Here's a proposed patch: 2005-12-14 Jim Meyering <address@hidden>

* xtime.h (xtime_nsec): Use `long int', not `int', to be consistent with type of timespec.tv_nsec.
        (xtime_make): Likewise for `ns' parameter.

Index: lib/xtime.h
===================================================================
RCS file: /fetish/cu/lib/xtime.h,v
retrieving revision 1.4
diff -u -p -r1.4 xtime.h
--- lib/xtime.h 29 Sep 2005 16:51:40 -0000      1.4
+++ lib/xtime.h 14 Dec 2005 14:23:44 -0000
@@ -41,7 +41,7 @@ typedef long int xtime_t;
/* Return an extended time value that contains S seconds and NS
   nanoseconds, without any overflow checking.  */
static inline xtime_t
-xtime_make (xtime_t s, int ns)
+xtime_make (xtime_t s, long int ns)
{
  if (XTIME_PRECISION == 1)
    return s;
@@ -75,10 +75,10 @@ xtime_nonnegative_nsec (xtime_t t)
}

/* Return the number of nanoseconds in T.  */
-static inline int
+static inline long int
xtime_nsec (xtime_t t)
{
-  int ns = t % XTIME_PRECISION;
+  long int ns = t % XTIME_PRECISION;
  if (ns < 0)
    ns += XTIME_PRECISION;
  return ns;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]