Merge pull request #5261 from mysterywolf/weak
[kernel] prepare to support full functional sprintf-family functions
This commit is contained in:
commit
6a6b43fe3e
|
@ -29,7 +29,7 @@
|
||||||
#ifndef _SFUD_CFG_H_
|
#ifndef _SFUD_CFG_H_
|
||||||
#define _SFUD_CFG_H_
|
#define _SFUD_CFG_H_
|
||||||
|
|
||||||
#include <rtconfig.h>
|
#include <rtthread.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It will print more information on debug mode.
|
* It will print more information on debug mode.
|
||||||
|
@ -47,7 +47,6 @@
|
||||||
|
|
||||||
#define DBG_TAG "SFUD"
|
#define DBG_TAG "SFUD"
|
||||||
#include <rtdbg.h>
|
#include <rtdbg.h>
|
||||||
extern void rt_kprintf(const char *fmt, ...);
|
|
||||||
#define SFUD_INFO(...) LOG_I(__VA_ARGS__)
|
#define SFUD_INFO(...) LOG_I(__VA_ARGS__)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -76,11 +76,13 @@ typedef unsigned int rt_uint32_t; /**< 32bit unsigned inte
|
||||||
#ifdef ARCH_CPU_64BIT
|
#ifdef ARCH_CPU_64BIT
|
||||||
typedef signed long rt_int64_t; /**< 64bit integer type */
|
typedef signed long rt_int64_t; /**< 64bit integer type */
|
||||||
typedef unsigned long rt_uint64_t; /**< 64bit unsigned integer type */
|
typedef unsigned long rt_uint64_t; /**< 64bit unsigned integer type */
|
||||||
|
typedef unsigned long rt_size_t; /**< Type for size number */
|
||||||
#else
|
#else
|
||||||
typedef signed long long rt_int64_t; /**< 64bit integer type */
|
typedef signed long long rt_int64_t; /**< 64bit integer type */
|
||||||
typedef unsigned long long rt_uint64_t; /**< 64bit unsigned integer type */
|
typedef unsigned long long rt_uint64_t; /**< 64bit unsigned integer type */
|
||||||
#endif
|
typedef unsigned int rt_size_t; /**< Type for size number */
|
||||||
#endif
|
#endif /* ARCH_CPU_64BIT */
|
||||||
|
#endif /* RT_USING_ARCH_DATA_TYPE */
|
||||||
|
|
||||||
typedef int rt_bool_t; /**< boolean type */
|
typedef int rt_bool_t; /**< boolean type */
|
||||||
typedef long rt_base_t; /**< Nbit CPU related date type */
|
typedef long rt_base_t; /**< Nbit CPU related date type */
|
||||||
|
@ -90,7 +92,6 @@ typedef rt_base_t rt_err_t; /**< Type for error numb
|
||||||
typedef rt_uint32_t rt_time_t; /**< Type for time stamp */
|
typedef rt_uint32_t rt_time_t; /**< Type for time stamp */
|
||||||
typedef rt_uint32_t rt_tick_t; /**< Type for tick count */
|
typedef rt_uint32_t rt_tick_t; /**< Type for tick count */
|
||||||
typedef rt_base_t rt_flag_t; /**< Type for flags */
|
typedef rt_base_t rt_flag_t; /**< Type for flags */
|
||||||
typedef rt_ubase_t rt_size_t; /**< Type for size number */
|
|
||||||
typedef rt_ubase_t rt_dev_t; /**< Type for device */
|
typedef rt_ubase_t rt_dev_t; /**< Type for device */
|
||||||
typedef rt_base_t rt_off_t; /**< Type for offset */
|
typedef rt_base_t rt_off_t; /**< Type for offset */
|
||||||
|
|
||||||
|
|
|
@ -541,14 +541,14 @@ void rt_components_board_init(void);
|
||||||
#define rt_kprintf(...)
|
#define rt_kprintf(...)
|
||||||
#define rt_kputs(str)
|
#define rt_kputs(str)
|
||||||
#else
|
#else
|
||||||
void rt_kprintf(const char *fmt, ...);
|
int rt_kprintf(const char *fmt, ...);
|
||||||
void rt_kputs(const char *str);
|
void rt_kputs(const char *str);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rt_int32_t rt_vsprintf(char *dest, const char *format, va_list arg_ptr);
|
int rt_vsprintf(char *dest, const char *format, va_list arg_ptr);
|
||||||
rt_int32_t 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);
|
||||||
rt_int32_t rt_sprintf(char *buf, const char *format, ...);
|
int rt_sprintf(char *buf, const char *format, ...);
|
||||||
rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *format, ...);
|
int rt_snprintf(char *buf, rt_size_t size, const char *format, ...);
|
||||||
|
|
||||||
#if defined(RT_USING_DEVICE) && defined(RT_USING_CONSOLE)
|
#if defined(RT_USING_DEVICE) && defined(RT_USING_CONSOLE)
|
||||||
rt_device_t rt_console_set_device(const char *name);
|
rt_device_t rt_console_set_device(const char *name);
|
||||||
|
|
|
@ -139,6 +139,10 @@ config RT_USING_ASM_MEMCPY
|
||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
|
|
||||||
|
config RT_USING_ASM_MEMSET
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
|
||||||
config RT_USING_TINY_FFS
|
config RT_USING_TINY_FFS
|
||||||
bool "Enable kservice to use tiny ffs"
|
bool "Enable kservice to use tiny ffs"
|
||||||
default n
|
default n
|
||||||
|
|
|
@ -115,6 +115,7 @@ int *_rt_errno(void)
|
||||||
}
|
}
|
||||||
RTM_EXPORT(_rt_errno);
|
RTM_EXPORT(_rt_errno);
|
||||||
|
|
||||||
|
#ifndef RT_USING_ASM_MEMSET
|
||||||
/**
|
/**
|
||||||
* This function will set the content of memory to specified value.
|
* This function will set the content of memory to specified value.
|
||||||
*
|
*
|
||||||
|
@ -127,7 +128,7 @@ RTM_EXPORT(_rt_errno);
|
||||||
*
|
*
|
||||||
* @return The address of source memory.
|
* @return The address of source memory.
|
||||||
*/
|
*/
|
||||||
RT_WEAK void *rt_memset(void *s, int c, rt_ubase_t count)
|
void *rt_memset(void *s, int c, rt_ubase_t count)
|
||||||
{
|
{
|
||||||
#ifdef RT_KSERVICE_USING_TINY_SIZE
|
#ifdef RT_KSERVICE_USING_TINY_SIZE
|
||||||
char *xs = (char *)s;
|
char *xs = (char *)s;
|
||||||
|
@ -200,6 +201,7 @@ RT_WEAK void *rt_memset(void *s, int c, rt_ubase_t count)
|
||||||
#endif /* RT_KSERVICE_USING_TINY_SIZE */
|
#endif /* RT_KSERVICE_USING_TINY_SIZE */
|
||||||
}
|
}
|
||||||
RTM_EXPORT(rt_memset);
|
RTM_EXPORT(rt_memset);
|
||||||
|
#endif /* RT_USING_ASM_MEMSET */
|
||||||
|
|
||||||
#ifndef RT_USING_ASM_MEMCPY
|
#ifndef RT_USING_ASM_MEMCPY
|
||||||
/**
|
/**
|
||||||
|
@ -338,7 +340,7 @@ RTM_EXPORT(rt_memmove);
|
||||||
* If the result > 0, cs is greater than ct.
|
* If the result > 0, cs is greater than ct.
|
||||||
* If the result = 0, cs is equal to ct.
|
* If the result = 0, cs is equal to ct.
|
||||||
*/
|
*/
|
||||||
RT_WEAK rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count)
|
rt_int32_t rt_memcmp(const void *cs, const void *ct, rt_ubase_t count)
|
||||||
{
|
{
|
||||||
const unsigned char *su1, *su2;
|
const unsigned char *su1, *su2;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
@ -842,10 +844,7 @@ static char *print_number(char *buf,
|
||||||
*
|
*
|
||||||
* @return The number of characters actually written to buffer.
|
* @return The number of characters actually written to buffer.
|
||||||
*/
|
*/
|
||||||
rt_int32_t rt_vsnprintf(char *buf,
|
RT_WEAK int rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args)
|
||||||
rt_size_t size,
|
|
||||||
const char *fmt,
|
|
||||||
va_list args)
|
|
||||||
{
|
{
|
||||||
#ifdef RT_PRINTF_LONGLONG
|
#ifdef RT_PRINTF_LONGLONG
|
||||||
unsigned long long num;
|
unsigned long long num;
|
||||||
|
@ -1119,7 +1118,7 @@ RTM_EXPORT(rt_vsnprintf);
|
||||||
*
|
*
|
||||||
* @return The number of characters actually written to buffer.
|
* @return The number of characters actually written to buffer.
|
||||||
*/
|
*/
|
||||||
rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...)
|
int rt_snprintf(char *buf, rt_size_t size, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
rt_int32_t n;
|
rt_int32_t n;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@ -1143,7 +1142,7 @@ RTM_EXPORT(rt_snprintf);
|
||||||
*
|
*
|
||||||
* @return The number of characters actually written to buffer.
|
* @return The number of characters actually written to buffer.
|
||||||
*/
|
*/
|
||||||
rt_int32_t rt_vsprintf(char *buf, const char *format, va_list arg_ptr)
|
int rt_vsprintf(char *buf, const char *format, va_list arg_ptr)
|
||||||
{
|
{
|
||||||
return rt_vsnprintf(buf, (rt_size_t) - 1, format, arg_ptr);
|
return rt_vsnprintf(buf, (rt_size_t) - 1, format, arg_ptr);
|
||||||
}
|
}
|
||||||
|
@ -1158,7 +1157,7 @@ RTM_EXPORT(rt_vsprintf);
|
||||||
*
|
*
|
||||||
* @return The number of characters actually written to buffer.
|
* @return The number of characters actually written to buffer.
|
||||||
*/
|
*/
|
||||||
rt_int32_t rt_sprintf(char *buf, const char *format, ...)
|
int rt_sprintf(char *buf, const char *format, ...)
|
||||||
{
|
{
|
||||||
rt_int32_t n;
|
rt_int32_t n;
|
||||||
va_list arg_ptr;
|
va_list arg_ptr;
|
||||||
|
@ -1258,8 +1257,10 @@ void rt_kputs(const char *str)
|
||||||
* This function will print a formatted string on system console.
|
* This function will print a formatted string on system console.
|
||||||
*
|
*
|
||||||
* @param fmt is the format parameters.
|
* @param fmt is the format parameters.
|
||||||
|
*
|
||||||
|
* @return The number of characters actually written to buffer.
|
||||||
*/
|
*/
|
||||||
RT_WEAK void rt_kprintf(const char *fmt, ...)
|
RT_WEAK int rt_kprintf(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
rt_size_t length;
|
rt_size_t length;
|
||||||
|
@ -1287,6 +1288,8 @@ RT_WEAK void rt_kprintf(const char *fmt, ...)
|
||||||
rt_hw_console_output(rt_log_buf);
|
rt_hw_console_output(rt_log_buf);
|
||||||
#endif /* RT_USING_DEVICE */
|
#endif /* RT_USING_DEVICE */
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
return length;
|
||||||
}
|
}
|
||||||
RTM_EXPORT(rt_kprintf);
|
RTM_EXPORT(rt_kprintf);
|
||||||
#endif /* RT_USING_CONSOLE */
|
#endif /* RT_USING_CONSOLE */
|
||||||
|
|
Loading…
Reference in New Issue