diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-29 12:04:57 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-29 12:04:57 -0600 |
commit | 6940b244de7c5048c55fc57ada93501c1be5ab20 (patch) | |
tree | 42734faad626d97f45fce0725031896824924701 /libcr_ipc/include | |
parent | 7b34cb7741c683dc623ece652032f1bf09d34140 (diff) |
fixes
Diffstat (limited to 'libcr_ipc/include')
-rw-r--r-- | libcr_ipc/include/libcr_ipc/_common.h | 5 | ||||
-rw-r--r-- | libcr_ipc/include/libcr_ipc/sema.h | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/libcr_ipc/include/libcr_ipc/_common.h b/libcr_ipc/include/libcr_ipc/_common.h index 547ab81..247ba3d 100644 --- a/libcr_ipc/include/libcr_ipc/_common.h +++ b/libcr_ipc/include/libcr_ipc/_common.h @@ -31,10 +31,15 @@ struct _cr_ipc_cid_fifo { .next = NULL, \ } +static inline bool _cr_ipc_cid_fifo_isempty(struct _cr_ipc_cid_fifo *fifo) { + return !fifo->head; +} + static inline void _cr_ipc_cid_fifo_push(struct _cr_ipc_cid_fifo *fifo, struct _cr_ipc_cid_fifo_node *self) { if (!fifo->tail) fifo->tail = &(fifo->head); *(fifo->tail) = self; + fifo->tail = &(self->next); } static inline cid_t _cr_ipc_cid_fifo_pop(struct _cr_ipc_cid_fifo *fifo) { diff --git a/libcr_ipc/include/libcr_ipc/sema.h b/libcr_ipc/include/libcr_ipc/sema.h index 8d71c69..257c8d5 100644 --- a/libcr_ipc/include/libcr_ipc/sema.h +++ b/libcr_ipc/include/libcr_ipc/sema.h @@ -45,7 +45,7 @@ static inline bool _cr_sema_drain(cr_sema_t *sema) { sema->locked = true; asm volatile ("":::"memory"); while (state == DRAINING) { - if (!sema->waiters.head) { + if (_cr_ipc_cid_fifo_isempty(&sema->waiters)) { state = DRAINED_ALL; } else if (!sema->cnt) { state = DRAINED_SOME; @@ -66,7 +66,7 @@ static inline bool _cr_sema_drain(cr_sema_t *sema) { } while (state == DRAINED_SOME && sema->cnt); /* If state == DRAINED_SELF, then we better have been the last * item in the list! */ - assert(state != DRAINED_SELF || !sema->waiters.head); + assert(state != DRAINED_SELF || _cr_ipc_cid_fifo_isempty(&sema->waiters)); return state == DRAINED_SELF; } |