chore(cherrymp): add license
This commit is contained in:
10
third_party/cherrymp/chry_mempool.c
vendored
10
third_party/cherrymp/chry_mempool.c
vendored
@@ -1,3 +1,8 @@
|
||||
/*
|
||||
* Copyright (c) 2024, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "chry_mempool.h"
|
||||
|
||||
int chry_mempool_create(struct chry_mempool *pool, void *block, uint32_t block_size, uint32_t block_count)
|
||||
@@ -8,7 +13,10 @@ int chry_mempool_create(struct chry_mempool *pool, void *block, uint32_t block_s
|
||||
ringbuf = usb_osal_malloc(sizeof(uintptr_t) * block_count);
|
||||
memset(ringbuf, 0, sizeof(uintptr_t) * block_count);
|
||||
|
||||
chry_ringbuffer_init(&pool->rb, ringbuf, sizeof(uintptr_t) * block_count);
|
||||
if (chry_ringbuffer_init(&pool->rb, ringbuf, sizeof(uintptr_t) * block_count) == -1) {
|
||||
usb_osal_free(ringbuf);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < block_count; i++) {
|
||||
addr = ((uintptr_t)block + i * block_size);
|
||||
|
||||
14
third_party/cherrymp/chry_mempool.h
vendored
14
third_party/cherrymp/chry_mempool.h
vendored
@@ -1,7 +1,11 @@
|
||||
/*
|
||||
* Copyright (c) 2024, sakumisu
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef CHRY_MEMPOOL_H
|
||||
#define CHRY_MEMPOOL_H
|
||||
|
||||
#include "usb_config.h"
|
||||
#include "usb_osal.h"
|
||||
#include "chry_ringbuffer.h"
|
||||
|
||||
@@ -10,10 +14,18 @@ struct chry_mempool {
|
||||
usb_osal_mq_t mq;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int chry_mempool_create(struct chry_mempool *pool, void *block, uint32_t block_size, uint32_t block_count);
|
||||
uintptr_t *chry_mempool_alloc(struct chry_mempool *pool);
|
||||
int chry_mempool_free(struct chry_mempool *pool, uintptr_t *item);
|
||||
int chry_mempool_send(struct chry_mempool *pool, uintptr_t *item);
|
||||
int chry_mempool_recv(struct chry_mempool *pool, uintptr_t **item, uint32_t timeout);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user