Skip to content

Commit 0b8771d

Browse files
faxe1008dkalowsk
authored andcommitted
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]> (cherry picked from commit 076994f)
1 parent 13dd5cb commit 0b8771d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
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(
@@ -309,6 +310,8 @@ zephyr_library_sources(
309310
${LVGL_DIR}/src/stdlib/builtin/lv_sprintf_builtin.c
310311
${LVGL_DIR}/src/stdlib/builtin/lv_string_builtin.c
311312
${LVGL_DIR}/src/stdlib/builtin/lv_tlsf.c
313+
${LVGL_DIR}/src/stdlib/clib/lv_string_clib.c
314+
${LVGL_DIR}/src/stdlib/clib/lv_sprintf_clib.c
312315

313316
${LVGL_DIR}/src/stdlib/clib/lv_mem_core_clib.c
314317
${LVGL_DIR}/src/stdlib/clib/lv_sprintf_clib.c

modules/lvgl/include/lv_conf.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212

1313
/* Memory manager settings */
1414

15-
#define LV_USE_STDLIB_MALLOC LV_STDLIB_CUSTOM
15+
#define LV_USE_STDLIB_MALLOC LV_STDLIB_CUSTOM
16+
#define LV_USE_STDLIB_STRING LV_STDLIB_CLIB
17+
#define LV_USE_STDLIB_SPRINTF LV_STDLIB_CLIB
1618

1719
#if defined(CONFIG_LV_Z_MEM_POOL_HEAP_LIB_C)
1820
#define LV_STDLIB_INCLUDE "stdlib.h"
@@ -26,9 +28,6 @@
2628
#define lv_free_core lvgl_free
2729
#endif
2830

29-
/* Misc settings */
30-
#define lv_snprintf snprintf
31-
#define lv_vsnprintf vsnprintf
3231
#define LV_ASSERT_HANDLER __ASSERT_NO_MSG(false);
3332
#define LV_ASSERT_HANDLER_INCLUDE "zephyr/sys/__assert.h"
3433

0 commit comments

Comments
 (0)