Skip to content

Commit 9213b7b

Browse files
temporary ifdef libsystemd
Signed-off-by: Khang D Nguyen <[email protected]>
1 parent 018b204 commit 9213b7b

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

meson.build

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ 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'],
6364
)
6465

6566
mctp_test = executable('test-mctp',
6667
sources: ['src/mctp.c'] + netlink_sources + util_sources + test_ops_sources,
6768
include_directories: include_directories('src'),
68-
dependencies: [libsystemd],
69+
c_args: ['-DHAVE_LIBSYSTEMD=0'],
6970
)
7071

7172
executable('mctp-req',
@@ -93,6 +94,7 @@ if libsystemd.found()
9394
dependencies: [libsystemd, toml_dep],
9495
install: true,
9596
install_dir: get_option('sbindir'),
97+
c_args: ['-DHAVE_LIBSYSTEMD=1'],
9698
)
9799

98100
mctpd_test = executable('test-mctpd',
@@ -101,6 +103,7 @@ if libsystemd.found()
101103
] + test_ops_sources + netlink_sources + util_sources,
102104
include_directories: include_directories('src'),
103105
dependencies: [libsystemd, toml_dep],
106+
c_args: ['-DHAVE_LIBSYSTEMD=1'],
104107
)
105108
endif
106109

src/mctp-ops.c

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

1010
#include <unistd.h>
1111
#include <linux/netlink.h>
12+
#if HAVE_LIBSYSTEMD
1213
#include <systemd/sd-event.h>
14+
#endif
1315
#include <err.h>
1416

1517
#include "mctp.h"
@@ -75,10 +77,12 @@ const struct mctp_ops mctp_ops = {
7577
.recvfrom = mctp_op_recvfrom,
7678
.close = mctp_op_close,
7779
},
80+
#if HAVE_LIBSYSTEMD
7881
.sd_event = {
7982
.add_time_relative = sd_event_add_time_relative,
8083
.source_set_time_relative = sd_event_source_set_time_relative,
8184
},
85+
#endif
8286
.bug_warn = mctp_bug_warn,
8387
};
8488

src/mctp-ops.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <stdint.h>
1111
#include <sys/socket.h>
1212
#include <stdarg.h>
13-
#include <systemd/sd-event.h>
1413

1514
#define _GNU_SOURCE
1615

@@ -26,13 +25,17 @@ struct socket_ops {
2625
int (*close)(int sd);
2726
};
2827

28+
struct sd_event;
29+
struct sd_event_source;
2930
struct sd_event_ops {
30-
int (*add_time_relative)(sd_event *e, sd_event_source **ret,
31-
clockid_t clock, uint64_t usec,
32-
uint64_t accuracy,
33-
sd_event_time_handler_t callback,
31+
int (*add_time_relative)(struct sd_event *e,
32+
struct sd_event_source **ret, clockid_t clock,
33+
uint64_t usec, uint64_t accuracy,
34+
int (*callback)(struct sd_event_source *s,
35+
uint64_t usec, void *userdata),
3436
void *userdata);
35-
int (*source_set_time_relative)(sd_event_source *s, uint64_t usec);
37+
int (*source_set_time_relative)(struct sd_event_source *s,
38+
uint64_t usec);
3639
};
3740

3841
struct mctp_ops {

tests/mctp-ops-test.c

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

22+
#if HAVE_LIBSYSTEMD
2223
#include <systemd/sd-event.h>
24+
#endif
2325
#include <linux/netlink.h>
2426

2527
#include "mctp-ops.h"
@@ -225,6 +227,7 @@ static void mctp_bug_warn(const char *fmt, va_list args)
225227
abort();
226228
}
227229

230+
#if HAVE_LIBSYSTEMD
228231
struct wrapped_time_userdata {
229232
sd_event_time_handler_t callback;
230233
void *userdata;
@@ -331,6 +334,7 @@ static int mctp_op_sd_event_source_set_time_relative(sd_event_source *s,
331334

332335
return 0;
333336
}
337+
#endif
334338

335339
const struct mctp_ops mctp_ops = {
336340
.mctp = {
@@ -349,10 +353,12 @@ const struct mctp_ops mctp_ops = {
349353
.recvfrom = mctp_op_recvfrom,
350354
.close = mctp_op_close,
351355
},
356+
#if HAVE_LIBSYSTEMD
352357
.sd_event = {
353358
.add_time_relative = mctp_op_sd_event_add_time_relative,
354359
.source_set_time_relative = mctp_op_sd_event_source_set_time_relative,
355360
},
361+
#endif
356362
.bug_warn = mctp_bug_warn,
357363
};
358364

0 commit comments

Comments
 (0)