chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
time-util: rename usec_sub() to usec_sub_signed() and add usec_sub_unsigned()
[elogind.git]
/
src
/
basic
/
time-util.h
diff --git
a/src/basic/time-util.h
b/src/basic/time-util.h
index 2ea7e8b511173c461fe7d3523e442d1356530d0d..a6df932ad2040cbfabe6bd1b2514749d6451a39f 100644
(file)
--- a/
src/basic/time-util.h
+++ b/
src/basic/time-util.h
@@
-191,19
+191,23
@@
static inline usec_t usec_add(usec_t a, usec_t b) {
return c;
}
return c;
}
-static inline usec_t usec_sub(usec_t timestamp, int64_t delta) {
- if (delta < 0)
- return usec_add(timestamp, (usec_t) (-delta));
+static inline usec_t usec_sub_unsigned(usec_t timestamp, usec_t delta) {
if (timestamp == USEC_INFINITY) /* Make sure infinity doesn't degrade */
return USEC_INFINITY;
if (timestamp == USEC_INFINITY) /* Make sure infinity doesn't degrade */
return USEC_INFINITY;
-
- if (timestamp < (usec_t) delta)
+ if (timestamp < delta)
return 0;
return timestamp - delta;
}
return 0;
return timestamp - delta;
}
+static inline usec_t usec_sub_signed(usec_t timestamp, int64_t delta) {
+ if (delta < 0)
+ return usec_add(timestamp, (usec_t) (-delta));
+ else
+ return usec_sub_unsigned(timestamp, (usec_t) delta);
+}
+
#if SIZEOF_TIME_T == 8
/* The last second we can format is 31. Dec 9999, 1s before midnight, because otherwise we'd enter 5 digit year
* territory. However, since we want to stay away from this in all timezones we take one day off. */
#if SIZEOF_TIME_T == 8
/* The last second we can format is 31. Dec 9999, 1s before midnight, because otherwise we'd enter 5 digit year
* territory. However, since we want to stay away from this in all timezones we take one day off. */