summaryrefslogtreecommitdiff
path: root/src/python-systemd/pyutil.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-05-08 19:46:49 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-05-08 21:35:03 -0400
commit539e0a4d583bca7db837275b07a20a933b7f8f83 (patch)
tree2a6b6a275354d289d5301bc3f1b9c6f35733ef94 /src/python-systemd/pyutil.c
parent5afbe712db5cc68213a24c45396ffb43fab05e3e (diff)
systemd-python: add wrappers for easy functions in sd-login
sd_get_uids, sd_get_seats, sd_get_sessions, and sd_get_machine_names.
Diffstat (limited to 'src/python-systemd/pyutil.c')
-rw-r--r--src/python-systemd/pyutil.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/python-systemd/pyutil.c b/src/python-systemd/pyutil.c
index 79065a11c0..9510acdddb 100644
--- a/src/python-systemd/pyutil.c
+++ b/src/python-systemd/pyutil.c
@@ -28,3 +28,19 @@ void cleanup_Py_DECREFp(PyObject **p) {
Py_DECREF(*p);
}
+
+PyObject* absolute_timeout(uint64_t t) {
+ if (t == (uint64_t) -1)
+ return PyLong_FromLong(-1);
+ else {
+ struct timespec ts;
+ uint64_t n;
+ int msec;
+
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ n = (uint64_t) ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
+ msec = t > n ? (int) ((t - n + 999) / 1000) : 0;
+
+ return PyLong_FromLong(msec);
+ }
+}