Skip to content

Commit

Permalink
Merge pull request RIOT-OS#15485 from miri64/mbox/enh/mbox-unset
Browse files Browse the repository at this point in the history
mbox: provide function to unset initialized mbox
  • Loading branch information
Teufelchen1 authored Mar 19, 2024
2 parents 21bd422 + 6229fda commit 5242533
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions core/include/mbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ static inline size_t mbox_avail(mbox_t *mbox)
return cib_avail(&mbox->cib);
}

/**
* @brief Unset's the mbox, effectively deinitializing and invalidating it.
*
* @param[in] mbox ptr to mailbox to operate on
*/
static inline void mbox_unset(mbox_t *mbox)
{
mbox->msg_array = NULL;
mbox->cib.mask = 0;
}

#ifdef __cplusplus
}
#endif
Expand Down
4 changes: 2 additions & 2 deletions pkg/lwip/include/arch/sys_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ typedef struct {

static inline bool sys_mbox_valid(sys_mbox_t *mbox)
{
return (mbox != NULL) && (mbox->mbox.cib.mask != 0);
return (mbox != NULL) && (mbox_size(&mbox->mbox) != 0);
}

static inline void sys_mbox_set_invalid(sys_mbox_t *mbox)
{
if (mbox != NULL) {
mbox->mbox.cib.mask = 0;
mbox_unset(&mbox->mbox);
}
}

Expand Down

0 comments on commit 5242533

Please sign in to comment.