]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: move DEVICE_TRACE() to udev-trace.h
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 18 Jul 2023 14:10:32 +0000 (23:10 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 31 Jul 2023 14:23:00 +0000 (23:23 +0900)
It is only used by udevd, and not necessary in src/shared.

src/shared/udev-util.h
src/udev/udev-event.c
src/udev/udev-rules.c
src/udev/udev-trace.h [new file with mode: 0644]
src/udev/udevd.c

index 05a0849934b88ae3fc484770b016c6ea58015227..c848cf6177a66e32378b5b8a5d9e419d20650060 100644 (file)
@@ -1,11 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
-#if HAVE_SYS_SDT_H
-#define SDT_USE_VARIADIC
-#include <sys/sdt.h>
-#endif
-
 #include "sd-device.h"
 
 #include "time-util.h"
@@ -55,30 +50,3 @@ bool devpath_conflict(const char *a, const char *b);
 int udev_queue_is_empty(void);
 
 bool udev_available(void);
-
-#if HAVE_SYS_SDT_H
-
-/* Each trace point can have different number of additional arguments. Note that when the macro is used only
- * additional arguments are listed in the macro invocation!
- *
- * Default arguments for each trace point are as follows:
- *   - arg0 - action
- *   - arg1 - sysname
- *   - arg2 - syspath
- *   - arg3 - subsystem
- */
-#define DEVICE_TRACE_POINT(name, dev, ...)                                                                 \
-        do {                                                                                               \
-                PROTECT_ERRNO;                                                                             \
-                const char *_n = NULL, *_p = NULL, *_s = NULL;                                             \
-                sd_device *_d = (dev);                                                                     \
-                sd_device_action_t _a = _SD_DEVICE_ACTION_INVALID;                                         \
-                (void) sd_device_get_action(_d, &_a);                                                      \
-                (void) sd_device_get_sysname(_d, &_n);                                                     \
-                (void) sd_device_get_syspath(_d, &_p);                                                     \
-                (void) sd_device_get_subsystem(_d, &_s);                                                   \
-                STAP_PROBEV(udev, name, device_action_to_string(_a), _n, _p, _s __VA_OPT__(,) __VA_ARGS__);\
-        } while (false);
-#else
-#define DEVICE_TRACE_POINT(name, dev, ...) ((void) 0)
-#endif
index 31547b76794a363f412dd8a1e5584df8f05f5c95..745f29a88f3443e96115a0338f9ac5e830913b2a 100644 (file)
@@ -31,6 +31,7 @@
 #include "udev-builtin.h"
 #include "udev-event.h"
 #include "udev-node.h"
+#include "udev-trace.h"
 #include "udev-util.h"
 #include "udev-watch.h"
 #include "user-util.h"
index 88846ae275a056e9ef7d955289024d03dd393f94..2c9797f09993b156f6ce76df6e924f3183dd732d 100644 (file)
@@ -32,6 +32,7 @@
 #include "udev-event.h"
 #include "udev-node.h"
 #include "udev-rules.h"
+#include "udev-trace.h"
 #include "udev-util.h"
 #include "user-util.h"
 #include "virt.h"
diff --git a/src/udev/udev-trace.h b/src/udev/udev-trace.h
new file mode 100644 (file)
index 0000000..5e94390
--- /dev/null
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+#pragma once
+
+#if HAVE_SYS_SDT_H
+#define SDT_USE_VARIADIC
+#include <sys/sdt.h>
+
+#include "device-private.h"
+#include "device-util.h"
+#include "errno-util.h"
+
+/* Each trace point can have different number of additional arguments. Note that when the macro is used only
+ * additional arguments are listed in the macro invocation!
+ *
+ * Default arguments for each trace point are as follows:
+ *   - arg0 - action
+ *   - arg1 - sysname
+ *   - arg2 - syspath
+ *   - arg3 - subsystem
+ */
+#define DEVICE_TRACE_POINT(name, dev, ...)                                                                 \
+        do {                                                                                               \
+                PROTECT_ERRNO;                                                                             \
+                const char *_n = NULL, *_p = NULL, *_s = NULL;                                             \
+                sd_device *_d = (dev);                                                                     \
+                sd_device_action_t _a = _SD_DEVICE_ACTION_INVALID;                                         \
+                (void) sd_device_get_action(_d, &_a);                                                      \
+                (void) sd_device_get_sysname(_d, &_n);                                                     \
+                (void) sd_device_get_syspath(_d, &_p);                                                     \
+                (void) sd_device_get_subsystem(_d, &_s);                                                   \
+                STAP_PROBEV(udev, name, device_action_to_string(_a), _n, _p, _s __VA_OPT__(,) __VA_ARGS__);\
+        } while (false);
+#else
+#define DEVICE_TRACE_POINT(name, dev, ...) ((void) 0)
+#endif
index fe29dd94b364e4fdff54d79973c436fb10fc1302..b545abd3e449f411066ec6e729295e8296a72a3d 100644 (file)
@@ -69,6 +69,7 @@
 #include "udev-ctrl.h"
 #include "udev-event.h"
 #include "udev-node.h"
+#include "udev-trace.h"
 #include "udev-util.h"
 #include "udev-watch.h"
 #include "user-util.h"