diff --git a/bsp/abstract-machine/include/extra.h b/bsp/abstract-machine/include/extra.h index 27c72f4a51ce..58ee47d35758 100644 --- a/bsp/abstract-machine/include/extra.h +++ b/bsp/abstract-machine/include/extra.h @@ -1,8 +1,7 @@ -typedef long suseconds_t; -typedef unsigned long useconds_t; -#include + #ifdef __ISA_NATIVE__ +#include // rename posix API to avoid conflict with glibc in native #define open rt_open #define creat rt_creat @@ -34,5 +33,7 @@ typedef unsigned long useconds_t; #define getcwd rt_getcwd #define gettimeofday rt_gettimeofday - +#else +typedef long suseconds_t; +typedef unsigned long useconds_t; #endif diff --git a/components/libc/compilers/common/cstdlib.c b/components/libc/compilers/common/cstdlib.c index 64bfbb10e0c0..8c947b7886e7 100644 --- a/components/libc/compilers/common/cstdlib.c +++ b/components/libc/compilers/common/cstdlib.c @@ -8,6 +8,7 @@ * 2021-02-15 Meco Man first version */ +#include #include #define DBG_TAG "stdlib" diff --git a/components/libc/compilers/common/cstring.c b/components/libc/compilers/common/cstring.c index 59c516d273e8..ff2dfaad26b9 100644 --- a/components/libc/compilers/common/cstring.c +++ b/components/libc/compilers/common/cstring.c @@ -48,12 +48,12 @@ void explicit_bzero(void* s, size_t n) char* index(const char* s, int c) { - return strchr(s, c); + return (char*)strchr(s, c); } char* rindex(const char* s, int c) { - return strrchr(s, c); + return (char*)strrchr(s, c); } int ffs(int i) diff --git a/components/libc/compilers/common/include/sys/select.h b/components/libc/compilers/common/include/sys/select.h index 32ce39c287e2..71d7360f898d 100644 --- a/components/libc/compilers/common/include/sys/select.h +++ b/components/libc/compilers/common/include/sys/select.h @@ -14,7 +14,8 @@ #include #include -#include + +struct timeval; #ifdef __cplusplus extern "C" { diff --git a/components/libc/compilers/common/include/sys/time.h b/components/libc/compilers/common/include/sys/time.h index 87be959715e2..cba0bbc4c18f 100644 --- a/components/libc/compilers/common/include/sys/time.h +++ b/components/libc/compilers/common/include/sys/time.h @@ -48,7 +48,7 @@ struct timezone int tz_dsttime; /* type of dst correction */ }; -#ifndef _TIMEVAL_DEFINED +#if !defined (_TIMEVAL_DEFINED) &&!defined (__timeval_defined) #define _TIMEVAL_DEFINED struct timeval { diff --git a/components/utilities/utest/utest.c b/components/utilities/utest/utest.c index 3c91fa81667c..8cb7d625dd96 100644 --- a/components/utilities/utest/utest.c +++ b/components/utilities/utest/utest.c @@ -149,8 +149,8 @@ static const char *file_basename(const char *file) char *end_ptr = RT_NULL; char *rst = RT_NULL; - if (!((end_ptr = strrchr(file, '\\')) != RT_NULL || \ - (end_ptr = strrchr(file, '/')) != RT_NULL) || \ + if (!((end_ptr = (char*)strrchr(file, '\\')) != RT_NULL || \ + (end_ptr = (char*)strrchr(file, '/')) != RT_NULL) || \ (rt_strlen(file) < 2)) { rst = (char *)file;