summaryrefslogtreecommitdiff
path: root/libcr_ipc
diff options
context:
space:
mode:
authorLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-05 21:41:15 -0600
committerLuke T. Shumaker <lukeshu@lukeshu.com>2025-04-05 21:41:15 -0600
commit5d72b64e90cd5252c2c25b6c6eb1e9cf5cc739f9 (patch)
tree3a29d91c3dfb3c7c580c87184a15b5bd54e55172 /libcr_ipc
parent7fe3755f3a3dc11f1371b2b104fe3cf357da2310 (diff)
parent9758d91ea795448689ec401570bf556b8107177c (diff)
Merge branch 'lukeshu/net-flash'
Diffstat (limited to 'libcr_ipc')
-rw-r--r--libcr_ipc/CMakeLists.txt2
-rw-r--r--libcr_ipc/include/libcr_ipc/chan.h10
-rw-r--r--libcr_ipc/include/libcr_ipc/rpc.h22
-rw-r--r--libcr_ipc/include/libcr_ipc/select.h3
-rw-r--r--libcr_ipc/include/libcr_ipc/sema.h4
5 files changed, 19 insertions, 22 deletions
diff --git a/libcr_ipc/CMakeLists.txt b/libcr_ipc/CMakeLists.txt
index 3746584..8545798 100644
--- a/libcr_ipc/CMakeLists.txt
+++ b/libcr_ipc/CMakeLists.txt
@@ -4,7 +4,7 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
add_library(libcr_ipc INTERFACE)
-target_include_directories(libcr_ipc SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
+target_include_directories(libcr_ipc PUBLIC INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
target_sources(libcr_ipc INTERFACE
chan.c
select.c
diff --git a/libcr_ipc/include/libcr_ipc/chan.h b/libcr_ipc/include/libcr_ipc/chan.h
index 5b1e583..dafc92d 100644
--- a/libcr_ipc/include/libcr_ipc/chan.h
+++ b/libcr_ipc/include/libcr_ipc/chan.h
@@ -21,7 +21,7 @@
*
* type:
*
- * /**
+ * / **
* * A NAME##_t is a fair unbuffered channel that transports
* * values of type `VAL_T`.
* *
@@ -35,7 +35,7 @@
*
* methods:
*
- * /**
+ * / **
* * NAME##_send(ch, val) sends `val` over `ch`.
* *
* * @runs_in coroutine
@@ -44,7 +44,7 @@
* * /
* void NAME##_send(NAME##_t *ch, VAL_T val);
*
- * /**
+ * / **
* * NAME##_recv(ch) reads and returns a value from ch.
* *
* * @runs_in coroutine
@@ -53,7 +53,7 @@
* * /
* VAL_T NAME##_recv(NAME##_t *ch);
*
- * /**
+ * / **
* * NAME##_can_send(ch) returns whether NAME##_send(ch, val)
* * would run without pausing.
* *
@@ -63,7 +63,7 @@
* * /
* bool NAME##_can_send(NAME##_t *ch);
*
- * /**
+ * / **
* * NAME##_can_recv(ch) returns whether NAME##_recv(ch) would
* * return without pausing.
* *
diff --git a/libcr_ipc/include/libcr_ipc/rpc.h b/libcr_ipc/include/libcr_ipc/rpc.h
index 0ff8bbf..0600399 100644
--- a/libcr_ipc/include/libcr_ipc/rpc.h
+++ b/libcr_ipc/include/libcr_ipc/rpc.h
@@ -20,7 +20,7 @@
*
* type:
*
- * /**
+ * / **
* * A NAME##_t is a fair rpc-channel on which the requester submits a
* * value of type `REQ_T` and the responder responds with a value of
* * type `RESP_T`.
@@ -35,7 +35,7 @@
* * _recv_req() and _send_resp().
* typedef ... NAME##_t;
*
- * /**
+ * / **
* * A NAME##_req_t is handle that wraps a REQ_T and is used to return
* * the response RESP_T to the correct requester. `REQ_T req` is the
* * only public member.
@@ -43,7 +43,7 @@
*
* methods:
*
- * /**
+ * / **
* * NAME##_send_req(ch, req) submits the `req` request over `ch` and
* * returns the response.
* *
@@ -53,7 +53,7 @@
* * /
* RESP_T NAME##_send_req(NAME##_t *ch, REQ_T req);
*
- * /**
+ * / **
* * NAME##_recv_req(ch) reads a request from ch, and returns a
* * NAME##_req_t handle wrapping that request.
* *
@@ -63,7 +63,7 @@
* * /
* NAME##_req_t NAME##_recv_req(NAME##_t *ch);
*
- * /**
+ * / **
* * NAME##_can_recv_req(ch) returns whether NAME##_recv_req(ch)
* * would return without pausing.
* *
@@ -75,7 +75,7 @@
*
* type:
*
- * /**
+ * / **
* * A NAME##_req_t is a handle that wraps a REQ_T, and is a channel
* * that a response may be written to.
* * /
@@ -83,7 +83,7 @@
*
* methods:
*
- * /**
+ * / **
* * cr_rpc_send_resp(req, resp) sends the given response to the given
* * request.
* *
@@ -111,7 +111,7 @@
RESP_T resp; \
_cr_rpc_send_req(&ch->core, \
&req, sizeof(req), \
- &resp, sizeof(resp)); \
+ &resp); \
return resp; \
} \
\
@@ -152,8 +152,8 @@ struct _cr_rpc_requester {
struct _cr_rpc_responder {
_cr_ipc_sll_node;
- /* /* before enqueued | after dequeued */
- /* /* -------------------+-------------------- */
+ /* before enqueued | after dequeued */
+ /* -------------------+-------------------- */
cid_t cid; /* responder cid | requester cid */
void *ptr; /* where to write req | where to write resp */
};
@@ -165,7 +165,7 @@ struct _cr_rpc {
static inline void _cr_rpc_send_req(struct _cr_rpc *ch,
void *req_ptr, size_t req_size,
- void *resp_ptr, size_t resp_size)
+ void *resp_ptr)
{
assert(ch);
assert(req_ptr);
diff --git a/libcr_ipc/include/libcr_ipc/select.h b/libcr_ipc/include/libcr_ipc/select.h
index b845082..0e35351 100644
--- a/libcr_ipc/include/libcr_ipc/select.h
+++ b/libcr_ipc/include/libcr_ipc/select.h
@@ -33,8 +33,6 @@ struct cr_select_arg {
};
#define CR_SELECT_RECV(CH, VALP) ({ \
- assert(CH); \
- assert(VALP); \
/* The _valp indirection is to get the \
* compiler to check that the types are \
* compatible. */ \
@@ -47,7 +45,6 @@ struct cr_select_arg {
}); \
})
#define CR_SELECT_SEND(CH, VAL) ({ \
- assert(CH); \
typeof((CH)->vals[0]) val_lvalue = VAL; \
((struct cr_select_arg){ \
.op = _CR_SELECT_OP_SEND, \
diff --git a/libcr_ipc/include/libcr_ipc/sema.h b/libcr_ipc/include/libcr_ipc/sema.h
index 6db4015..fcabf28 100644
--- a/libcr_ipc/include/libcr_ipc/sema.h
+++ b/libcr_ipc/include/libcr_ipc/sema.h
@@ -84,9 +84,9 @@ static inline void cr_sema_wait(cr_sema_t *sema) {
.cid = cr_getcid(),
};
_cr_ipc_sll_push_to_rear(&sema->waiters, &self);
- if (sema->waiters.front != &self || !sema->cnt)
+ if (sema->waiters.front != &self._cr_ipc_sll_node || !sema->cnt)
cr_pause_and_yield();
- assert(sema->waiters.front == &self && sema->cnt);
+ assert(sema->waiters.front == &self._cr_ipc_sll_node && sema->cnt);
_cr_ipc_sll_pop_from_front(&sema->waiters);
sema->cnt--;
if (sema->cnt && sema->waiters.front)