diff options
author | Uros Majstorovic <majstor@majstor.org> | 2025-02-15 02:15:57 +0100 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2025-02-15 02:15:57 +0100 |
commit | 7269b0a3f0b7e5f41ba65c7321fde9b8fd88c642 (patch) | |
tree | a03775e3a61d752850df6ac6b6bdcc26f5dcc973 /yocto/meta-bsp-rvphone/recipes-bsp/esp32spid/src/msgq.c | |
parent | b8015c9579d88bb7c5f0637c1bac836ec71bda1d (diff) |
removed old (compulab) yocto directory
Diffstat (limited to 'yocto/meta-bsp-rvphone/recipes-bsp/esp32spid/src/msgq.c')
-rw-r--r-- | yocto/meta-bsp-rvphone/recipes-bsp/esp32spid/src/msgq.c | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/yocto/meta-bsp-rvphone/recipes-bsp/esp32spid/src/msgq.c b/yocto/meta-bsp-rvphone/recipes-bsp/esp32spid/src/msgq.c deleted file mode 100644 index ff9f59e..0000000 --- a/yocto/meta-bsp-rvphone/recipes-bsp/esp32spid/src/msgq.c +++ /dev/null @@ -1,42 +0,0 @@ -#include <stdlib.h> -#include <pthread.h> - -#include "msgq.h" - -#define IDX_MASK(IDX, SIZE) ((IDX) & ((SIZE) - 1)) - -int msgq_init(MSGQueue *msgq, unsigned char **array, uint16_t size) { - int rv; - - msgq->idx_r = 0; - msgq->idx_w = 0; - msgq->size = size; - msgq->array = array; - rv = pthread_mutex_init(&msgq->mutex, NULL); - if (rv) { - return MSGQ_ERR; - } - - rv = pthread_cond_init(&msgq->cond, NULL); - if (rv) { - pthread_mutex_destroy(&msgq->mutex); - return MSGQ_ERR; - } -} - -int msgq_push(MSGQueue *msgq, unsigned char *buffer) { - if ((uint16_t)(msgq->idx_w - msgq->idx_r) == msgq->size) return MSGQ_ERR_FULL; - - msgq->array[IDX_MASK(msgq->idx_w++, msgq->size)] = buffer; - return MSGQ_OK; -} - -unsigned char *msgq_pop(MSGQueue *msgq) { - if (msgq->idx_r == msgq->idx_w) return NULL; - - return msgq->array[IDX_MASK(msgq->idx_r++, msgq->size)]; -} - -uint16_t msgq_len(MSGQueue *msgq) { - return (uint16_t)(msgq->idx_w - msgq->idx_r); -} |