1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

feat(stdlib): add lv_memmove (#4888)

Signed-off-by: Xu Xingliang <xuxingliang@xiaomi.com>
This commit is contained in:
Neo Xu 2023-11-29 18:15:27 +08:00 committed by GitHub
parent 34f7e9e012
commit 6bc99b1d1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 49 additions and 23 deletions

View File

@ -46,10 +46,7 @@ extern "C" {
#define LZ4_FREESTANDING 1
#define LZ4_memset lv_memset
#define LZ4_memcpy lv_memcpy
#define LZ4_memmove memmove
/**
* @todo add LZ4_memmove
*/
#define LZ4_memmove lv_memmove
#ifndef LZ4_H_2983827168210
#define LZ4_H_2983827168210

View File

@ -260,4 +260,4 @@ static void lv_mem_walker(void * ptr, size_t size, int used, void * user)
mon_p->free_biggest_size = size;
}
}
#endif /*LV_USE_BUILTIN_MALLOC*/
#endif /*LV_STDLIB_BUILTIN*/

View File

@ -883,4 +883,4 @@ int lv_vsnprintf(char * buffer, size_t count, const char * format, va_list va)
return _lv_vsnprintf(_out_buffer, buffer, count, format, va);
}
#endif /*LV_USE_BUILTIN_SNPRINTF*/
#endif /*LV_STDLIB_BUILTIN*/

View File

@ -145,6 +145,22 @@ LV_ATTRIBUTE_FAST_MEM void lv_memset(void * dst, uint8_t v, size_t len)
}
}
LV_ATTRIBUTE_FAST_MEM void * lv_memmove(void * dst, const void * src, size_t len)
{
if(dst < src || (char *)dst > ((char *)src + len)) {
return lv_memcpy(dst, src, len);
}
else {
char * tmp = (char *)dst + len;
char * s = (char *) src + len;
while(len--) {
*--tmp = *--s;
}
return dst;
}
}
/* See https://en.cppreference.com/w/c/string/byte/strlen for reference */
size_t lv_strlen(const char * str)
{
@ -194,4 +210,4 @@ char * lv_strdup(const char * src)
* STATIC FUNCTIONS
**********************/
#endif /*LV_USE_BUILTIN_MEMCPY*/
#endif /*LV_STDLIB_BUILTIN*/

View File

@ -1242,4 +1242,4 @@ void * lv_tlsf_realloc(lv_tlsf_t tlsf, void * ptr, size_t size)
return p;
}
#endif /* LV_USE_BUILTIN_MALLOC */
#endif /*LV_STDLIB_BUILTIN*/

View File

@ -105,4 +105,4 @@ int lv_tlsf_check_pool(lv_pool_t pool);
#endif /*LV_TLSF_H*/
#endif /* LV_USE_BUILTIN_MALLOC */
#endif /*LV_STDLIB_BUILTIN*/

View File

@ -91,4 +91,4 @@ lv_result_t lv_mem_test_core(void)
* STATIC FUNCTIONS
**********************/
#endif /*LV_USE_BUILTIN_MALLOC*/
#endif /*LV_STDLIB_CLIB*/

View File

@ -8,12 +8,9 @@
#include "../../lv_conf_internal.h"
#if LV_USE_STDLIB_STRING == LV_STDLIB_CLIB
#include "../lv_string.h"
#include "../lv_mem.h" /*Need lv_malloc*/
#include <string.h>
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
#include "../lv_mem.h"
#endif
/*********************
* DEFINES
*********************/
@ -48,6 +45,11 @@ LV_ATTRIBUTE_FAST_MEM void lv_memset(void * dst, uint8_t v, size_t len)
memset(dst, v, len);
}
LV_ATTRIBUTE_FAST_MEM void * lv_memmove(void * dst, const void * src, size_t len)
{
return memmove(dst, src, len);
}
size_t lv_strlen(const char * str)
{
return strlen(str);
@ -92,4 +94,4 @@ char * lv_strdup(const char * src)
* STATIC FUNCTIONS
**********************/
#endif /*LV_USE_BUILTIN_MEMCPY*/
#endif /*LV_STDLIB_CLIB*/

View File

@ -48,6 +48,15 @@ void * lv_memcpy(void * dst, const void * src, size_t len);
*/
void lv_memset(void * dst, uint8_t v, size_t len);
/**
* @brief Move a block of memory from source to destination
* @param dst Pointer to the destination array where the content is to be copied.
* @param src Pointer to the source of data to be copied.
* @param len Number of bytes to copy
* @return Pointer to the destination array.
*/
void * lv_memmove(void * dst, const void * src, size_t len);
/**
* Same as `memset(dst, 0x00, len)`.
* @param dst pointer to the destination buffer

View File

@ -92,4 +92,4 @@ lv_result_t lv_mem_test_core(void)
* STATIC FUNCTIONS
**********************/
#endif /*LV_USE_BUILTIN_MALLOC*/
#endif /*LV_STDLIB_MICROPYTHON*/

View File

@ -95,4 +95,4 @@ lv_result_t lv_mem_test_core(void)
* STATIC FUNCTIONS
**********************/
#endif /*LV_USE_STDLIB_MALLOC*/
#endif /*LV_STDLIB_RTTHREAD*/

View File

@ -58,4 +58,4 @@ int lv_vsnprintf(char * buffer, size_t count, const char * format, va_list va)
* STATIC FUNCTIONS
**********************/
#endif /*LV_USE_STDLIB_SPRINTF*/
#endif /*LV_STDLIB_RTTHREAD*/

View File

@ -8,12 +8,9 @@
#include "../../lv_conf_internal.h"
#if LV_USE_STDLIB_STRING == LV_STDLIB_RTTHREAD
#include "../lv_string.h"
#include "../lv_mem.h" /*Need lv_malloc*/
#include <rtthread.h>
#if LV_USE_STDLIB_MALLOC == LV_STDLIB_BUILTIN
#include "../lv_mem.h"
#endif
/*********************
* DEFINES
*********************/
@ -48,6 +45,11 @@ LV_ATTRIBUTE_FAST_MEM void lv_memset(void * dst, uint8_t v, size_t len)
rt_memset(dst, v, len);
}
LV_ATTRIBUTE_FAST_MEM void * lv_memmove(void * dst, const void * src, size_t len)
{
return rt_memmove(dst, src, len);
}
size_t lv_strlen(const char * str)
{
return rt_strlen(str);
@ -87,4 +89,4 @@ char * lv_strdup(const char * src)
* STATIC FUNCTIONS
**********************/
#endif /*LV_USE_STDLIB_STRING*/
#endif /*LV_STDLIB_RTTHREAD*/