/* Creates a "timestamp" file, that contains nothing but a
* usec_t timestamp, formatted in ASCII. */
- if (n <= 0 || n >= USEC_INFINITY)
+ if (!timestamp_is_set(n))
return -ERANGE;
xsprintf(ln, USEC_FMT "\n", n);
if (r < 0)
return r;
- if (t <= 0 || t >= (uint64_t) USEC_INFINITY)
+ if (!timestamp_is_set(t))
return -ERANGE;
*ret = (usec_t) t;
dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u) {
assert(ts);
- if (u == USEC_INFINITY || u == 0) {
+ if (!timestamp_is_set(u)) {
ts->realtime = ts->monotonic = u;
return ts;
}
assert(ts);
- if (u == USEC_INFINITY || u == 0) {
+ if (!timestamp_is_set(u)) {
ts->realtime = ts->monotonic = ts->boottime = u;
return ts;
}
1 + 1 + /* space and shortest possible zone */
1))
return NULL; /* Not enough space even for the shortest form. */
- if (t <= 0 || t == USEC_INFINITY)
+ if (!timestamp_is_set(t))
return NULL; /* Timestamp is unset */
if (style == TIMESTAMP_UNIX) {
const char *s;
usec_t n, d;
- if (t <= 0 || t == USEC_INFINITY)
+ if (!timestamp_is_set(t))
return NULL;
n = now(CLOCK_REALTIME);
assert(fd >= 0);
- if (IN_SET(usec, 0, USEC_INFINITY))
+ if (!timestamp_is_set(usec))
usec = now(CLOCK_REALTIME);
le = htole64((uint64_t) usec);
assert(s);
watchdog_usec = service_get_watchdog_usec(s);
- if (IN_SET(watchdog_usec, 0, USEC_INFINITY)) {
+ if (!timestamp_is_set(watchdog_usec)) {
service_stop_watchdog(s);
return;
}
assert(s);
- if (IN_SET(extend_timeout_usec, 0, USEC_INFINITY))
+ if (!timestamp_is_set(extend_timeout_usec))
return;
extended = usec_add(now(CLOCK_MONOTONIC), extend_timeout_usec);
/* Use the packet's timestamp if there is one known */
base = triple_timestamp_by_clock(&n->timestamp, clock_boottime_or_monotonic());
- if (base <= 0 || base == USEC_INFINITY)
+ if (!timestamp_is_set(base))
base = now(clock_boottime_or_monotonic()); /* Otherwise, take the current time */
n->until = usec_add(base, n->ttl * USEC_PER_SEC);
r = safe_atou64(s, &u);
if (r < 0)
goto finish;
- if (u <= 0 || u >= USEC_INFINITY) {
+ if (!timestamp_is_set(u)) {
r = -EINVAL;
goto finish;
}
assert(realtime);
x = timespec_load(&st->st_ctim);
- if (x > 0 && x != USEC_INFINITY && x < *realtime)
+ if (timestamp_is_set(x) && x < *realtime)
*realtime = x;
x = timespec_load(&st->st_atim);
- if (x > 0 && x != USEC_INFINITY && x < *realtime)
+ if (timestamp_is_set(x) && x < *realtime)
*realtime = x;
x = timespec_load(&st->st_mtim);
- if (x > 0 && x != USEC_INFINITY && x < *realtime)
+ if (timestamp_is_set(x) && x < *realtime)
*realtime = x;
/* Let's read the original creation time, if possible. Ideally we'd just query the creation time the
else
printf("%"PRIu32"\n", i.uid);
- if (i.timestamp.realtime > 0 && i.timestamp.realtime < USEC_INFINITY)
+ if (timestamp_is_set(i.timestamp.realtime))
printf("\t Since: %s; %s\n",
FORMAT_TIMESTAMP(i.timestamp.realtime),
FORMAT_TIMESTAMP_RELATIVE(i.timestamp.realtime));
else
printf("%"PRIu32"\n", i.uid);
- if (i.timestamp.realtime > 0 && i.timestamp.realtime < USEC_INFINITY)
+ if (timestamp_is_set(i.timestamp.realtime))
printf("\t Since: %s; %s\n",
FORMAT_TIMESTAMP(i.timestamp.realtime),
FORMAT_TIMESTAMP_RELATIVE(i.timestamp.realtime));
assert(!u->timer_event_source);
user_stop_delay = user_get_stop_delay(u);
- if (IN_SET(user_stop_delay, 0, USEC_INFINITY))
+ if (!timestamp_is_set(user_stop_delay))
return;
if (sd_event_get_state(u->manager->event) == SD_EVENT_FINISHED) {
i->read_only ? "read-only" : "writable",
i->read_only ? ansi_normal() : "");
- if (i->crtime > 0 && i->crtime < USEC_INFINITY)
+ if (timestamp_is_set(i->crtime))
printf("\t Created: %s; %s\n",
FORMAT_TIMESTAMP(i->crtime), FORMAT_TIMESTAMP_RELATIVE(i->crtime));
- if (i->mtime > 0 && i->mtime < USEC_INFINITY)
+ if (timestamp_is_set(i->mtime))
printf("\tModified: %s; %s\n",
FORMAT_TIMESTAMP(i->mtime), FORMAT_TIMESTAMP_RELATIVE(i->mtime));
STRPTR_IN_SET(i->active_state, "activating") ? i->inactive_exit_timestamp :
i->active_exit_timestamp;
- if (timestamp > 0 && timestamp < USEC_INFINITY) {
+ if (timestamp_is_set(timestamp)) {
printf(" since %s; %s\n",
FORMAT_TIMESTAMP_STYLE(timestamp, arg_timestamp_style),
FORMAT_TIMESTAMP_RELATIVE(timestamp));
dual_timestamp_get(&nw);
next_elapse = calc_next_elapse(&nw, &next);
- if (next_elapse > 0 && next_elapse < USEC_INFINITY)
+ if (timestamp_is_set(next_elapse))
printf(" Trigger: %s; %s\n",
FORMAT_TIMESTAMP_STYLE(next_elapse, arg_timestamp_style),
FORMAT_TIMESTAMP_RELATIVE(next_elapse));