未验证 提交 de6d7eca 编写于 作者: mysterywolf's avatar mysterywolf 提交者: GitHub

[libc] fix the sys/select.h problem (#5790)

上级 03823b50
......@@ -12,7 +12,7 @@
#ifndef __SYS_SELECT_H__
#define __SYS_SELECT_H__
#include <rtconfig.h>
#include <rtthread.h>
#include <sys/types.h>
#include <sys/time.h>
......@@ -53,7 +53,7 @@ typedef struct _types_fd_set {
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
#define FD_ZERO(p) rt_memset((void*)(p), 0, sizeof(*(p)))
#endif /* _SYS_TYPES_FD_SET */
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
......
# 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')
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.2.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('Compiler', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
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.
/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-07-21 Meco Man The first version
*/
#ifndef __SYS_SELECT_H__
#define __SYS_SELECT_H__
#include <rtconfig.h>
#include <sys/types.h>
#include <sys/time.h>
#ifdef _WIN32
#include <winsock.h>
#endif
#ifndef FD_SETSIZE
#define FD_SETSIZE 32
#endif
#ifdef SAL_USING_POSIX
#ifdef FD_SETSIZE
#undef FD_SETSIZE
#endif
#define FD_SETSIZE DFS_FD_MAX
#endif /* SAL_USING_POSIX */
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
typedef struct _types_fd_set {
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
} _types_fd_set;
#define fd_set _types_fd_set
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
#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__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册