]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: undo the dependency inversion between unit.h and all unit types 9005/head
authorFelipe Sateler <fsateler@debian.org>
Tue, 15 May 2018 18:17:34 +0000 (14:17 -0400)
committerFelipe Sateler <fsateler@debian.org>
Tue, 15 May 2018 18:24:34 +0000 (14:24 -0400)
32 files changed:
src/analyze/analyze-verify.c
src/core/all-units.h [new file with mode: 0644]
src/core/automount.h
src/core/dbus-scope.h
src/core/dbus.c
src/core/device.h
src/core/dynamic-user.c
src/core/execute.c
src/core/load-fragment-gperf.gperf.m4
src/core/load-fragment.c
src/core/main.c
src/core/manager.c
src/core/manager.h
src/core/mount.c
src/core/mount.h
src/core/path.h
src/core/scope.h
src/core/service.h
src/core/slice.h
src/core/socket.h
src/core/swap.c
src/core/swap.h
src/core/target.h
src/core/timer.h
src/core/unit.c
src/core/unit.h
src/test/test-execute.c
src/test/test-path.c
src/test/test-sched-prio.c
src/test/test-unit-file.c
src/test/test-unit-name.c
src/test/test-watch-pid.c

index 90c10f575a4e604c8baeb975fac6d713fa49588b..694ecc72879de2885c36e31acf2360e3d07b832d 100644 (file)
@@ -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 (file)
index 0000000..ed8350e
--- /dev/null
@@ -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"
index f017b8c7ee7edd8c8fbe434d4429311cc585ed8c..bdadb5547860e3ca1ee0c4c25255f7f7cf9887e0 100644 (file)
@@ -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);
index f055b70aac8d647e45286bd3dd744df736caa904..115886b134af627c1097eac7210fed1a58dd61a7 100644 (file)
@@ -9,7 +9,7 @@
 
 #include "sd-bus.h"
 
-#include "unit.h"
+#include "scope.h"
 
 extern const sd_bus_vtable bus_scope_vtable[];
 
index 47492835ee8e729506893717c9a3d02c9042eca0..9e39d8ab7f1a486e2abf5fddcc96b57d76002a61 100644 (file)
@@ -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"
index d52700b66f66bf9ea452018e1d5f351bf7f0fbb6..f188640c59b673b5ad951f73ec6db47c1c7c96f3 100644 (file)
@@ -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);
index 1f4ed576d98a19ade4b8998c2c6a2851e6c0a8b4..05ccc8c854e8a820cc6901c8a1f82248946fc2b7 100644 (file)
@@ -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"
index ecc7e8821a247a8bb653823af15550119f5199c1..fca20c556783a27335366abd53fc47cb08a5f3f5 100644 (file)
@@ -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"
index 5d90a7c054961c4864c9644a23d21f846b3a777b..001837463b2d912f7df3d8b79cec8eb707f0f000 100644 (file)
@@ -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
index a78039bb4fabc2e2f8881eee63aa4bc71f6d330b..e17987bf070f9ea72cf6af91c06d41e540137b2b 100644 (file)
@@ -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"
index 201882ca95c029277c0bbceb181b4c94315f4319..978434038e374c082e506437c62aeeeca9203df9 100644 (file)
@@ -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"
index 6412fee4764e215e85b6a6841c1a825fe541d1fc..a4cea85136f2d31863825a64a2666817ae50b8e1 100644 (file)
@@ -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"
index 35a3a1eb4000320573b43085ff03a9f7b128e888..f41cce1c09e99e6583f388431da61962a03f0cf9 100644 (file)
@@ -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 */
index 968ed104dacc3b0bd78a06168191b437638869da..d5463b76213b33cbda9bf357deffbdeda8c87e98 100644 (file)
@@ -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"
index 08a4cfe61f1daa6748a965bc4ba1750696adb144..71dac128c22237372032662d6eecb6066a1dc4e3 100644 (file)
@@ -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);
index ca7dac227d969fb4ebbfe9af2aa2a9de912603f8..2aa2ca111f055c799f9dfc9065670507fcc072f5 100644 (file)
@@ -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);
index 6e314eeda3af1da2bf99fe269a1cc6a032917242..e74014119d77936df2813a274aaaa3b48a014e36 100644 (file)
@@ -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);
index 116d5d119fabb279796e61f514923205dcdc9a6b..6d64f8e9e6fe98efb4dd249fcdaad3a4f30be640 100644 (file)
@@ -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);
index 7d48fafa3aca364674b980aac97870f7a5e0cdae..0ab479467ce877254c50f974ca974cd95f0acab7 100644 (file)
@@ -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);
index ce9452dbd6904f8d3a8ffbdd3eb9d5ec8aca6110..8a9559d5c6da0c7f89a92338a134491e96a3c3d3 100644 (file)
@@ -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);
index 618a8d553dc258e5b4687360e939dfdffb8ed38f..e75c9f2464f01cc91ebecee5387aca861457ec86 100644 (file)
@@ -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"
index ec29ccfa6e2aa011723865967fdf6e454d720d8c..fdb14e667a3e3a3e37cb221787115e133517178a 100644 (file)
@@ -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);
index 2b099c2513a36b06316ced0eae88f7102c4b346b..4a2dea17ed63ff11f6088cd1a6b0c2cf42045c52 100644 (file)
@@ -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);
index 728afba9bda0d481303de48696cdf3a1fc547f3b..0588a96ca2445d7d6b886cb7a9570ef895439fef 100644 (file)
@@ -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);
index 13e00a25c8233f49190f1ffd17071385fe46ae14..c7320240f7bdebc76d0da973f9736d47327e32ce 100644 (file)
@@ -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"
index 26194ef35a0a90eab44a7a999da8ed16aa3974ce..767cd96aeb6de4f1e7f4b1f74172c052b9116928 100644 (file)
 #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);
index 730dfd1e0b838f3cff238cdc6b26a4aed1178a57..20202c9421c31b64491a40c6e2712866bd0466df 100644 (file)
@@ -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"
index ed53177dcc8ded864c2fd15817502b487dc25f39..cdc2375d563389ae18f2309883daf98d30363fee 100644 (file)
@@ -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"
index 7d8fc445ec085087b5d3250b78e00265de96f546..da0f8581423d085bcb7fcb460b9f783b97deb128 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <sched.h>
 
+#include "all-units.h"
 #include "macro.h"
 #include "manager.h"
 #include "rm-rf.h"
index 3fd4ac9e5dae532eedd90e6017178aba968ddd87..45849ef87ed63393bce3a5c843c7745cf1a24212 100644 (file)
@@ -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"
index bb44bc25458c9b8cd0ceac428bdd94989d66d356..692c3f41cff066d667615735fa8c8f1496864b37 100644 (file)
@@ -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"
index c280374582c42b224aab0fbbb40f361667b19fe2..cb43b35bc5d986e254824232079b4c3ee8e319d4 100644 (file)
@@ -3,6 +3,7 @@
 #include "log.h"
 #include "manager.h"
 #include "rm-rf.h"
+#include "service.h"
 #include "test-helper.h"
 #include "tests.h"