improve libc time and MSVC simulator (#5775)

- [libc] 解决由于类unix操作系统发展历史原因fcntl.h定义的标志位在不同编译器中定义不同的问题
- [simulator] 部分宏定义转为全局宏定义以确保vs内置文件可以正确配置
- [simulator] 取消自欺欺人式的警告消除处理方式
- [libc][time] 优化time相关结构体在不同编译器下的包含
This commit is contained in:
Man, Jianting (Meco)
2022-04-07 14:24:11 +08:00
committed by GitHub
parent e68f934ff8
commit c318dfa964
8 changed files with 73 additions and 25 deletions
@@ -1,5 +1,5 @@
import os
from building import *
Import('rtconfig')
src = []
@@ -9,6 +9,13 @@ group = []
src += Glob('*.c')
if rtconfig.PLATFORM != 'gcc' or rtconfig.ARCH == 'sim':
if rtconfig.PLATFORM != 'gcc':
group = DefineGroup('Compiler', src, depend = [''], CPPPATH = CPPPATH)
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
group = group + SConscript(os.path.join(d, 'SConscript'))
Return('group')
@@ -0,0 +1,4 @@
Because of the history issue, flags in fcntl.h, such as O_CREAT, have difference types of value. Some OS use hex flags and others use octal flags.
In terms of RT-Thread, Keil, IAR and MSVC use octal flags, which is located in the `tcntl/octal` folder; newlib uses hex flags; musl uses octal flags.
@@ -0,0 +1,15 @@
# RT-Thread building script for bridge
import os
from building import *
cwd = GetCurrentDir()
objs = []
list = os.listdir(cwd)
for d in list:
path = os.path.join(cwd, d)
if os.path.isfile(os.path.join(path, 'SConscript')):
objs = objs + SConscript(os.path.join(d, 'SConscript'))
Return('objs')
@@ -0,0 +1,14 @@
from building import *
Import('rtconfig')
src = []
cwd = GetCurrentDir()
CPPPATH = [cwd]
group = []
if rtconfig.PLATFORM == 'armcc' or\
rtconfig.PLATFORM == 'armclang' or\
rtconfig.PLATFORM == 'iar' or\
rtconfig.CROSS_TOOL == 'msvc':
group = DefineGroup('Compiler', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
+8 -6
View File
@@ -18,7 +18,9 @@
#include <time.h>
#ifdef _WIN32
#include <winsock.h> /* for struct timeval */
#endif
#include <corecrt.h> /* for __time64_t */
typedef __time64_t time_t;
#endif /* _WIN32 */
#ifdef __cplusplus
extern "C" {
@@ -50,17 +52,17 @@ struct timeval
time_t tv_sec; /* seconds */
suseconds_t tv_usec; /* and microseconds */
};
#endif
#endif /* !defined(_TIMEVAL_DEFINED) && !defined(_WIN32) */
#if !(defined(__GNUC__) && !defined(__ARMCC_VERSION)/*GCC*/) && \
!(defined(__ICCARM__) && (__VER__ >= 8010001)) && \
!defined(_WIN32)
#if defined(__ARMCC_VERSION) || defined(_WIN32) || (defined(__ICCARM__) && (__VER__ >= 8010001))
struct timespec
{
time_t tv_sec; /* seconds */
long tv_nsec; /* and nanoseconds */
};
#endif /* defined(__ARMCC_VERSION) || defined(_WIN32) || (defined(__ICCARM__) && (__VER__ >= 8010001)) */
#if !(defined(__GNUC__) && !defined(__ARMCC_VERSION)/*GCC*/)
/*
* Structure defined by POSIX.1b to be like a itimerval, but with
* timespecs. Used in the timer_*() system calls.
@@ -70,7 +72,7 @@ struct itimerspec
struct timespec it_interval;
struct timespec it_value;
};
#endif
#endif /* !(defined(__GNUC__) && !defined(__ARMCC_VERSION)) */
int stime(const time_t *t);
time_t timegm(struct tm * const t);