summaryrefslogtreecommitdiff
path: root/lib/timespec-add.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2013-09-19 14:12:29 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2013-09-19 14:33:08 -0700
commitcf0e1bcdc666748ef2bcb38f806cac432936090d (patch)
treeba7019e213542ec8b10d8c03f18e7d31bd685209 /lib/timespec-add.c
parent6f3c76e0dc5cb93b7e0d1db77143ad9ef2e773b7 (diff)
downloadgnulib-cf0e1bcdc666748ef2bcb38f806cac432936090d.tar.gz
timespec: new function make_timespec, and new constants
* lib/timespec.h: Incorporate recent changes on the Emacs trunk. (TIMESPEC_RESOLUTION, LOG10_TIMESPEC_RESOLUTION): New constants. (make_timespec): New function. * lib/dtotimespec.c (dtotimespec): * lib/timespec-add.c (timespec_add): * lib/timespec-sub.c (timespec_sub): * lib/utimens.c (validate_timespec): * lib/utimensat.c (rpl_utimensat): Use these new constants and functions.
Diffstat (limited to 'lib/timespec-add.c')
-rw-r--r--lib/timespec-add.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/lib/timespec-add.c b/lib/timespec-add.c
index 6ce2c73064..51323a6320 100644
--- a/lib/timespec-add.c
+++ b/lib/timespec-add.c
@@ -28,11 +28,10 @@
struct timespec
timespec_add (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;
- int nsd = ns - 1000000000;
+ int nsd = ns - TIMESPEC_RESOLUTION;
int rns = ns;
if (0 <= nsd)
@@ -65,7 +64,5 @@ timespec_add (struct timespec a, struct timespec b)
else
rs += bs;
- r.tv_sec = rs;
- r.tv_nsec = rns;
- return r;
+ return make_timespec (rs, rns);
}