]> code.delx.au - gnu-emacs/blobdiff - lib/timespec-sub.c
Merge from gnulib.
[gnu-emacs] / lib / timespec-sub.c
index 97c9f9de88c448ff6794eb743d2a3c70059d8ab8..b164a8380d0b2ce4beffcf11b915d57184b74d25 100644 (file)
@@ -29,7 +29,6 @@
 struct timespec
 timespec_sub (struct timespec a, struct timespec b)
 {
-  struct timespec r;
   time_t rs = a.tv_sec;
   time_t bs = b.tv_sec;
   int ns = a.tv_nsec - b.tv_nsec;
@@ -37,7 +36,7 @@ timespec_sub (struct timespec a, struct timespec b)
 
   if (ns < 0)
     {
-      rns = ns + 1000000000;
+      rns = ns + TIMESPEC_RESOLUTION;
       if (rs == TYPE_MINIMUM (time_t))
         {
           if (bs <= 0)
@@ -65,7 +64,5 @@ timespec_sub (struct timespec a, struct timespec b)
   else
     rs -= bs;
 
-  r.tv_sec = rs;
-  r.tv_nsec = rns;
-  return r;
+  return make_timespec (rs, rns);
 }