summaryrefslogtreecommitdiff
path: root/src/systemd
diff options
context:
space:
mode:
authorNathaniel McCallum <npmccallum@redhat.com>2018-01-22 16:26:44 -0500
committerSven Eden <yamakuzure@gmx.net>2018-05-30 07:50:14 +0200
commit8b42f5e6cdc1c819741ef9492b7cec23971ccc4c (patch)
treee3596c5b52899b308cecfea1f945c5a2219a2bbe /src/systemd
parent269ddd6aecc9307853384bfc44a22c9ade596f34 (diff)
Add support for SD_BUS_DEFAULT*
Currently, sd-bus supports the ability to have thread-local default busses. However, this is less useful than it can be since all functions which require an sd_bus* as input require the caller to pass it. This patch adds a new macro which allows the developer to pass a constant SD_BUS_DEFAULT, SD_BUS_DEFAULT_USER or SD_BUS_DEFAULT_SYSTEM instead. This reduces work for the caller. For example: r = sd_bus_default(&bus); r = sd_bus_call_method(bus, ...); sd_bus_unref(bus); Becomes: r = sd_bus_call_method(SD_BUS_DEFAULT, ...); If the specified thread-local default bus does not exist, the function calls will return -ENOPKG. No bus will ever be implicitly created.
Diffstat (limited to 'src/systemd')
-rw-r--r--src/systemd/sd-bus.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index d15278555..e17d17683 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -33,6 +33,10 @@
_SD_BEGIN_DECLARATIONS;
+#define SD_BUS_DEFAULT ((sd_bus *) 1)
+#define SD_BUS_DEFAULT_USER ((sd_bus *) 2)
+#define SD_BUS_DEFAULT_SYSTEM ((sd_bus *) 3)
+
/* Types */
typedef struct sd_bus sd_bus;