summaryrefslogtreecommitdiff
path: root/libcr_ipc
diff options
context:
space:
mode:
Diffstat (limited to 'libcr_ipc')
-rw-r--r--libcr_ipc/include/libcr_ipc/chan.h13
-rw-r--r--libcr_ipc/include/libcr_ipc/rpc.h5
-rw-r--r--libcr_ipc/tests/test_chan.c4
-rw-r--r--libcr_ipc/tests/test_rpc.c2
-rw-r--r--libcr_ipc/tests/test_select.c2
5 files changed, 16 insertions, 10 deletions
diff --git a/libcr_ipc/include/libcr_ipc/chan.h b/libcr_ipc/include/libcr_ipc/chan.h
index dafc92d..0e44d84 100644
--- a/libcr_ipc/include/libcr_ipc/chan.h
+++ b/libcr_ipc/include/libcr_ipc/chan.h
@@ -12,6 +12,7 @@
#include <string.h> /* for memcpy */
#include <libcr/coroutine.h> /* for cid_t, cr_* */
+#include <libmisc/macro.h>
#include <libcr_ipc/_linkedlist.h>
@@ -78,30 +79,32 @@
struct _cr_chan core; \
VAL_T vals[0]; \
} NAME##_t; \
- \
+ \
static inline void NAME##_send(NAME##_t *ch, VAL_T val) { \
cr_assert_in_coroutine(); \
_cr_chan_xfer(_CR_CHAN_SENDER, &ch->core, &val, sizeof(val)); \
} \
- \
+ \
static inline VAL_T NAME##_recv(NAME##_t *ch) { \
cr_assert_in_coroutine(); \
VAL_T val; \
_cr_chan_xfer(_CR_CHAN_RECVER, &ch->core, &val, sizeof(val)); \
return val; \
} \
- \
+ \
static inline bool NAME##_can_send(NAME##_t *ch) { \
cr_assert_in_coroutine(); \
return ch->core.waiters.front && \
ch->core.waiter_typ == _CR_CHAN_RECVER; \
} \
- \
+ \
static inline bool NAME##_can_recv(NAME##_t *ch) { \
cr_assert_in_coroutine(); \
return ch->core.waiters.front && \
ch->core.waiter_typ == _CR_CHAN_SENDER; \
- }
+ } \
+ \
+ extern int LM_CAT2_(_CR_CHAN_FORCE_SEMICOLON_, __COUNTER__)
enum _cr_chan_waiter_typ {
_CR_CHAN_SENDER,
diff --git a/libcr_ipc/include/libcr_ipc/rpc.h b/libcr_ipc/include/libcr_ipc/rpc.h
index 0600399..512727b 100644
--- a/libcr_ipc/include/libcr_ipc/rpc.h
+++ b/libcr_ipc/include/libcr_ipc/rpc.h
@@ -11,6 +11,7 @@
#include <string.h> /* for memcpy() */
#include <libcr/coroutine.h> /* for cid_t, cr_* */
+#include <libmisc/macro.h>
#include <libcr_ipc/_linkedlist.h>
@@ -136,7 +137,9 @@
*(req._resp) = resp; \
cr_unpause(req._requester); \
cr_yield(); \
- }
+ } \
+ \
+ extern int LM_CAT2_(_CR_RPC_FORCE_SEMICOLON_, __COUNTER__)
enum _cr_rpc_waiter_typ {
_CR_RPC_REQUESTER,
diff --git a/libcr_ipc/tests/test_chan.c b/libcr_ipc/tests/test_chan.c
index 9d6eecf..9b6f018 100644
--- a/libcr_ipc/tests/test_chan.c
+++ b/libcr_ipc/tests/test_chan.c
@@ -1,6 +1,6 @@
/* libcr_ipc/tests/test_chan.c - Tests for <libcr_ipc/chan.h>
*
- * Copyright (C) 2024 Luke T. Shumaker <lukeshu@lukeshu.com>
+ * Copyright (C) 2024-2025 Luke T. Shumaker <lukeshu@lukeshu.com>
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
@@ -9,7 +9,7 @@
#include "test.h"
-CR_CHAN_DECLARE(intchan, int)
+CR_CHAN_DECLARE(intchan, int);
COROUTINE cr_producer(void *_ch) {
intchan_t *ch = _ch;
diff --git a/libcr_ipc/tests/test_rpc.c b/libcr_ipc/tests/test_rpc.c
index 4aff5ca..1e3c471 100644
--- a/libcr_ipc/tests/test_rpc.c
+++ b/libcr_ipc/tests/test_rpc.c
@@ -9,7 +9,7 @@
#include "test.h"
-CR_RPC_DECLARE(intrpc, int, int)
+CR_RPC_DECLARE(intrpc, int, int);
/* Test that the RPC is fair, have worker1 start waiting first, and
* ensure that it gets the first request. */
diff --git a/libcr_ipc/tests/test_select.c b/libcr_ipc/tests/test_select.c
index 07ddc09..9609534 100644
--- a/libcr_ipc/tests/test_select.c
+++ b/libcr_ipc/tests/test_select.c
@@ -9,7 +9,7 @@
#include "test.h"
-CR_CHAN_DECLARE(intchan, int)
+CR_CHAN_DECLARE(intchan, int);
intchan_t ch[10] = {0};
intchan_t fch = {0};