Skip to content

Commit d45a7f7

Browse files
committed
modules: lvgl: Fix stdlib usage
LVGL already provides an implementation wrapping a C standard library into its own lv_* functions. Add them to the CMakeLists and set the appropriate defines for them. Signed-off-by: Fabian Blatz <[email protected]>
1 parent 9b5aa6b commit d45a7f7

File tree

2 files changed

+6
-27
lines changed

2 files changed

+6
-27
lines changed

modules/lvgl/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ zephyr_include_directories(${LVGL_DIR}/src/)
1616
zephyr_include_directories(include)
1717

1818
zephyr_compile_definitions(LV_CONF_INCLUDE_SIMPLE=1)
19+
zephyr_library_compile_definitions(_POSIX_C_SOURCE=200809L)
1920
zephyr_compile_definitions(LV_CONF_PATH="${CMAKE_CURRENT_SOURCE_DIR}/include/lv_conf.h")
2021

2122
zephyr_library_sources(
@@ -307,6 +308,8 @@ zephyr_library_sources(
307308
${LVGL_DIR}/src/others/xml/parsers/lv_xml_textarea_parser.c
308309

309310
${LVGL_DIR}/src/stdlib/builtin/lv_tlsf.c
311+
${LVGL_DIR}/src/stdlib/clib/lv_string_clib.c
312+
${LVGL_DIR}/src/stdlib/clib/lv_sprintf_clib.c
310313

311314
${LVGL_DIR}/src/stdlib/lv_mem.c
312315

modules/lvgl/include/lv_conf.h

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
/* Memory manager settings */
1616

17-
#define LV_USE_STDLIB_MALLOC LV_STDLIB_CUSTOM
17+
#define LV_USE_STDLIB_MALLOC LV_STDLIB_CUSTOM
18+
#define LV_USE_STDLIB_STRING LV_STDLIB_CLIB
19+
#define LV_USE_STDLIB_SPRINTF LV_STDLIB_CLIB
1820

1921
#if defined(CONFIG_LV_Z_MEM_POOL_HEAP_LIB_C)
2022
#define LV_STDLIB_INCLUDE "stdlib.h"
@@ -28,32 +30,6 @@
2830
#define lv_free_core lvgl_free
2931
#endif
3032

31-
/* Stdlib wrappers */
32-
33-
/* Needed because parameter types are not compatible */
34-
static __always_inline void zmemset(void *dst, uint8_t v, size_t len)
35-
{
36-
memset(dst, v, len);
37-
}
38-
39-
#define lv_snprintf snprintf
40-
#define lv_vsnprintf vsnprintf
41-
#define lv_memcpy memcpy
42-
#define lv_memmove memmove
43-
#define lv_memset zmemset
44-
#define lv_memcmp memcmp
45-
#define lv_strdup strdup
46-
#define lv_strndup strndup
47-
#define lv_strlen strlen
48-
#define lv_strnlen strnlen
49-
#define lv_strcmp strcmp
50-
#define lv_strncmp strncmp
51-
#define lv_strcpy strcpy
52-
#define lv_strncpy strncpy
53-
#define lv_strlcpy strlcpy
54-
#define lv_strcat strcat
55-
#define lv_strncat strncat
56-
#define lv_strchr strchr
5733
#define LV_ASSERT_HANDLER __ASSERT_NO_MSG(false);
5834
#define LV_ASSERT_HANDLER_INCLUDE "zephyr/sys/__assert.h"
5935

0 commit comments

Comments
 (0)