提交 29b73ecb 编写于 作者: mysterywolf's avatar mysterywolf 提交者: Bernard Xiong

[newlib] 处理newlib版本不一致导致的问题

上级 78fa23be
......@@ -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)];
......
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')
from shutil import copy
from building import *
from gcc import *
Import('rtconfig')
src = []
......@@ -8,10 +8,10 @@ cwd = GetCurrentDir()
CPPPATH = [cwd]
group = []
if rtconfig.PLATFORM == 'gcc' and ('mips' in rtconfig.PREFIX): # identify mips gcc tool chain
# 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:
# 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")
copy("../../../../common/nogcc/sys/select.h", "./sys/select.h") # copy from 'nogcc/sys/select.h'
except:
pass
......
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.
......@@ -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__ */
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
This folder is for some particular targets.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册