summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-06 23:37:07 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-07 01:36:34 -0600
commit599c887d12d406296f356a02b1088f04ffe1f26e (patch)
treee2e4361fdcc8033ed02e3f144f66064e21793be8
parentb46d9f8886517c5e54cafc8bba1a6e0e30fdb691 (diff)
libcr_ipc: Have *_DECLARE() allow+require semicolons
-rw-r--r--cmd/sbc_harness/usb_keyboard.h4
-rw-r--r--lib9p/include/lib9p/srv.h4
-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
-rw-r--r--libhw_cr/rp2040_include/libhw/w5500.h2
8 files changed, 21 insertions, 15 deletions
diff --git a/cmd/sbc_harness/usb_keyboard.h b/cmd/sbc_harness/usb_keyboard.h
index 210014d..cf8483b 100644
--- a/cmd/sbc_harness/usb_keyboard.h
+++ b/cmd/sbc_harness/usb_keyboard.h
@@ -1,6 +1,6 @@
/* sbc_harness/usb_keyboard.h - Implementation of a USB keyboard device
*
- * 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
*/
@@ -12,7 +12,7 @@
#include <libcr/coroutine.h> /* for COROUTINE */
#include <libcr_ipc/rpc.h> /* for CR_RPC_DECLARE */
-CR_RPC_DECLARE(usb_keyboard_rpc, uint32_t, int)
+CR_RPC_DECLARE(usb_keyboard_rpc, uint32_t, int);
void usb_keyboard_init(void);
COROUTINE usb_keyboard_cr(void *arg);
diff --git a/lib9p/include/lib9p/srv.h b/lib9p/include/lib9p/srv.h
index 070cf5a..ec47142 100644
--- a/lib9p/include/lib9p/srv.h
+++ b/lib9p/include/lib9p/srv.h
@@ -19,7 +19,7 @@
/* context ********************************************************************/
-CR_CHAN_DECLARE(_lib9p_srv_flushch, bool)
+CR_CHAN_DECLARE(_lib9p_srv_flushch, bool);
struct lib9p_srv_ctx {
struct lib9p_ctx basectx;
@@ -132,7 +132,7 @@ LO_INTERFACE(lib9p_srv_dio);
/* main server entrypoints ****************************************************/
-CR_RPC_DECLARE(_lib9p_srv_reqch, struct _lib9p_srv_req *, bool)
+CR_RPC_DECLARE(_lib9p_srv_reqch, struct _lib9p_srv_req *, bool);
struct lib9p_srv {
/* Things you provide */
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};
diff --git a/libhw_cr/rp2040_include/libhw/w5500.h b/libhw_cr/rp2040_include/libhw/w5500.h
index 8db6a58..8dda1a1 100644
--- a/libhw_cr/rp2040_include/libhw/w5500.h
+++ b/libhw_cr/rp2040_include/libhw/w5500.h
@@ -17,7 +17,7 @@
#include <libhw/generic/net.h>
#include <libhw/generic/spi.h>
-CR_CHAN_DECLARE(_w5500_sockintr_ch, uint8_t)
+CR_CHAN_DECLARE(_w5500_sockintr_ch, uint8_t);
struct _w5500_socket {
BEGIN_PRIVATE(LIBHW_W5500_H);