From a11d85bf52f72802804ecf15719153df30d7cb8b Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 5 Apr 2022 01:46:40 -0400 Subject: [PATCH 1/8] =?UTF-8?q?[libc]=20=E8=A7=A3=E5=86=B3=E7=94=B1?= =?UTF-8?q?=E4=BA=8E=E5=8E=86=E5=8F=B2=E5=8E=9F=E5=9B=A0fcntl.h=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E7=9A=84=E5=80=BC=E5=9C=A8=E4=B8=8D=E5=90=8C=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E5=99=A8=E4=B8=AD=E5=AE=9A=E4=B9=89=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../libc/compilers/common/extension/SConscript | 11 +++++++++-- .../compilers/common/extension/fcntl/README.md | 4 ++++ .../compilers/common/extension/fcntl/SConscript | 15 +++++++++++++++ .../common/extension/fcntl/octal/SConscript | 14 ++++++++++++++ .../common/extension/{ => fcntl/octal}/fcntl.h | 0 5 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 components/libc/compilers/common/extension/fcntl/README.md create mode 100644 components/libc/compilers/common/extension/fcntl/SConscript create mode 100644 components/libc/compilers/common/extension/fcntl/octal/SConscript rename components/libc/compilers/common/extension/{ => fcntl/octal}/fcntl.h (100%) diff --git a/components/libc/compilers/common/extension/SConscript b/components/libc/compilers/common/extension/SConscript index dbc26ac1774..ddd83c82345 100644 --- a/components/libc/compilers/common/extension/SConscript +++ b/components/libc/compilers/common/extension/SConscript @@ -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') diff --git a/components/libc/compilers/common/extension/fcntl/README.md b/components/libc/compilers/common/extension/fcntl/README.md new file mode 100644 index 00000000000..6de3b6d7607 --- /dev/null +++ b/components/libc/compilers/common/extension/fcntl/README.md @@ -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. + +For RT-Thread, Keil and IAR use octal flags, which is located in the `tcntl/octal` folder; newlib uses hex flags; musl uses octal flags; MSVC uses hex flags but not the standard hex flags (be different from newlib hex flags). + diff --git a/components/libc/compilers/common/extension/fcntl/SConscript b/components/libc/compilers/common/extension/fcntl/SConscript new file mode 100644 index 00000000000..4c815c49b83 --- /dev/null +++ b/components/libc/compilers/common/extension/fcntl/SConscript @@ -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') diff --git a/components/libc/compilers/common/extension/fcntl/octal/SConscript b/components/libc/compilers/common/extension/fcntl/octal/SConscript new file mode 100644 index 00000000000..de5674d67d0 --- /dev/null +++ b/components/libc/compilers/common/extension/fcntl/octal/SConscript @@ -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.PLATFORM == 'cl': # msvc + group = DefineGroup('Compiler', src, depend = [''], CPPPATH = CPPPATH) +Return('group') diff --git a/components/libc/compilers/common/extension/fcntl.h b/components/libc/compilers/common/extension/fcntl/octal/fcntl.h similarity index 100% rename from components/libc/compilers/common/extension/fcntl.h rename to components/libc/compilers/common/extension/fcntl/octal/fcntl.h From 23a1a1cb6de642374425f0ce3f29eef8e5da4988 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 5 Apr 2022 03:02:32 -0400 Subject: [PATCH 2/8] =?UTF-8?q?[simulator]=20=E9=83=A8=E5=88=86=E5=AE=8F?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E8=BD=AC=E4=B8=BA=E5=85=A8=E5=B1=80=E5=AE=8F?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E4=BB=A5=E7=A1=AE=E4=BF=9Dvs=E5=86=85?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E5=8F=AF=E4=BB=A5=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/simulator/drivers/SConscript | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/bsp/simulator/drivers/SConscript b/bsp/simulator/drivers/SConscript index 8f0c9275ff2..fe5e9aa108f 100644 --- a/bsp/simulator/drivers/SConscript +++ b/bsp/simulator/drivers/SConscript @@ -8,6 +8,20 @@ LIBS = [] LIBPATH = [] CPPPATH = [cwd] +CPPDEFINES = \ +[ +# avoid to conflict with the inherent STDC in VS +'_CRT_DECLARE_NONSTDC_NAMES=0', +# errno macro redefinition +'_CRT_ERRNO_DEFINED', +# disable deprecation of unsafe functions, such as strncpy +'_CRT_SECURE_NO_WARNINGS', +# RT_VESRION in winuser.h +'NORESOURCE', +# dfs_elm.c time.h conflicts with wtime.inl +'_INC_WTIME_INL', '_INC_TIME_INL', +] + # remove no need file. if GetDepend('PKG_USING_GUIENGINE') == False: SrcRemove(src, 'sdl_fb.c') @@ -30,7 +44,8 @@ if GetDepend('RT_USING_DFS') == False or GetDepend('RT_USING_MODULE') == False: if sys.platform[0:5]=="linux": #check whether under linux SrcRemove(src, ['module_win32.c', 'dfs_win32.c']) -group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH, LIBS=LIBS, LIBPATH=LIBPATH) +group = DefineGroup('Drivers', src, depend = [''], + CPPPATH = CPPPATH, LIBS=LIBS, LIBPATH=LIBPATH, CPPDEFINES=CPPDEFINES) list = os.listdir(cwd) for item in list: From 84cdbabc2a36c9ca30330bfdf279f4feec8918a7 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 5 Apr 2022 03:04:49 -0400 Subject: [PATCH 3/8] =?UTF-8?q?[simulator]=20=E5=8F=96=E6=B6=88=E8=87=AA?= =?UTF-8?q?=E6=AC=BA=E6=AC=BA=E4=BA=BA=E5=BC=8F=E7=9A=84=E8=AD=A6=E5=91=8A?= =?UTF-8?q?=E6=B6=88=E9=99=A4=E5=A4=84=E7=90=86=E6=96=B9=E5=BC=8F=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/simulator/rtconfig_project.h | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/bsp/simulator/rtconfig_project.h b/bsp/simulator/rtconfig_project.h index 12892e9a987..0dc3bed0eeb 100644 --- a/bsp/simulator/rtconfig_project.h +++ b/bsp/simulator/rtconfig_project.h @@ -12,21 +12,9 @@ #define RT_HEAP_SIZE (1024*1024*8) -#if defined(_MSC_VER) -#define NORESOURCE /* RT_VESRION in winuser.h */ -#define _CRT_ERRNO_DEFINED /* errno macro redefinition */ -#define _INC_WTIME_INL /* dfs_elm.c time.h conflicts with wtime.inl */ -#define _INC_TIME_INL /* dfs_elm.c time.h conflicts with wtime.inl */ -#define _CRT_DECLARE_NONSTDC_NAMES 0 /* avoid to conflict with the inherent STDC in VS */ - +#ifdef _MSC_VER /* disable some warning in MSC */ -#pragma warning(disable:4273) /* to ignore: warning C4273: inconsistent dll linkage */ -#pragma warning(disable:4312) /* to ignore: warning C4312: 'type cast' : conversion from 'rt_uint32_t' to 'rt_uint32_t *' */ -#pragma warning(disable:4311) /* to ignore: warning C4311: 'type cast' : pointer truncation from 'short *__w64 ' to 'long' */ -#pragma warning(disable:4996) /* to ignore: warning C4996: The POSIX name for this item is deprecated. */ -#pragma warning(disable:4267) /* to ignore: warning C4267: conversion from 'size_t' to 'rt_size_t', possible loss of data */ -#pragma warning(disable:4244) /* to ignore: warning C4244: '=' : conversion from '__w64 int' to 'rt_size_t', possible loss of data */ - -#endif /* end of _MSC_VER */ +// #pragma warning(disable:4273) /* to ignore: warning C4273: inconsistent dll linkage */ +#endif /* _MSC_VER */ -#endif +#endif /* RTCONFIG_PROJECT_H__ */ From b219b1bdd3a9a30f7662f44c2d0bc610c1acbc8c Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 5 Apr 2022 03:13:16 -0400 Subject: [PATCH 4/8] update readme --- components/libc/compilers/common/extension/fcntl/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/libc/compilers/common/extension/fcntl/README.md b/components/libc/compilers/common/extension/fcntl/README.md index 6de3b6d7607..8866eace7c6 100644 --- a/components/libc/compilers/common/extension/fcntl/README.md +++ b/components/libc/compilers/common/extension/fcntl/README.md @@ -1,4 +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. -For RT-Thread, Keil and IAR use octal flags, which is located in the `tcntl/octal` folder; newlib uses hex flags; musl uses octal flags; MSVC uses hex flags but not the standard hex flags (be different from newlib hex 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. From a9b085d871bb78e7adda892506aac6f2e43d8d89 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 5 Apr 2022 03:36:21 -0400 Subject: [PATCH 5/8] update sconscript --- bsp/simulator/drivers/SConscript | 29 ++++++++++--------- .../common/extension/fcntl/octal/SConscript | 2 +- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/bsp/simulator/drivers/SConscript b/bsp/simulator/drivers/SConscript index fe5e9aa108f..7abb91fcf5a 100644 --- a/bsp/simulator/drivers/SConscript +++ b/bsp/simulator/drivers/SConscript @@ -1,26 +1,29 @@ import sys import os from building import * +Import('rtconfig') cwd = GetCurrentDir() src = Glob('*.c') LIBS = [] LIBPATH = [] CPPPATH = [cwd] +CPPDEFINES = [] -CPPDEFINES = \ -[ -# avoid to conflict with the inherent STDC in VS -'_CRT_DECLARE_NONSTDC_NAMES=0', -# errno macro redefinition -'_CRT_ERRNO_DEFINED', -# disable deprecation of unsafe functions, such as strncpy -'_CRT_SECURE_NO_WARNINGS', -# RT_VESRION in winuser.h -'NORESOURCE', -# dfs_elm.c time.h conflicts with wtime.inl -'_INC_WTIME_INL', '_INC_TIME_INL', -] +if rtconfig.CROSS_TOOL == 'msvc': + CPPDEFINES += \ + [ + # avoid to conflict with the inherent STDC in VS + '_CRT_DECLARE_NONSTDC_NAMES=0', + # errno macro redefinition + '_CRT_ERRNO_DEFINED', + # disable deprecation of unsafe functions, such as strncpy + '_CRT_SECURE_NO_WARNINGS', + # RT_VESRION in winuser.h + 'NORESOURCE', + # dfs_elm.c time.h conflicts with wtime.inl + '_INC_WTIME_INL', '_INC_TIME_INL', + ] # remove no need file. if GetDepend('PKG_USING_GUIENGINE') == False: diff --git a/components/libc/compilers/common/extension/fcntl/octal/SConscript b/components/libc/compilers/common/extension/fcntl/octal/SConscript index de5674d67d0..22d72dff057 100644 --- a/components/libc/compilers/common/extension/fcntl/octal/SConscript +++ b/components/libc/compilers/common/extension/fcntl/octal/SConscript @@ -9,6 +9,6 @@ group = [] if rtconfig.PLATFORM == 'armcc' or\ rtconfig.PLATFORM == 'armclang' or\ rtconfig.PLATFORM == 'iar' or\ - rtconfig.PLATFORM == 'cl': # msvc + rtconfig.CROSS_TOOL == 'msvc': group = DefineGroup('Compiler', src, depend = [''], CPPPATH = CPPPATH) Return('group') From e985eadfc80eb08eb9fbe7c1be2daf63754c1f7a Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Tue, 5 Apr 2022 13:18:19 -0400 Subject: [PATCH 6/8] =?UTF-8?q?[libc][time]=20=E4=BC=98=E5=8C=96time?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E7=BB=93=E6=9E=84=E4=BD=93=E5=9C=A8=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E7=BC=96=E8=AF=91=E5=99=A8=E4=B8=8B=E7=9A=84=E5=8C=85?= =?UTF-8?q?=E5=90=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bsp/simulator/drivers/SConscript | 6 +++--- components/libc/compilers/common/sys/time.h | 14 ++++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bsp/simulator/drivers/SConscript b/bsp/simulator/drivers/SConscript index 7abb91fcf5a..731b577fd30 100644 --- a/bsp/simulator/drivers/SConscript +++ b/bsp/simulator/drivers/SConscript @@ -17,12 +17,12 @@ if rtconfig.CROSS_TOOL == 'msvc': '_CRT_DECLARE_NONSTDC_NAMES=0', # errno macro redefinition '_CRT_ERRNO_DEFINED', + # time.h conflicts + '_CRT_NO_TIME_T', # disable deprecation of unsafe functions, such as strncpy '_CRT_SECURE_NO_WARNINGS', - # RT_VESRION in winuser.h + # RT_VESRION conflicts in winuser.h 'NORESOURCE', - # dfs_elm.c time.h conflicts with wtime.inl - '_INC_WTIME_INL', '_INC_TIME_INL', ] # remove no need file. diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h index a3af31b20b3..9d0807aaca9 100644 --- a/components/libc/compilers/common/sys/time.h +++ b/components/libc/compilers/common/sys/time.h @@ -18,7 +18,9 @@ #include #ifdef _WIN32 #include /* for struct timeval */ -#endif +#include /* 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) struct timespec { time_t tv_sec; /* seconds */ long tv_nsec; /* and nanoseconds */ }; +#endif /* defined(__ARMCC_VERSION) || defined(_WIN32) */ +#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); From ff8cda98cdd86cd91c07d534db3d2d5298a1db07 Mon Sep 17 00:00:00 2001 From: "Man, Jianting (Meco)" <920369182@qq.com> Date: Tue, 5 Apr 2022 22:23:38 -0400 Subject: [PATCH 7/8] Update time.h --- components/libc/compilers/common/sys/time.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h index 9d0807aaca9..526c6d4e5d2 100644 --- a/components/libc/compilers/common/sys/time.h +++ b/components/libc/compilers/common/sys/time.h @@ -54,7 +54,7 @@ struct timeval }; #endif /* !defined(_TIMEVAL_DEFINED) && !defined(_WIN32) */ -#if defined(__ARMCC_VERSION) || defined(_WIN32) +#if defined(__ARMCC_VERSION) || defined(_WIN32) || (defined(__ICCARM__) && (__VER__ >= 8010001)) struct timespec { time_t tv_sec; /* seconds */ From f929c1ba29f7eabd2c726add207ee3d8644a62c1 Mon Sep 17 00:00:00 2001 From: "Man, Jianting (Meco)" <920369182@qq.com> Date: Tue, 5 Apr 2022 22:55:39 -0400 Subject: [PATCH 8/8] Update time.h --- components/libc/compilers/common/sys/time.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/libc/compilers/common/sys/time.h b/components/libc/compilers/common/sys/time.h index 526c6d4e5d2..3fe6ae4a264 100644 --- a/components/libc/compilers/common/sys/time.h +++ b/components/libc/compilers/common/sys/time.h @@ -60,7 +60,7 @@ struct timespec time_t tv_sec; /* seconds */ long tv_nsec; /* and nanoseconds */ }; -#endif /* defined(__ARMCC_VERSION) || defined(_WIN32) */ +#endif /* defined(__ARMCC_VERSION) || defined(_WIN32) || (defined(__ICCARM__) && (__VER__ >= 8010001)) */ #if !(defined(__GNUC__) && !defined(__ARMCC_VERSION)/*GCC*/) /*