From fb02d576c01a307c805c92f449944f89fd069470 Mon Sep 17 00:00:00 2001 From: Peter Mitsis Date: Thu, 13 Oct 2016 16:55:45 -0400 Subject: [PATCH] unified: Memory map APIs to use size_t Change-Id: I035019c0cb7193400d02f493546fd3964baf073a Signed-off-by: Peter Mitsis --- include/kernel.h | 12 ++++++------ include/legacy.h | 6 +++++- kernel/unified/mem_map.c | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/kernel.h b/include/kernel.h index 7a4993d9c1d..fa13bb6370e 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -1454,11 +1454,11 @@ extern void k_pipe_block_put(struct k_pipe *pipe, struct k_mem_block *block, struct k_mem_map { _wait_q_t wait_q; - int num_blocks; - int block_size; + uint32_t num_blocks; + size_t block_size; char *buffer; char *free_list; - int num_used; + uint32_t num_used; _DEBUG_TRACING_KERNEL_OBJECTS_NEXT_PTR(k_mem_map); }; @@ -1511,7 +1511,7 @@ struct k_mem_map { * @return N/A */ extern void k_mem_map_init(struct k_mem_map *map, void *buffer, - int block_size, int num_blocks); + size_t block_size, uint32_t num_blocks); /** * @brief Allocate a memory map block. @@ -1552,7 +1552,7 @@ extern void k_mem_map_free(struct k_mem_map *map, void **mem); * * @return Number of used memory blocks */ -static inline int k_mem_map_num_used_get(struct k_mem_map *map) +static inline uint32_t k_mem_map_num_used_get(struct k_mem_map *map) { return map->num_used; } @@ -1568,7 +1568,7 @@ static inline int k_mem_map_num_used_get(struct k_mem_map *map) * * @return Number of unused memory blocks */ -static inline int k_mem_map_num_free_get(struct k_mem_map *map) +static inline uint32_t k_mem_map_num_free_get(struct k_mem_map *map) { return map->num_blocks - map->num_used; } diff --git a/include/legacy.h b/include/legacy.h index 4ae1469d538..6e9a129b87f 100644 --- a/include/legacy.h +++ b/include/legacy.h @@ -393,7 +393,11 @@ static inline int task_mem_map_alloc(kmemory_map_t map, void **mptr, } #define task_mem_map_free k_mem_map_free -#define task_mem_map_used_get k_mem_map_num_used_get + +static inline int task_mem_map_used_get(kmemory_map_t map) +{ + return (int)k_mem_map_num_used_get(map); +} #define DEFINE_MEM_MAP(name, map_num_blocks, map_block_size) \ K_MEM_MAP_DEFINE(_k_mem_map_obj_##name, map_block_size, \ diff --git a/kernel/unified/mem_map.c b/kernel/unified/mem_map.c index 3a5bc40c97a..6966cc506ad 100644 --- a/kernel/unified/mem_map.c +++ b/kernel/unified/mem_map.c @@ -70,7 +70,7 @@ static int init_mem_map_module(struct device *dev) } void k_mem_map_init(struct k_mem_map *map, void *buffer, - int block_size, int num_blocks) + size_t block_size, uint32_t num_blocks) { map->num_blocks = num_blocks; map->block_size = block_size;