[libc] add RT_USING_INTERNAL_LIBC_ONLY macro

This option is for RT-Thread Nano version.
If select this option, it will not compile components/libc
folder and only use tool chain internal libc. Normally, the
tool chain internal is only cover ISO standard (e.g. armcc),
but some tool chains' internal libc will cover more than
ISO standard (e.g. newlib).
This commit is contained in:
Meco Man 2023-11-21 09:39:42 -05:00
parent d73fd165b0
commit 873fd76b2f
4 changed files with 42 additions and 24 deletions

View File

@ -1,11 +1,27 @@
menu "C/C++ and POSIX layer" menu "C/C++ and POSIX layer"
# This is for external libc(e.g. mlib), config RT_USING_INTERNAL_LIBC_ONLY
# and NOT for newlib or picolibc which are inherent in the toolchains. bool "Only use tool chain internal libc"
# Usually, the external libc should be a software package and select default n
# RT_USING_EXTERNAL_LIBC in software package's Kconfig help
This option is for RT-Thread Nano version.
If select this option, it will not compile components/libc
folder and only use tool chain internal libc. Normally, the
tool chain internal is only cover ISO standard (e.g. armcc),
but some tool chains' internal libc will cover more than
ISO standard (e.g. newlib). However, no matter the cover level
it is, the rt-thread libc leveling layer will not be involved
at all if select this option.
config RT_USING_EXTERNAL_LIBC config RT_USING_EXTERNAL_LIBC
depends on !RT_USING_INTERNAL_LIBC_ONLY
bool bool
help
This is for external libc(e.g. mlib),
and NOT for newlib or picolibc which are inherent in the toolchains.
Usually, the external libc should be a software package and select
RT_USING_EXTERNAL_LIBC in software package's Kconfig
This option is not available for users to select.
source "$RTT_DIR/components/libc/compilers/common/Kconfig" source "$RTT_DIR/components/libc/compilers/common/Kconfig"
source "$RTT_DIR/components/libc/posix/Kconfig" source "$RTT_DIR/components/libc/posix/Kconfig"

View File

@ -7,9 +7,10 @@ cwd = GetCurrentDir()
objs = [] objs = []
list = os.listdir(cwd) list = os.listdir(cwd)
for d in list: if not GetDepend('RT_USING_INTERNAL_LIBC_ONLY'):
path = os.path.join(cwd, d) for d in list:
if os.path.isfile(os.path.join(path, 'SConscript')): path = os.path.join(cwd, d)
objs = objs + SConscript(os.path.join(d, 'SConscript')) if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
Return('objs') Return('objs')

View File

