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: use dual_timestamp_get()
[elogind.git]
/
src
/
basic
/
time-util.c
diff --git
a/src/basic/time-util.c
b/src/basic/time-util.c
index f2250947d127349fe419f895ccfa6ae260fd2820..28b20f41805379dd6661974f62c3cfe141805d80 100644
(file)
--- a/
src/basic/time-util.c
+++ b/
src/basic/time-util.c
@@
-27,6
+27,7
@@
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
+#include "parse-util.h"
#include "path-util.h"
#include "string-util.h"
#include "strv.h"
#include "path-util.h"
#include "string-util.h"
#include "strv.h"
@@
-111,9
+112,8
@@
dual_timestamp* dual_timestamp_from_boottime_or_monotonic(dual_timestamp *ts, us
ts->realtime = ts->monotonic = USEC_INFINITY;
return ts;
}
ts->realtime = ts->monotonic = USEC_INFINITY;
return ts;
}
- ts->realtime = now(CLOCK_REALTIME);
- ts->monotonic = now(CLOCK_MONOTONIC);
+ dual_timestamp_get(ts);
delta = (int64_t) now(clock_boottime_or_monotonic()) - (int64_t) u;
if ((int64_t) ts->realtime > delta)
delta = (int64_t) now(clock_boottime_or_monotonic()) - (int64_t) u;
if ((int64_t) ts->realtime > delta)
@@
-666,29
+666,18
@@
int parse_timestamp(const char *t, usec_t *usec) {
parse_usec:
{
parse_usec:
{
- char *end;
- unsigned long long val;
- size_t l;
+ unsigned add;
k++;
k++;
- if (*k < '0' || *k > '9')
+ r = parse_fractional_part_u(&k, 6, &add);
+ if (r < 0)
return -EINVAL;
return -EINVAL;
- /* base 10 instead of base 0, .09 is not base 8 */
- errno = 0;
- val = strtoull(k, &end, 10);
- if (*end || errno)
+ if (*k)
return -EINVAL;
return -EINVAL;
- l = end-k;
-
- /* val has l digits, make them 6 */
- for (; l < 6; l++)
- val *= 10;
- for (; l > 6; l--)
- val /= 10;
+ x_usec = add;
- x_usec = val;
}
from_tm:
}
from_tm: