summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/analyze/analyze-verify.c1
-rw-r--r--src/core/all-units.h14
-rw-r--r--src/core/automount.h2
-rw-r--r--src/core/dbus-scope.h2
-rw-r--r--src/core/dbus.c1
-rw-r--r--src/core/device.h4
-rw-r--r--src/core/dynamic-user.c1
-rw-r--r--src/core/execute.c1
-rw-r--r--src/core/load-fragment-gperf.gperf.m42
-rw-r--r--src/core/load-fragment.c2
-rw-r--r--src/core/main.c1
-rw-r--r--src/core/manager.c2
-rw-r--r--src/core/manager.h1
-rw-r--r--src/core/mount.c1
-rw-r--r--src/core/mount.h3
-rw-r--r--src/core/path.h2
-rw-r--r--src/core/scope.h2
-rw-r--r--src/core/service.h4
-rw-r--r--src/core/slice.h4
-rw-r--r--src/core/socket.h3
-rw-r--r--src/core/swap.c1
-rw-r--r--src/core/swap.h3
-rw-r--r--src/core/target.h4
-rw-r--r--src/core/timer.h3
-rw-r--r--src/core/unit.c1
-rw-r--r--src/core/unit.h43
-rw-r--r--src/test/test-execute.c1
-rw-r--r--src/test/test-path.c1
-rw-r--r--src/test/test-sched-prio.c1
-rw-r--r--src/test/test-unit-file.c1
-rw-r--r--src/test/test-unit-name.c1
-rw-r--r--src/test/test-watch-pid.c1
32 files changed, 79 insertions, 35 deletions
diff --git a/src/analyze/analyze-verify.c b/src/analyze/analyze-verify.c
index 90c10f575a..694ecc7287 100644
--- a/src/analyze/analyze-verify.c
+++ b/src/analyze/analyze-verify.c
@@ -8,6 +8,7 @@
#include <stdlib.h>
#include "alloc-util.h"
+#include "all-units.h"
#include "analyze-verify.h"
#include "bus-error.h"
#include "bus-util.h"
diff --git a/src/core/all-units.h b/src/core/all-units.h
new file mode 100644
index 0000000000..ed8350ebe0
--- /dev/null
+++ b/src/core/all-units.h
@@ -0,0 +1,14 @@
+#pragma once
+
+#include "unit.h"
+
+#include "automount.h"
+#include "device.h"
+#include "path.h"
+#include "scope.h"
+#include "service.h"
+#include "slice.h"
+#include "socket.h"
+#include "swap.h"
+#include "target.h"
+#include "timer.h"
diff --git a/src/core/automount.h b/src/core/automount.h
index f017b8c7ee..bdadb55478 100644
--- a/src/core/automount.h
+++ b/src/core/automount.h
@@ -45,3 +45,5 @@ extern const UnitVTable automount_vtable;
const char* automount_result_to_string(AutomountResult i) _const_;
AutomountResult automount_result_from_string(const char *s) _pure_;
+
+DEFINE_CAST(AUTOMOUNT, Automount);
diff --git a/src/core/dbus-scope.h b/src/core/dbus-scope.h
index f055b70aac..115886b134 100644
--- a/src/core/dbus-scope.h
+++ b/src/core/dbus-scope.h
@@ -9,7 +9,7 @@
#include "sd-bus.h"
-#include "unit.h"
+#include "scope.h"
extern const sd_bus_vtable bus_scope_vtable[];
diff --git a/src/core/dbus.c b/src/core/dbus.c
index 47492835ee..9e39d8ab7f 100644
--- a/src/core/dbus.c
+++ b/src/core/dbus.c
@@ -30,6 +30,7 @@
#include "mkdir.h"
#include "process-util.h"
#include "selinux-access.h"
+#include "service.h"
#include "special.h"
#include "string-util.h"
#include "strv.h"
diff --git a/src/core/device.h b/src/core/device.h
index d52700b66f..f188640c59 100644
--- a/src/core/device.h
+++ b/src/core/device.h
@@ -7,6 +7,8 @@
Copyright 2010 Lennart Poettering
***/
+#include "unit.h"
+
typedef struct Device Device;
typedef enum DeviceFound {
@@ -37,3 +39,5 @@ extern const UnitVTable device_vtable;
int device_found_node(Manager *m, const char *node, bool add, DeviceFound found, bool now);
bool device_shall_be_bound_by(Unit *device, Unit *u);
+
+DEFINE_CAST(DEVICE, Device);
diff --git a/src/core/dynamic-user.c b/src/core/dynamic-user.c
index 1f4ed576d9..05ccc8c854 100644
--- a/src/core/dynamic-user.c
+++ b/src/core/dynamic-user.c
@@ -17,6 +17,7 @@
#include "io-util.h"
#include "parse-util.h"
#include "random-util.h"
+#include "socket-util.h"
#include "stdio-util.h"
#include "string-util.h"
#include "user-util.h"
diff --git a/src/core/execute.c b/src/core/execute.c
index ecc7e8821a..fca20c5567 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -86,6 +86,7 @@
#include "selinux-util.h"
#include "signal-util.h"
#include "smack-util.h"
+#include "socket-util.h"
#include "special.h"
#include "stat-util.h"
#include "string-table.h"
diff --git a/src/core/load-fragment-gperf.gperf.m4 b/src/core/load-fragment-gperf.gperf.m4
index 5d90a7c054..001837463b 100644
--- a/src/core/load-fragment-gperf.gperf.m4
+++ b/src/core/load-fragment-gperf.gperf.m4
@@ -6,6 +6,8 @@ _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
#include "conf-parser.h"
#include "load-fragment.h"
#include "missing.h"
+
+#include "all-units.h"
%}
struct ConfigPerfItem;
%null_strings
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index a78039bb4f..e17987bf07 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -20,6 +20,7 @@
#include "af-list.h"
#include "alloc-util.h"
+#include "all-units.h"
#include "bus-error.h"
#include "bus-internal.h"
#include "bus-util.h"
@@ -57,7 +58,6 @@
#include "strv.h"
#include "unit-name.h"
#include "unit-printf.h"
-#include "unit.h"
#include "user-util.h"
#include "utf8.h"
#include "web-util.h"
diff --git a/src/core/main.c b/src/core/main.c
index 201882ca95..978434038e 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -40,6 +40,7 @@
#include "def.h"
#include "emergency-action.h"
#include "env-util.h"
+#include "exit-status.h"
#include "fd-util.h"
#include "fdset.h"
#include "fileio.h"
diff --git a/src/core/manager.c b/src/core/manager.c
index 6412fee476..a4cea85136 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -28,6 +28,7 @@
#include "sd-path.h"
#include "alloc-util.h"
+#include "all-units.h"
#include "audit-fd.h"
#include "boot-timestamps.h"
#include "bus-common-errors.h"
@@ -65,6 +66,7 @@
#include "ratelimit.h"
#include "rm-rf.h"
#include "signal-util.h"
+#include "socket-util.h"
#include "special.h"
#include "stat-util.h"
#include "string-table.h"
diff --git a/src/core/manager.h b/src/core/manager.h
index 35a3a1eb40..f41cce1c09 100644
--- a/src/core/manager.h
+++ b/src/core/manager.h
@@ -21,6 +21,7 @@
#include "ratelimit.h"
struct libmnt_monitor;
+typedef struct Unit Unit;
/* Enforce upper limit how many names we allow */
#define MANAGER_MAX_NAMES 131072 /* 128K */
diff --git a/src/core/mount.c b/src/core/mount.c
index 968ed104da..d5463b7621 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -16,6 +16,7 @@
#include "alloc-util.h"
#include "dbus-mount.h"
+#include "device.h"
#include "escape.h"
#include "exit-status.h"
#include "format-util.h"
diff --git a/src/core/mount.h b/src/core/mount.h
index 08a4cfe61f..71dac128c2 100644
--- a/src/core/mount.h
+++ b/src/core/mount.h
@@ -11,6 +11,7 @@ typedef struct Mount Mount;
#include "kill.h"
#include "dynamic-user.h"
+#include "unit.h"
typedef enum MountExecCommand {
MOUNT_EXEC_MOUNT,
@@ -97,3 +98,5 @@ MountExecCommand mount_exec_command_from_string(const char *s) _pure_;
const char* mount_result_to_string(MountResult i) _const_;
MountResult mount_result_from_string(const char *s) _pure_;
+
+DEFINE_CAST(MOUNT, Mount);
diff --git a/src/core/path.h b/src/core/path.h
index ca7dac227d..2aa2ca111f 100644
--- a/src/core/path.h
+++ b/src/core/path.h
@@ -79,3 +79,5 @@ PathType path_type_from_string(const char *s) _pure_;
const char* path_result_to_string(PathResult i) _const_;
PathResult path_result_from_string(const char *s) _pure_;
+
+DEFINE_CAST(PATH, Path);
diff --git a/src/core/scope.h b/src/core/scope.h
index 6e314eeda3..e74014119d 100644
--- a/src/core/scope.h
+++ b/src/core/scope.h
@@ -46,3 +46,5 @@ int scope_abandon(Scope *s);
const char* scope_result_to_string(ScopeResult i) _const_;
ScopeResult scope_result_from_string(const char *s) _pure_;
+
+DEFINE_CAST(SCOPE, Scope);
diff --git a/src/core/service.h b/src/core/service.h
index 116d5d119f..6d64f8e9e6 100644
--- a/src/core/service.h
+++ b/src/core/service.h
@@ -14,6 +14,8 @@ typedef struct ServiceFDStore ServiceFDStore;
#include "kill.h"
#include "path.h"
#include "ratelimit.h"
+#include "socket.h"
+#include "unit.h"
typedef enum ServiceRestart {
SERVICE_RESTART_NO,
@@ -204,3 +206,5 @@ NotifyState notify_state_from_string(const char *s) _pure_;
const char* service_result_to_string(ServiceResult i) _const_;
ServiceResult service_result_from_string(const char *s) _pure_;
+
+DEFINE_CAST(SERVICE, Service);
diff --git a/src/core/slice.h b/src/core/slice.h
index 7d48fafa3a..0ab479467c 100644
--- a/src/core/slice.h
+++ b/src/core/slice.h
@@ -7,6 +7,8 @@
Copyright 2013 Lennart Poettering
***/
+#include "unit.h"
+
typedef struct Slice Slice;
struct Slice {
@@ -18,3 +20,5 @@ struct Slice {
};
extern const UnitVTable slice_vtable;
+
+DEFINE_CAST(SLICE, Slice);
diff --git a/src/core/socket.h b/src/core/socket.h
index ce9452dbd6..8a9559d5c6 100644
--- a/src/core/socket.h
+++ b/src/core/socket.h
@@ -13,6 +13,7 @@ typedef struct SocketPeer SocketPeer;
#include "mount.h"
#include "service.h"
#include "socket-util.h"
+#include "unit.h"
typedef enum SocketExecCommand {
SOCKET_EXEC_START_PRE,
@@ -182,3 +183,5 @@ SocketResult socket_result_from_string(const char *s) _pure_;
const char* socket_port_type_to_string(SocketPort *p) _pure_;
SocketType socket_port_type_from_string(const char *p) _pure_;
+
+DEFINE_CAST(SOCKET, Socket);
diff --git a/src/core/swap.c b/src/core/swap.c
index 618a8d553d..e75c9f2464 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -14,6 +14,7 @@
#include "alloc-util.h"
#include "dbus-swap.h"
+#include "device.h"
#include "escape.h"
#include "exit-status.h"
#include "fd-util.h"
diff --git a/src/core/swap.h b/src/core/swap.h
index ec29ccfa6e..fdb14e667a 100644
--- a/src/core/swap.h
+++ b/src/core/swap.h
@@ -9,6 +9,7 @@
***/
#include "libudev.h"
+#include "unit.h"
typedef struct Swap Swap;
@@ -95,3 +96,5 @@ SwapExecCommand swap_exec_command_from_string(const char *s) _pure_;
const char* swap_result_to_string(SwapResult i) _const_;
SwapResult swap_result_from_string(const char *s) _pure_;
+
+DEFINE_CAST(SWAP, Swap);
diff --git a/src/core/target.h b/src/core/target.h
index 2b099c2513..4a2dea17ed 100644
--- a/src/core/target.h
+++ b/src/core/target.h
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
+#include "unit.h"
+
/***
This file is part of systemd.
@@ -16,3 +18,5 @@ struct Target {
};
extern const UnitVTable target_vtable;
+
+DEFINE_CAST(TARGET, Target);
diff --git a/src/core/timer.h b/src/core/timer.h
index 728afba9bd..0588a96ca2 100644
--- a/src/core/timer.h
+++ b/src/core/timer.h
@@ -10,6 +10,7 @@
typedef struct Timer Timer;
#include "calendarspec.h"
+#include "unit.h"
typedef enum TimerBase {
TIMER_ACTIVE,
@@ -77,3 +78,5 @@ TimerBase timer_base_from_string(const char *s) _pure_;
const char* timer_result_to_string(TimerResult i) _const_;
TimerResult timer_result_from_string(const char *s) _pure_;
+
+DEFINE_CAST(TIMER, Timer);
diff --git a/src/core/unit.c b/src/core/unit.c
index 13e00a25c8..c7320240f7 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -16,6 +16,7 @@
#include "sd-messages.h"
#include "alloc-util.h"
+#include "all-units.h"
#include "bus-common-errors.h"
#include "bus-util.h"
#include "cgroup-util.h"
diff --git a/src/core/unit.h b/src/core/unit.h
index 26194ef35a..767cd96aeb 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -11,11 +11,6 @@
#include <stdlib.h>
#include <unistd.h>
-typedef struct Unit Unit;
-typedef struct UnitVTable UnitVTable;
-typedef struct UnitRef UnitRef;
-typedef struct UnitStatusMessageFormats UnitStatusMessageFormats;
-
#include "bpf-program.h"
#include "condition.h"
#include "emergency-action.h"
@@ -24,6 +19,8 @@ typedef struct UnitStatusMessageFormats UnitStatusMessageFormats;
#include "unit-name.h"
#include "cgroup.h"
+typedef struct UnitRef UnitRef;
+
typedef enum KillOperation {
KILL_TERMINATE,
KILL_TERMINATE_AND_LOG,
@@ -120,7 +117,7 @@ typedef enum UnitCGroupBPFState {
UNIT_CGROUP_BPF_INVALIDATED = -1,
} UnitCGroupBPFState;
-struct Unit {
+typedef struct Unit {
Manager *manager;
UnitType type;
@@ -358,13 +355,13 @@ struct Unit {
/* When writing transient unit files, stores which section we stored last. If < 0, we didn't write any yet. If
* == 0 we are in the [Unit] section, if > 0 we are in the unit type-specific section. */
int last_section_private:2;
-};
+} Unit;
-struct UnitStatusMessageFormats {
+typedef struct UnitStatusMessageFormats {
const char *starting_stopping[2];
const char *finished_start_job[_JOB_RESULT_MAX];
const char *finished_stop_job[_JOB_RESULT_MAX];
-};
+} UnitStatusMessageFormats;
/* Flags used when writing drop-in files or transient unit files */
typedef enum UnitWriteFlags {
@@ -387,17 +384,9 @@ typedef enum UnitWriteFlags {
/* Returns true if neither persistent, nor runtime storage is requested, i.e. this is a check invocation only */
#define UNIT_WRITE_FLAGS_NOOP(flags) (((flags) & (UNIT_RUNTIME|UNIT_PERSISTENT)) == 0)
-#include "automount.h"
-#include "device.h"
-#include "path.h"
-#include "scope.h"
-#include "slice.h"
-#include "socket.h"
-#include "swap.h"
-#include "target.h"
-#include "timer.h"
-
-struct UnitVTable {
+#include "kill.h"
+
+typedef struct UnitVTable {
/* How much memory does an object of this unit type need */
size_t object_size;
@@ -566,7 +555,7 @@ struct UnitVTable {
/* True if queued jobs of this type should be GC'ed if no other job needs them anymore */
bool gc_jobs:1;
-};
+} UnitVTable;
extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
@@ -590,18 +579,6 @@ extern const UnitVTable * const unit_vtable[_UNIT_TYPE_MAX];
#define UNIT_TRIGGER(u) ((Unit*) hashmap_first_key((u)->dependencies[UNIT_TRIGGERS]))
-DEFINE_CAST(SERVICE, Service);
-DEFINE_CAST(SOCKET, Socket);
-DEFINE_CAST(TARGET, Target);
-DEFINE_CAST(DEVICE, Device);
-DEFINE_CAST(MOUNT, Mount);
-DEFINE_CAST(AUTOMOUNT, Automount);
-DEFINE_CAST(SWAP, Swap);
-DEFINE_CAST(TIMER, Timer);
-DEFINE_CAST(PATH, Path);
-DEFINE_CAST(SLICE, Slice);
-DEFINE_CAST(SCOPE, Scope);
-
Unit *unit_new(Manager *m, size_t size);
void unit_free(Unit *u);
DEFINE_TRIVIAL_CLEANUP_FUNC(Unit *, unit_free);
diff --git a/src/test/test-execute.c b/src/test/test-execute.c
index 730dfd1e0b..20202c9421 100644
--- a/src/test/test-execute.c
+++ b/src/test/test-execute.c
@@ -24,6 +24,7 @@
#if HAVE_SECCOMP
#include "seccomp-util.h"
#endif
+#include "service.h"
#include "stat-util.h"
#include "test-helper.h"
#include "tests.h"
diff --git a/src/test/test-path.c b/src/test/test-path.c
index ed53177dcc..cdc2375d56 100644
--- a/src/test/test-path.c
+++ b/src/test/test-path.c
@@ -11,6 +11,7 @@
#include <sys/types.h>
#include "alloc-util.h"
+#include "all-units.h"
#include "fd-util.h"
#include "fs-util.h"
#include "macro.h"
diff --git a/src/test/test-sched-prio.c b/src/test/test-sched-prio.c
index 7d8fc445ec..da0f858142 100644
--- a/src/test/test-sched-prio.c
+++ b/src/test/test-sched-prio.c
@@ -7,6 +7,7 @@
#include <sched.h>
+#include "all-units.h"
#include "macro.h"
#include "manager.h"
#include "rm-rf.h"
diff --git a/src/test/test-unit-file.c b/src/test/test-unit-file.c
index 3fd4ac9e5d..45849ef87e 100644
--- a/src/test/test-unit-file.c
+++ b/src/test/test-unit-file.c
@@ -14,6 +14,7 @@
#include <unistd.h>
#include "alloc-util.h"
+#include "all-units.h"
#include "capability-util.h"
#include "fd-util.h"
#include "fileio.h"
diff --git a/src/test/test-unit-name.c b/src/test/test-unit-name.c
index bb44bc2545..692c3f41cf 100644
--- a/src/test/test-unit-name.c
+++ b/src/test/test-unit-name.c
@@ -13,6 +13,7 @@
#include <string.h>
#include "alloc-util.h"
+#include "all-units.h"
#include "glob-util.h"
#include "hostname-util.h"
#include "macro.h"
diff --git a/src/test/test-watch-pid.c b/src/test/test-watch-pid.c
index c280374582..cb43b35bc5 100644
--- a/src/test/test-watch-pid.c
+++ b/src/test/test-watch-pid.c
@@ -3,6 +3,7 @@
#include "log.h"
#include "manager.h"
#include "rm-rf.h"
+#include "service.h"
#include "test-helper.h"
#include "tests.h"