parent
18259f3b8c
commit
92af61aefe
@ -0,0 +1,81 @@
|
||||
From 2ed3d130986501e1db27d57be424d5fd82755ca5 Mon Sep 17 00:00:00 2001
|
||||
From: Lennart Poettering <lennart@poettering.net>
|
||||
Date: Fri, 12 Feb 2016 21:29:01 +0100
|
||||
Subject: [PATCH] time-util: map ALARM clockids to non-ALARM clockids in now()
|
||||
|
||||
Fixes: #2597
|
||||
(cherry picked from commit 32c1f5a57998f2a9e1992af006b83e39e3155830)
|
||||
|
||||
Resolves: #1310800
|
||||
---
|
||||
src/basic/time-util.c | 24 ++++++++++++++++++++++--
|
||||
src/libsystemd/sd-event/sd-event.c | 6 +++++-
|
||||
2 files changed, 27 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/basic/time-util.c b/src/basic/time-util.c
|
||||
index 3973850..510f018 100644
|
||||
--- a/src/basic/time-util.c
|
||||
+++ b/src/basic/time-util.c
|
||||
@@ -42,10 +42,30 @@
|
||||
|
||||
static nsec_t timespec_load_nsec(const struct timespec *ts);
|
||||
|
||||
+static clockid_t map_clock_id(clockid_t c) {
|
||||
+
|
||||
+ /* Some more exotic archs (s390, ppc, …) lack the "ALARM" flavour of the clocks. Thus, clock_gettime() will
|
||||
+ * fail for them. Since they are essentially the same as their non-ALARM pendants (their only difference is
|
||||
+ * when timers are set on them), let's just map them accordingly. This way, we can get the correct time even on
|
||||
+ * those archs. */
|
||||
+
|
||||
+ switch (c) {
|
||||
+
|
||||
+ case CLOCK_BOOTTIME_ALARM:
|
||||
+ return CLOCK_BOOTTIME;
|
||||
+
|
||||
+ case CLOCK_REALTIME_ALARM:
|
||||
+ return CLOCK_REALTIME;
|
||||
+
|
||||
+ default:
|
||||
+ return c;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
usec_t now(clockid_t clock_id) {
|
||||
struct timespec ts;
|
||||
|
||||
- assert_se(clock_gettime(clock_id, &ts) == 0);
|
||||
+ assert_se(clock_gettime(map_clock_id(clock_id), &ts) == 0);
|
||||
|
||||
return timespec_load(&ts);
|
||||
}
|
||||
@@ -53,7 +73,7 @@ usec_t now(clockid_t clock_id) {
|
||||
nsec_t now_nsec(clockid_t clock_id) {
|
||||
struct timespec ts;
|
||||
|
||||
- assert_se(clock_gettime(clock_id, &ts) == 0);
|
||||
+ assert_se(clock_gettime(map_clock_id(clock_id), &ts) == 0);
|
||||
|
||||
return timespec_load_nsec(&ts);
|
||||
}
|
||||
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
|
||||
index deef6ba..2b46a1f 100644
|
||||
--- a/src/libsystemd/sd-event/sd-event.c
|
||||
+++ b/src/libsystemd/sd-event/sd-event.c
|
||||
@@ -2780,9 +2780,13 @@ _public_ int sd_event_now(sd_event *e, clockid_t clock, uint64_t *usec) {
|
||||
*usec = e->timestamp.monotonic;
|
||||
break;
|
||||
|
||||
- default:
|
||||
+ case CLOCK_BOOTTIME:
|
||||
+ case CLOCK_BOOTTIME_ALARM:
|
||||
*usec = e->timestamp_boottime;
|
||||
break;
|
||||
+
|
||||
+ default:
|
||||
+ assert_not_reached("Unknown clock?");
|
||||
}
|
||||
|
||||
return 0;
|
||||
--
|
||||
2.5.0
|
||||
|
@ -13,7 +13,7 @@
|
||||
Name: systemd
|
||||
Url: http://www.freedesktop.org/wiki/Software/systemd
|
||||
Version: 229
|
||||
Release: 2%{?gitcommit:.git%{gitcommitshort}}%{?dist}
|
||||
Release: 3%{?gitcommit:.git%{gitcommitshort}}%{?dist}
|
||||
# For a breakdown of the licensing, see README
|
||||
License: LGPLv2+ and MIT and GPLv2+
|
||||
Summary: A System and Service Manager
|
||||
@ -34,6 +34,8 @@ Source7: systemd-journal-remote.xml
|
||||
Source8: systemd-journal-gatewayd.xml
|
||||
Source9: 20-yama-ptrace.conf
|
||||
|
||||
Patch0001: 0001-time-util-map-ALARM-clockids-to-non-ALARM-clockids-i.patch
|
||||
|
||||
Patch0999: 0999-Add-a-workaround-for-linux-net-if.h-conflict.patch
|
||||
|
||||
# kernel-install patch for grubby, drop if grubby is obsolete
|
||||
@ -806,6 +808,9 @@ getent passwd systemd-journal-upload >/dev/null 2>&1 || useradd -r -l -g systemd
|
||||
/usr/lib/firewalld/services/*
|
||||
|
||||
%changelog
|
||||
* Tue Feb 23 2016 Jan Synáček <jsynacek@redhat.com> - 229-3
|
||||
- Fix build failures on ppc64 (#1310800)
|
||||
|
||||
* Tue Feb 16 2016 Dennis Gilmore <dennis@ausil.us> - 229-2
|
||||
- revert: fixed kernel-install for copying files for grubby
|
||||
Resolves: rhbz#1299019
|
||||
|
Loading…
Reference in New Issue
Block a user