summaryrefslogtreecommitdiff
path: root/lib/timespec.h
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2009-10-29 11:52:34 +0100
committerJim Meyering <meyering@redhat.com>2009-10-29 11:52:34 +0100
commit02a5d9ca15dc8e71fe8af9e76e732e01c90fc703 (patch)
tree153e418f6390e90af0ca616fda253bdd95ea1e4a /lib/timespec.h
parent739294f4aaa7734eb73bed785302dc64626c4ff1 (diff)
downloadgnulib-02a5d9ca15dc8e71fe8af9e76e732e01c90fc703.tar.gz
timespec: long-to-int truncation could make timespec_cmp malfunction
* lib/timespec.h (timespec_cmp): Do not interpret a difference of a multiple of 2^32 nanoseconds as no difference.
Diffstat (limited to 'lib/timespec.h')
-rw-r--r--lib/timespec.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/timespec.h b/lib/timespec.h
index 3f51db8e4d..db3453a24c 100644
--- a/lib/timespec.h
+++ b/lib/timespec.h
@@ -1,6 +1,6 @@
/* timespec -- System time interface
- Copyright (C) 2000, 2002, 2004, 2005, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -27,7 +27,9 @@ timespec_cmp (struct timespec a, struct timespec b)
{
return (a.tv_sec < b.tv_sec ? -1
: a.tv_sec > b.tv_sec ? 1
- : a.tv_nsec - b.tv_nsec);
+ : a.tv_nsec < b.tv_nsec ? -1
+ : a.tv_nsec > b.tv_nsec ? 1
+ : 0);
}
void gettime (struct timespec *);