]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge shared/exec-directory-util.? into basic/unit-def.?
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Jul 2025 10:09:31 +0000 (12:09 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Jul 2025 10:57:33 +0000 (12:57 +0200)
Suggested in
https://github.com/systemd/systemd/pull/35892#discussion_r2180322856.

This is a tiny amount of code and does not warrant having a separate file
and spawning a separate instance of the compiler during the build.

Note: it took me a while to confirm that the contents of that table and
function don't end up in libsystemd.so. The issue is that they _are_ present in
it, unless LTO is used. We actually use link_whole[libbasic_static] for
libsystemd, so we end up with all that code there. LTO is needed to clean
that up.

src/basic/unit-def.c
src/basic/unit-def.h
src/core/execute.h
src/shared/exec-directory-util.c [deleted file]
src/shared/exec-directory-util.h [deleted file]
src/shared/meson.build
src/systemctl/systemctl-show.c

index f98cfd4ae18b914bc648defa330a71064eee0c00..04b096cd197be4b2cf8be13430d742adde14b6ff 100644 (file)
@@ -361,6 +361,17 @@ static const char* const job_mode_table[_JOB_MODE_MAX] = {
 
 DEFINE_STRING_TABLE_LOOKUP(job_mode, JobMode);
 
+/* This table maps ExecDirectoryType to the setting it is configured with in the unit */
+static const char* const exec_directory_type_table[_EXEC_DIRECTORY_TYPE_MAX] = {
+        [EXEC_DIRECTORY_RUNTIME]       = "RuntimeDirectory",
+        [EXEC_DIRECTORY_STATE]         = "StateDirectory",
+        [EXEC_DIRECTORY_CACHE]         = "CacheDirectory",
+        [EXEC_DIRECTORY_LOGS]          = "LogsDirectory",
+        [EXEC_DIRECTORY_CONFIGURATION] = "ConfigurationDirectory",
+};
+
+DEFINE_STRING_TABLE_LOOKUP(exec_directory_type, ExecDirectoryType);
+
 Glyph unit_active_state_to_glyph(UnitActiveState state) {
         static const Glyph map[_UNIT_ACTIVE_STATE_MAX] = {
                 [UNIT_ACTIVE]       = GLYPH_BLACK_CIRCLE,
index 7664f2881ac5807baa603118a5485e6c02c2c0b2..e0b1c6730d84824e030e05731b26c33e85da03a8 100644 (file)
@@ -296,6 +296,16 @@ typedef enum JobMode {
         _JOB_MODE_INVALID = -EINVAL,
 } JobMode;
 
+typedef enum ExecDirectoryType {
+        EXEC_DIRECTORY_RUNTIME,
+        EXEC_DIRECTORY_STATE,
+        EXEC_DIRECTORY_CACHE,
+        EXEC_DIRECTORY_LOGS,
+        EXEC_DIRECTORY_CONFIGURATION,
+        _EXEC_DIRECTORY_TYPE_MAX,
+        _EXEC_DIRECTORY_TYPE_INVALID = -EINVAL,
+} ExecDirectoryType;
+
 char* unit_dbus_path_from_name(const char *name);
 int unit_name_from_dbus_path(const char *path, char **name);
 
@@ -361,4 +371,7 @@ NotifyAccess notify_access_from_string(const char *s) _pure_;
 const char* job_mode_to_string(JobMode t) _const_;
 JobMode job_mode_from_string(const char *s) _pure_;
 
+const char* exec_directory_type_to_string(ExecDirectoryType i) _const_;
+ExecDirectoryType exec_directory_type_from_string(const char *s) _pure_;
+
 Glyph unit_active_state_to_glyph(UnitActiveState state);
index e0f3ba51e06bd65253e9d3d54e9ab85526fe9e25..da1600a0440257f5cb231c6798222b9c555ccf7a 100644 (file)
@@ -7,7 +7,6 @@
 #include "cgroup-util.h"
 #include "core-forward.h"
 #include "cpu-set-util.h"
-#include "exec-directory-util.h"
 #include "exec-util.h"
 #include "list.h"
 #include "log-context.h"
diff --git a/src/shared/exec-directory-util.c b/src/shared/exec-directory-util.c
deleted file mode 100644 (file)
index d9effa2..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-
-#include "exec-directory-util.h"
-#include "string-table.h"
-
-/* This table maps ExecDirectoryType to the setting it is configured with in the unit */
-static const char* const exec_directory_type_table[_EXEC_DIRECTORY_TYPE_MAX] = {
-        [EXEC_DIRECTORY_RUNTIME]       = "RuntimeDirectory",
-        [EXEC_DIRECTORY_STATE]         = "StateDirectory",
-        [EXEC_DIRECTORY_CACHE]         = "CacheDirectory",
-        [EXEC_DIRECTORY_LOGS]          = "LogsDirectory",
-        [EXEC_DIRECTORY_CONFIGURATION] = "ConfigurationDirectory",
-};
-
-DEFINE_STRING_TABLE_LOOKUP(exec_directory_type, ExecDirectoryType);
diff --git a/src/shared/exec-directory-util.h b/src/shared/exec-directory-util.h
deleted file mode 100644 (file)
index 0006c73..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/* SPDX-License-Identifier: LGPL-2.1-or-later */
-#pragma once
-
-#include <errno.h>
-
-#include "macro-fundamental.h"
-
-typedef enum ExecDirectoryType {
-        EXEC_DIRECTORY_RUNTIME,
-        EXEC_DIRECTORY_STATE,
-        EXEC_DIRECTORY_CACHE,
-        EXEC_DIRECTORY_LOGS,
-        EXEC_DIRECTORY_CONFIGURATION,
-        _EXEC_DIRECTORY_TYPE_MAX,
-        _EXEC_DIRECTORY_TYPE_INVALID = -EINVAL,
-} ExecDirectoryType;
-
-const char* exec_directory_type_to_string(ExecDirectoryType i) _const_;
-ExecDirectoryType exec_directory_type_from_string(const char *s) _pure_;
index afbf7f8033ed00483115382cbbfbf9c32cdbc255..78e435de350c338677d87b5a3c2b14de48f86f15 100644 (file)
@@ -69,7 +69,6 @@ shared_sources = files(
         'elf-util.c',
         'enable-mempool.c',
         'ethtool-util.c',
-        'exec-directory-util.c',
         'exec-util.c',
         'exit-status.c',
         'extension-util.c',
index e75e7ac1c176cb328ad8537048dc4fe59f346e6d..1db9bf2beae088932e7b2fc6b3f033a0a3901149 100644 (file)
@@ -15,7 +15,6 @@
 #include "cgroup-show.h"
 #include "cpu-set-util.h"
 #include "errno-util.h"
-#include "exec-directory-util.h"
 #include "exec-util.h"
 #include "exit-status.h"
 #include "extract-word.h"