mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-01-23 17:40:01 +08:00
Merge pull request #2696 from HubertXie/master
[kservice][rt_kprintf]修复long long数据类型打印问题
This commit is contained in:
commit
bab3546f01
@ -545,6 +545,26 @@ RTM_EXPORT(rt_show_version);
|
|||||||
/* private function */
|
/* private function */
|
||||||
#define isdigit(c) ((unsigned)((c) - '0') < 10)
|
#define isdigit(c) ((unsigned)((c) - '0') < 10)
|
||||||
|
|
||||||
|
#ifdef RT_PRINTF_LONGLONG
|
||||||
|
rt_inline int divide(long long *n, int base)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
|
/* optimized for processor which does not support divide instructions. */
|
||||||
|
if (base == 10)
|
||||||
|
{
|
||||||
|
res = (int)(((unsigned long long)*n) % 10U);
|
||||||
|
*n = (long long)(((unsigned long long)*n) / 10U);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
res = (int)(((unsigned long long)*n) % 16U);
|
||||||
|
*n = (long long)(((unsigned long long)*n) / 16U);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
#else
|
||||||
rt_inline int divide(long *n, int base)
|
rt_inline int divide(long *n, int base)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
@ -563,6 +583,7 @@ rt_inline int divide(long *n, int base)
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
rt_inline int skip_atoi(const char **s)
|
rt_inline int skip_atoi(const char **s)
|
||||||
{
|
{
|
||||||
@ -584,7 +605,11 @@ rt_inline int skip_atoi(const char **s)
|
|||||||
#ifdef RT_PRINTF_PRECISION
|
#ifdef RT_PRINTF_PRECISION
|
||||||
static char *print_number(char *buf,
|
static char *print_number(char *buf,
|
||||||
char *end,
|
char *end,
|
||||||
|
#ifdef RT_PRINTF_LONGLONG
|
||||||
|
long long num,
|
||||||
|
#else
|
||||||
long num,
|
long num,
|
||||||
|
#endif
|
||||||
int base,
|
int base,
|
||||||
int s,
|
int s,
|
||||||
int precision,
|
int precision,
|
||||||
@ -592,7 +617,11 @@ static char *print_number(char *buf,
|
|||||||
#else
|
#else
|
||||||
static char *print_number(char *buf,
|
static char *print_number(char *buf,
|
||||||
char *end,
|
char *end,
|
||||||
|
#ifdef RT_PRINTF_LONGLONG
|
||||||
|
long long num,
|
||||||
|
#else
|
||||||
long num,
|
long num,
|
||||||
|
#endif
|
||||||
int base,
|
int base,
|
||||||
int s,
|
int s,
|
||||||
int type)
|
int type)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user