summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-06-17 15:59:18 +0200
committerLennart Poettering <lennart@poettering.net>2011-06-21 19:29:45 +0200
commita185c5aa2d8bef98716f8cf160da263c17e588b2 (patch)
treeef6ff057c606efefe86b34503fe92bf40cf05b6d /src/util.c
parent91f9dcaf9270fe465525638cc08bd94590273349 (diff)
logind: implement idle hint logic
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index 2047ebd7bd..08529cc235 100644
--- a/src/util.c
+++ b/src/util.c
@@ -108,6 +108,28 @@ dual_timestamp* dual_timestamp_get(dual_timestamp *ts) {
return ts;
}
+dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u) {
+ int64_t delta;
+ assert(ts);
+
+ ts->realtime = u;
+
+ if (u == 0)
+ ts->monotonic = 0;
+ else {
+ delta = (int64_t) now(CLOCK_REALTIME) - (int64_t) u;
+
+ ts->monotonic = now(CLOCK_MONOTONIC);
+
+ if ((int64_t) ts->monotonic > delta)
+ ts->monotonic -= delta;
+ else
+ ts->monotonic = 0;
+ }
+
+ return ts;
+}
+
usec_t timespec_load(const struct timespec *ts) {
assert(ts);