Skip to content

Commit 236330c

Browse files
committed
meson, ops: define sd_event ops by intent, not libsystemd presence
Setting HAVE_LIBSYSTEMD based on target is a bit misleading: we may *have* a libsystemd available, but not want to use it (for example, in ops used by the mctp binary). Instead, use OPS_SD_EVENT to describe our intent to include the sd_event operations. Signed-off-by: Jeremy Kerr <[email protected]>
1 parent 9a7f504 commit 236330c

File tree

4 files changed

+8
-16
lines changed

4 files changed

+8
-16
lines changed

meson.build

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,11 @@ toml_dep = declare_dependency(
6060
executable('mctp',
6161
sources: ['src/mctp.c'] + netlink_sources + util_sources + ops_sources,
6262
install: true,
63-
c_args: ['-DHAVE_LIBSYSTEMD=0'],
6463
)
6564

6665
mctp_test = executable('test-mctp',
6766
sources: ['src/mctp.c'] + netlink_sources + util_sources + test_ops_sources,
6867
include_directories: include_directories('src'),
69-
c_args: ['-DHAVE_LIBSYSTEMD=0'],
7068
)
7169

7270
executable('mctp-req',
@@ -94,7 +92,7 @@ if libsystemd.found()
9492
dependencies: [libsystemd, toml_dep],
9593
install: true,
9694
install_dir: get_option('sbindir'),
97-
c_args: ['-DHAVE_LIBSYSTEMD=1'],
95+
c_args: ['-DOPS_SD_EVENT=1'],
9896
)
9997

10098
mctpd_test = executable('test-mctpd',
@@ -103,7 +101,7 @@ if libsystemd.found()
103101
] + test_ops_sources + netlink_sources + util_sources,
104102
include_directories: include_directories('src'),
105103
dependencies: [libsystemd, toml_dep],
106-
c_args: ['-DHAVE_LIBSYSTEMD=1'],
104+
c_args: ['-DOPS_SD_EVENT=1'],
107105
)
108106
endif
109107

src/mctp-ops.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@
99

1010
#include <unistd.h>
1111
#include <linux/netlink.h>
12-
#if HAVE_LIBSYSTEMD
13-
#include <systemd/sd-event.h>
14-
#endif
1512
#include <err.h>
1613

1714
#include "mctp.h"
@@ -77,7 +74,7 @@ const struct mctp_ops mctp_ops = {
7774
.recvfrom = mctp_op_recvfrom,
7875
.close = mctp_op_close,
7976
},
80-
#if HAVE_LIBSYSTEMD
77+
#if OPS_SD_EVENT
8178
.sd_event = {
8279
.add_time_relative = sd_event_add_time_relative,
8380
.source_set_time_relative = sd_event_source_set_time_relative,

src/mctp-ops.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#include <sys/socket.h>
1111
#include <stdarg.h>
12-
#if HAVE_LIBSYSTEMD
12+
#if OPS_SD_EVENT
1313
#include <systemd/sd-event.h>
1414
#endif
1515

@@ -27,7 +27,7 @@ struct socket_ops {
2727
int (*close)(int sd);
2828
};
2929

30-
#if HAVE_LIBSYSTEMD
30+
#if OPS_SD_EVENT
3131
struct sd_event_ops {
3232
typeof(sd_event_add_time_relative) *add_time_relative;
3333
typeof(sd_event_source_set_time_relative) *source_set_time_relative;
@@ -37,7 +37,7 @@ struct sd_event_ops {
3737
struct mctp_ops {
3838
struct socket_ops mctp;
3939
struct socket_ops nl;
40-
#if HAVE_LIBSYSTEMD
40+
#if OPS_SD_EVENT
4141
struct sd_event_ops sd_event;
4242
#endif
4343
void (*bug_warn)(const char *fmt, va_list args);

tests/mctp-ops-test.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
#include <sys/socket.h>
2020
#include <sys/un.h>
2121

22-
#if HAVE_LIBSYSTEMD
23-
#include <systemd/sd-event.h>
24-
#endif
2522
#include <linux/netlink.h>
2623

2724
#include "mctp-ops.h"
@@ -227,7 +224,7 @@ static void mctp_bug_warn(const char *fmt, va_list args)
227224
abort();
228225
}
229226

230-
#if HAVE_LIBSYSTEMD
227+
#if OPS_SD_EVENT
231228
struct wrapped_time_userdata {
232229
sd_event_time_handler_t callback;
233230
void *userdata;
@@ -353,7 +350,7 @@ const struct mctp_ops mctp_ops = {
353350
.recvfrom = mctp_op_recvfrom,
354351
.close = mctp_op_close,
355352
},
356-
#if HAVE_LIBSYSTEMD
353+
#if OPS_SD_EVENT
357354
.sd_event = {
358355
.add_time_relative = mctp_op_sd_event_add_time_relative,
359356
.source_set_time_relative = mctp_op_sd_event_source_set_time_relative,

0 commit comments

Comments
 (0)