libc: share time() between minimal libc and armclang libc

Introduce a place to share implementations of libc functions that
are needed by different libc versions.  Place time() in this common
location so it can be shared when building for either minimal libc or
armclang libc.

Signed-off-by: Kumar Gala <kumar.gala@intel.com>
This commit is contained in:
Kumar Gala 2023-03-24 19:10:50 +00:00 committed by Carles Cufí
parent a7aafcbbdc
commit 672aeace88
8 changed files with 16 additions and 1 deletions

View file

@ -15,6 +15,7 @@ choice LIBC_IMPLEMENTATION
config ARMCLANG_STD_LIBC config ARMCLANG_STD_LIBC
bool "ARM Compiler C library" bool "ARM Compiler C library"
select COMMON_LIBC_TIME if POSIX_CLOCK
help help
Use the full Arm Compiler runtime libraries. Use the full Arm Compiler runtime libraries.
A reduced Zephyr minimal libc will be used for library functionality A reduced Zephyr minimal libc will be used for library functionality

View file

@ -5,3 +5,5 @@ add_subdirectory_ifdef(CONFIG_ARMCLANG_STD_LIBC armstdc)
add_subdirectory_ifdef(CONFIG_MINIMAL_LIBC minimal) add_subdirectory_ifdef(CONFIG_MINIMAL_LIBC minimal)
add_subdirectory_ifdef(CONFIG_NEWLIB_LIBC newlib) add_subdirectory_ifdef(CONFIG_NEWLIB_LIBC newlib)
add_subdirectory_ifdef(CONFIG_PICOLIBC picolibc) add_subdirectory_ifdef(CONFIG_PICOLIBC picolibc)
add_subdirectory(common)

View file

@ -75,6 +75,7 @@ endchoice # LIBC_IMPLEMENTATION
config HAS_NEWLIB_LIBC_NANO config HAS_NEWLIB_LIBC_NANO
bool bool
rsource "common/Kconfig"
rsource "minimal/Kconfig" rsource "minimal/Kconfig"
rsource "newlib/Kconfig" rsource "newlib/Kconfig"
rsource "picolibc/Kconfig" rsource "picolibc/Kconfig"

View file

@ -0,0 +1,4 @@
# SPDX-License-Identifier: Apache-2.0
zephyr_library()
zephyr_library_sources_ifdef(CONFIG_COMMON_LIBC_TIME source/time/time.c)

7
lib/libc/common/Kconfig Normal file
View file

@ -0,0 +1,7 @@
# Copyright (c) 2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
config COMMON_LIBC_TIME
bool
help
common implementation of time().

View file

@ -33,7 +33,6 @@ zephyr_library_sources(
if(CONFIG_MINIMAL_LIBC_TIME) if(CONFIG_MINIMAL_LIBC_TIME)
zephyr_library_sources(source/time/gmtime.c) zephyr_library_sources(source/time/gmtime.c)
zephyr_library_sources_ifdef(CONFIG_POSIX_CLOCK source/time/time.c)
endif() endif()
zephyr_library_sources_ifdef(CONFIG_MINIMAL_LIBC_RAND source/stdlib/rand.c) zephyr_library_sources_ifdef(CONFIG_MINIMAL_LIBC_RAND source/stdlib/rand.c)

View file

@ -66,6 +66,7 @@ config MINIMAL_LIBC_RAND
config MINIMAL_LIBC_TIME config MINIMAL_LIBC_TIME
bool "Time functions" bool "Time functions"
select COMMON_LIBC_TIME if POSIX_CLOCK
default y default y
help help
Enable time() and gmtime_r() for the minimal libc. Enable time() and gmtime_r() for the minimal libc.