bug-gnulib
[Top][All Lists]
Advanced

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

Re: xtime.h's xtime_nsec: s/int/long int/? (resend)


From: Jim Meyering
Subject: Re: xtime.h's xtime_nsec: s/int/long int/? (resend)
Date: Tue, 03 Jan 2006 17:06:16 +0100

[I sent this message a few weeks ago, but it was
 mistakenly MIME-format=flowed, so not very readable]

Hi Paul,
I noticed that xtime.h's xtime_nsec function uses/returns `int':

/* Return the number of nanoseconds in T.  */
static inline long int
xtime_nsec (xtime_t t)
{
  long 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]