dovecot-2.2: lib: Added support for adding milliseconds to struc...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Sep 30 21:09:21 UTC 2014
details: http://hg.dovecot.org/dovecot-2.2/rev/bad8e61e2e88
changeset: 17854:bad8e61e2e88
user: Stephan Bosch <stephan at rename-it.nl>
date: Wed Oct 01 00:06:19 2014 +0300
description:
lib: Added support for adding milliseconds to struct timeval time values.
diffstat:
src/lib/time-util.h | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diffs (32 lines):
diff -r d80395660f27 -r bad8e61e2e88 src/lib/time-util.h
--- a/src/lib/time-util.h Wed Oct 01 00:03:17 2014 +0300
+++ b/src/lib/time-util.h Wed Oct 01 00:06:19 2014 +0300
@@ -11,6 +11,28 @@
long long timeval_diff_usecs(const struct timeval *tv1,
const struct timeval *tv2);
+static inline void
+timeval_add_msecs(struct timeval *tv, unsigned int msecs)
+{
+ tv->tv_sec += msecs / 1000;
+ tv->tv_usec += (msecs % 1000) * 1000;
+ if (tv->tv_usec >= 1000000) {
+ tv->tv_sec++;
+ tv->tv_usec -= 1000000;
+ }
+}
+
+static inline void
+timeval_sub_msecs(struct timeval *tv, unsigned int msecs)
+{
+ tv->tv_sec -= msecs / 1000;
+ tv->tv_usec -= (msecs % 1000) * 1000;
+ if (tv->tv_usec < 0) {
+ tv->tv_sec--;
+ tv->tv_usec += 1000000;
+ }
+}
+
/* Wrapper to strftime() */
const char *t_strflocaltime(const char *fmt, time_t t) ATTR_STRFTIME(1);
More information about the dovecot-cvs
mailing list