summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2021-12-22 19:21:52 -0500
committerBernard Xiong <[email protected]>2021-12-29 12:10:02 +0800
commit29b73ecb6f75c53d36a7e03dde7bdafd464b08d9 (patch)
tree0b9bc6e89daf6213559ee38de1287eccbf96180e
parent78fa23bebe7c9a1ce1bccf417130affabf2310e8 (diff)
[newlib] 处理newlib版本不一致导致的问题
-rw-r--r--components/libc/compilers/common/nogcc/sys/select.h6
-rw-r--r--components/libc/compilers/gcc/newlib/SConscript12
-rw-r--r--components/libc/compilers/gcc/newlib/legacy/SConscript (renamed from components/libc/compilers/gcc/partial/SConscript)0
-rw-r--r--components/libc/compilers/gcc/newlib/legacy/_select/SConscript20
-rw-r--r--components/libc/compilers/gcc/newlib/legacy/_select/readme.md2
-rw-r--r--components/libc/compilers/gcc/newlib/legacy/_select/sys/select.h (renamed from components/libc/compilers/gcc/partial/mips/sys/select.h)12
-rw-r--r--components/libc/compilers/gcc/partial/mips/SConscript20
-rw-r--r--components/libc/compilers/gcc/partial/mips/readme.md4
-rw-r--r--components/libc/compilers/gcc/partial/readme.md2
9 files changed, 46 insertions, 32 deletions
diff --git a/components/libc/compilers/common/nogcc/sys/select.h b/components/libc/compilers/common/nogcc/sys/select.h
index 02fb77dd89..44f9b4ed91 100644
--- a/components/libc/compilers/common/nogcc/sys/select.h
+++ b/components/libc/compilers/common/nogcc/sys/select.h
@@ -6,6 +6,7 @@
* Change Logs:
* Date Author Notes
* 2021-07-21 Meco Man The first version
+ * 2021-12-25 Meco Man Handle newlib 2.2.0 or lower version
*/
#ifndef __SYS_SELECT_H__
@@ -33,13 +34,12 @@
typedef long fd_mask;
#ifndef _WIN32
-#ifndef _SYS_TYPES_FD_SET /* MIPS */
-
+#ifndef _SYS_TYPES_FD_SET /* Newlib 2.2.0 or lower version */
#define NBBY 8 /* number of bits in a byte */
#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
#ifndef howmany
#define howmany(x,y) (((x)+((y)-1))/(y))
-#endif
+#endif /* howmany */
typedef struct _types_fd_set {
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
diff --git a/components/libc/compilers/gcc/newlib/SConscript b/components/libc/compilers/gcc/newlib/SConscript
index 58672a0255..d51bbdad84 100644
--- a/components/libc/compilers/gcc/newlib/SConscript
+++ b/components/libc/compilers/gcc/newlib/SConscript
@@ -1,4 +1,6 @@
+import os
from building import *
+from gcc import *
Import('rtconfig')
src = []
@@ -14,9 +16,19 @@ if rtconfig.PLATFORM == 'gcc':
else:
src += ['syscalls.c']
+ #report newlib version
+ print('Newlib version:' + GetNewLibVersion(rtconfig))
+
# identify this is Newlib, and only enable POSIX.1-1990
CPPDEFINES = ['RT_USING_NEWLIB', '_POSIX_C_SOURCE=1']
group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
+
+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/gcc/partial/SConscript b/components/libc/compilers/gcc/newlib/legacy/SConscript
index 4c815c49b8..4c815c49b8 100644
--- a/components/libc/compilers/gcc/partial/SConscript
+++ b/components/libc/compilers/gcc/newlib/legacy/SConscript
diff --git a/components/libc/compilers/gcc/newlib/legacy/_select/SConscript b/components/libc/compilers/gcc/newlib/legacy/_select/SConscript
new file mode 100644
index 0000000000..1c6a22b869
--- /dev/null
+++ b/components/libc/compilers/gcc/newlib/legacy/_select/SConscript
@@ -0,0 +1,20 @@
+from shutil import copy
+from building import *
+from gcc import *
+Import('rtconfig')
+
+src = []
+cwd = GetCurrentDir()
+CPPPATH = [cwd]
+group = []
+
+# sys/select.h does not exist in newlib 2.1.0 or lower version
+if rtconfig.PLATFORM == 'gcc' and (CheckHeader(rtconfig, 'sys/select.h') == False):
+ try:
+ copy("../../../../common/nogcc/sys/select.h", "./sys/select.h") # copy from 'nogcc/sys/select.h'
+ except:
+ pass
+
+ group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH)
+
+Return('group')
diff --git a/components/libc/compilers/gcc/newlib/legacy/_select/readme.md b/components/libc/compilers/gcc/newlib/legacy/_select/readme.md
new file mode 100644
index 0000000000..4ad9f21923
--- /dev/null
+++ b/components/libc/compilers/gcc/newlib/legacy/_select/readme.md
@@ -0,0 +1,2 @@
+Newlib 2.2.0 or lower version does not provide `sys/select.h`, and `fd_set` is defined in `sys/types.h`. It will be generated by scons automatically, and **DO NOT** change it.
+
diff --git a/components/libc/compilers/gcc/partial/mips/sys/select.h b/components/libc/compilers/gcc/newlib/legacy/_select/sys/select.h
index 575ad3a1b5..02fb77dd89 100644
--- a/components/libc/compilers/gcc/partial/mips/sys/select.h
+++ b/components/libc/compilers/gcc/newlib/legacy/_select/sys/select.h
@@ -15,6 +15,10 @@
#include <sys/types.h>
#include <sys/time.h>
+#ifdef _WIN32
+#include <winsock.h>
+#endif
+
#ifndef FD_SETSIZE
#define FD_SETSIZE 32
#endif
@@ -26,16 +30,17 @@
#define FD_SETSIZE DFS_FD_MAX
#endif /* SAL_USING_POSIX */
-#define NBBY 8 /* number of bits in a byte */
-
typedef long fd_mask;
+#ifndef _WIN32
+#ifndef _SYS_TYPES_FD_SET /* MIPS */
+
+#define NBBY 8 /* number of bits in a byte */
#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
#ifndef howmany
#define howmany(x,y) (((x)+((y)-1))/(y))
#endif
-#ifndef _SYS_TYPES_FD_SET /* MIPS */
typedef struct _types_fd_set {
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
} _types_fd_set;
@@ -48,5 +53,6 @@ typedef struct _types_fd_set {
#endif /* _SYS_TYPES_FD_SET */
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
+#endif /* _WIN32 */
#endif /* __SYS_SELECT_H__ */
diff --git a/components/libc/compilers/gcc/partial/mips/SConscript b/components/libc/compilers/gcc/partial/mips/SConscript
deleted file mode 100644
index 7651233d46..0000000000
--- a/components/libc/compilers/gcc/partial/mips/SConscript
+++ /dev/null
@@ -1,20 +0,0 @@
-from shutil import copy
-from building import *
-
-Import('rtconfig')
-
-src = []
-cwd = GetCurrentDir()
-CPPPATH = [cwd]
-group = []
-
-if rtconfig.PLATFORM == 'gcc' and ('mips' in rtconfig.PREFIX): # identify mips gcc tool chain
- try:
- # There is no 'sys/select.h' in tthe mips gcc toolchain; it will be copied from 'nogcc/sys/select.h'
- copy("../../../common/nogcc/sys/select.h", "./sys/select.h")
- except:
- pass
-
- group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH)
-
-Return('group')
diff --git a/components/libc/compilers/gcc/partial/mips/readme.md b/components/libc/compilers/gcc/partial/mips/readme.md
deleted file mode 100644
index a3eeb06c5d..0000000000
--- a/components/libc/compilers/gcc/partial/mips/readme.md
+++ /dev/null
@@ -1,4 +0,0 @@
-These files don't exist in the mips gcc toolchain. They will be generated by scons automatically , and **DO NOT** change them:
-
-- sys/select.h
-
diff --git a/components/libc/compilers/gcc/partial/readme.md b/components/libc/compilers/gcc/partial/readme.md
deleted file mode 100644
index 959fc29f35..0000000000
--- a/components/libc/compilers/gcc/partial/readme.md
+++ /dev/null
@@ -1,2 +0,0 @@
-This folder is for some particular targets.
-