@ -50,9 +50,9 @@
* 2023-04-01 Chushicheng change version number to v5.0.1 * 2023-04-01 Chushicheng change version number to v5.0.1
* 2023-05-20 Bernard add stdc atomic detection. * 2023-05-20 Bernard add stdc atomic detection.
* 2023-09-15 xqyjlj perf rt_hw_interrupt_disable/enable * 2023-09-15 xqyjlj perf rt_hw_interrupt_disable/enable
* 2023-09-17 Meco Man add RT_USING_LIBC_ISO_ONLY macro
* 2023-10-10 Chushicheng change version number to v5.1.0 * 2023-10-10 Chushicheng change version number to v5.1.0
* 2023-10-11 zmshahaha move specific devices related and driver to components/drivers * 2023-10-11 zmshahaha move specific devices related and driver to components/drivers
* 2023-11-21 Meco Man add RT_USING_INTERNAL_LIBC_ONLY macro
*/ */
#ifndef __RT_DEF_H__ #ifndef __RT_DEF_H__
@ -60,24 +60,26 @@
#include <rtconfig.h> #include <rtconfig.h>
#ifdef RT_USING_LIBC /*
#if !defined(RT_USING_LIBC_ISO_ONLY) && !defined(RT_VER_NUM) * If RT_VER_NUM is not defined or RT_USING_INTERNAL_LIBC_ONLY is defined,
/* If RT_VER_NUM is not defined, there is no extra libc support. */ * there is no extra libc support, only internal libc can be used.
#define RT_USING_LIBC_ISO_ONLY (1) */
#if defined(RT_USING_INTERNAL_LIBC_ONLY) || !defined(RT_VER_NUM)
#define __RT_USING_INTERNAL_LIBC_ONLY (1)
#else #else
#define RT_USING_LIBC_ISO_ONLY (0) #define __RT_USING_INTERNAL_LIBC_ONLY (0)
#endif /* !defined(RT_USING_LIBC_ISO_ONLY) && !defined(RT_VER_NUM) */ #endif /* defined(RT_USING_INTERNAL_LIBC_ONLY) && !defined(RT_VER_NUM) */
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdarg.h> #include <stdarg.h>
#if !RT_USING_LIBC_ISO_ONLY #if !__RT_USING_INTERNAL_LIBC_ONLY
#include <sys/types.h> #include <sys/types.h>
#include <sys/errno.h> #include <sys/errno.h>
#if defined(RT_USING_SIGNALS) || defined(RT_USING_SMART) #if defined(RT_USING_SIGNALS) || defined(RT_USING_SMART)
#include <sys/signal.h> #include <sys/signal.h>
#endif /* defined(RT_USING_SIGNALS) || defined(RT_USING_SMART) */ #endif /* defined(RT_USING_SIGNALS) || defined(RT_USING_SMART) */
#endif /* !RT_USING_LIBC_ISO_ONLY */ #endif /* !__RT_USING_INTERNAL_LIBC_ONLY */
#endif /* RT_USING_LIBC */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -133,13 +135,13 @@ typedef unsigned long long rt_uint64_t; /**< 64bit unsigned inte
#endif /* RT_USING_LIBC */ #endif /* RT_USING_LIBC */
#endif /* RT_USING_ARCH_DATA_TYPE */ #endif /* RT_USING_ARCH_DATA_TYPE */
#if defined(RT_USING_LIBC) && !RT_USING_LIBC_ISO_ONLY #if defined(RT_USING_LIBC) && !__RT_USING_INTERNAL_LIBC_ONLY
typedef size_t rt_size_t; /**< Type for size number */ typedef size_t rt_size_t; /**< Type for size number */
typedef ssize_t rt_ssize_t; /**< Used for a count of bytes or an error indication */ typedef ssize_t rt_ssize_t; /**< Used for a count of bytes or an error indication */
#else #else
typedef rt_ubase_t rt_size_t; /**< Type for size number */ typedef rt_ubase_t rt_size_t; /**< Type for size number */
typedef rt_base_t rt_ssize_t; /**< Used for a count of bytes or an error indication */ typedef rt_base_t rt_ssize_t; /**< Used for a count of bytes or an error indication */
#endif /* defined(RT_USING_LIBC) && !RT_USING_LIBC_ISO_ONLY */ #endif /* defined(RT_USING_LIBC) && !__RT_USING_INTERNAL_LIBC_ONLY */
typedef rt_base_t rt_err_t; /**< Type for error number */ typedef rt_base_t rt_err_t; /**< Type for error number */
typedef rt_uint32_t rt_time_t; /**< Type for time stamp */ typedef rt_uint32_t rt_time_t; /**< Type for time stamp */
@ -403,7 +405,7 @@ typedef int (*init_fn_t)(void);
/**@{*/ /**@{*/
/* RT-Thread error code definitions */ /* RT-Thread error code definitions */
#if defined(RT_USING_LIBC) && !RT_USING_LIBC_ISO_ONLY #if defined(RT_USING_LIBC) && !__RT_USING_INTERNAL_LIBC_ONLY
/* POSIX error code compatible */ /* POSIX error code compatible */
#define RT_EOK 0 /**< There is no error */ #define RT_EOK 0 /**< There is no error */
#define RT_ERROR 255 /**< A generic/unknown error happens */ #define RT_ERROR 255 /**< A generic/unknown error happens */
@ -438,7 +440,7 @@ typedef int (*init_fn_t)(void);
#define RT_EPERM 13 /**< Operation not permitted */ #define RT_EPERM 13 /**< Operation not permitted */
#define RT_ETRAP 14 /**< Trap event */ #define RT_ETRAP 14 /**< Trap event */
#define RT_EFAULT 15 /**< Bad address */ #define RT_EFAULT 15 /**< Bad address */
#endif /* defined(RT_USING_LIBC) && !RT_USING_LIBC_ISO_ONLY */ #endif /* defined(RT_USING_LIBC) && !__RT_USING_INTERNAL_LIBC_ONLY */
/**@}*/ /**@}*/

View File

@ -659,13 +659,12 @@ void rt_components_board_init(void);
#else #else
int rt_kprintf(const char *fmt, ...); int rt_kprintf(const char *fmt, ...);
void rt_kputs(const char *str); void rt_kputs(const char *str);
#endif /* RT_USING_CONSOLE */
rt_err_t rt_backtrace(void); rt_err_t rt_backtrace(void);
rt_err_t rt_backtrace_thread(rt_thread_t thread); rt_err_t rt_backtrace_thread(rt_thread_t thread);
rt_err_t rt_backtrace_frame(struct rt_hw_backtrace_frame *frame); rt_err_t rt_backtrace_frame(struct rt_hw_backtrace_frame *frame);
#endif /* RT_USING_CONSOLE */
int rt_vsprintf(char *dest, const char *format, va_list arg_ptr); int rt_vsprintf(char *dest, const char *format, va_list arg_ptr);
int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args); int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args);
int rt_sprintf(char *buf, const char *format, ...); int rt_sprintf(char *buf, const char *format, ...);