chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
basic/escape: merge utf8 and non-utf8 paths in cunescape_one
[elogind.git]
/
src
/
basic
/
time-util.c
diff --git
a/src/basic/time-util.c
b/src/basic/time-util.c
index 7fb3745d6c317f1dc0109f070d13c85d5388ed55..34061fea9e51785eb974f2671cf6f73b3134956c 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"
@@
-41,8
+42,7
@@
usec_t now(clockid_t clock_id) {
return timespec_load(&ts);
}
return timespec_load(&ts);
}
-/// UNNEEDED by elogind
-#if 0
+#if 0 /// UNNEEDED by elogind
nsec_t now_nsec(clockid_t clock_id) {
struct timespec ts;
nsec_t now_nsec(clockid_t clock_id) {
struct timespec ts;
@@
-83,8
+83,7
@@
dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u) {
return ts;
}
return ts;
}
-/// UNNEEDED by elogind
-#if 0
+#if 0 /// UNNEEDED by elogind
dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u) {
int64_t delta;
assert(ts);
dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u) {
int64_t delta;
assert(ts);
@@
-226,8
+225,7
@@
char *format_timestamp(char *buf, size_t l, usec_t t) {
return format_timestamp_internal(buf, l, t, false);
}
return format_timestamp_internal(buf, l, t, false);
}
-/// UNNEEDED by elogind
-#if 0
+#if 0 /// UNNEEDED by elogind
char *format_timestamp_utc(char *buf, size_t l, usec_t t) {
return format_timestamp_internal(buf, l, t, true);
}
char *format_timestamp_utc(char *buf, size_t l, usec_t t) {
return format_timestamp_internal(buf, l, t, true);
}
@@
-259,8
+257,7
@@
char *format_timestamp_us(char *buf, size_t l, usec_t t) {
return format_timestamp_internal_us(buf, l, t, false);
}
return format_timestamp_internal_us(buf, l, t, false);
}
-/// UNNEEDED by elogind
-#if 0
+#if 0 /// UNNEEDED by elogind
char *format_timestamp_us_utc(char *buf, size_t l, usec_t t) {
return format_timestamp_internal_us(buf, l, t, true);
}
char *format_timestamp_us_utc(char *buf, size_t l, usec_t t) {
return format_timestamp_internal_us(buf, l, t, true);
}
@@
-439,8
+436,7
@@
char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy) {
return buf;
}
return buf;
}
-/// UNNEEDED by elogind
-#if 0
+#if 0 /// UNNEEDED by elogind
void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t) {
assert(f);
void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t) {
assert(f);
@@
-671,29
+667,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:
@@
-852,8
+837,7
@@
int parse_sec(const char *t, usec_t *usec) {
return parse_time(t, usec, USEC_PER_SEC);
}
return parse_time(t, usec, USEC_PER_SEC);
}
-/// UNNEEDED by elogind
-#if 0
+#if 0 /// UNNEEDED by elogind
int parse_nsec(const char *t, nsec_t *nsec) {
static const struct {
const char *suffix;
int parse_nsec(const char *t, nsec_t *nsec) {
static const struct {
const char *suffix;
@@
-1150,8
+1134,7
@@
struct tm *localtime_or_gmtime_r(const time_t *t, struct tm *tm, bool utc) {
return utc ? gmtime_r(t, tm) : localtime_r(t, tm);
}
return utc ? gmtime_r(t, tm) : localtime_r(t, tm);
}
-/// UNNEEDED by elogind
-#if 0
+#if 0 /// UNNEEDED by elogind
unsigned long usec_to_jiffies(usec_t u) {
static thread_local unsigned long hz = 0;
long r;
unsigned long usec_to_jiffies(usec_t u) {
static thread_local unsigned long hz = 0;
long r;