Skip to content

Commit 5c058b6

Browse files
committed
[libc] 增加sys/select.h到partical/ls1
1 parent a3dfdad commit 5c058b6

File tree

3 files changed

+68
-7
lines changed

3 files changed

+68
-7
lines changed

components/libc/compilers/common/partial/ls1/SConscript

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ cwd = GetCurrentDir()
88
CPPPATH = [cwd]
99
group = []
1010

11-
# There is no 'sys/select.h' in these bsp's gcc toolchain; thus, we need to copy this file from 'nogcc/sys/select.h'
12-
if GetDepend('SOC_LS1B') or GetDepend('SOC_LS1C300'):
13-
copy("../../nogcc/sys/select.h", "sys/select.h")
14-
if GetDepend('RT_USING_LIBC'):
15-
src += Glob('*.c')
16-
group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH)
11+
if rtconfig.PLATFORM == 'gcc':
12+
if GetDepend('SOC_LS1B') or GetDepend('SOC_LS1C300'):
13+
try:
14+
# There is no 'sys/select.h' in these bsp's gcc toolchain; thus, we need to copy this file from 'nogcc/sys/select.h'
15+
copy("../../nogcc/sys/select.h", "./sys/select.h")
16+
except:
17+
pass
18+
if GetDepend('RT_USING_LIBC'):
19+
src += Glob('*.c')
20+
21+
group = DefineGroup('libc', src, depend = [], CPPPATH = CPPPATH)
1722

1823
Return('group')
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
This folder will be included when compiling the BSPs as follow:
22

33
- ls1bdev
4-
- ls1cdev
4+
- ls1cdev
5+
6+
These files will be generated by scons automatically , and **DO NOT** change them:
7+
8+
- sys/select.h
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2006-2021, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-07-21 Meco Man The first version
9+
*/
10+
11+
#ifndef __SYS_SELECT_H__
12+
#define __SYS_SELECT_H__
13+
14+
#include <rtconfig.h>
15+
#include <sys/types.h>
16+
#include <sys/time.h>
17+
18+
#ifndef FD_SETSIZE
19+
#define FD_SETSIZE 32
20+
#endif
21+
22+
#ifdef SAL_USING_POSIX
23+
#ifdef FD_SETSIZE
24+
#undef FD_SETSIZE
25+
#endif
26+
#define FD_SETSIZE DFS_FD_MAX
27+
#endif /* SAL_USING_POSIX */
28+
29+
#define NBBY 8 /* number of bits in a byte */
30+
31+
typedef long fd_mask;
32+
33+
#define NFDBITS (sizeof (fd_mask) * NBBY) /* bits per mask */
34+
#ifndef howmany
35+
#define howmany(x,y) (((x)+((y)-1))/(y))
36+
#endif
37+
38+
#ifndef _SYS_TYPES_FD_SET /* MIPS */
39+
typedef struct _types_fd_set {
40+
fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
41+
} _types_fd_set;
42+
#define fd_set _types_fd_set
43+
44+
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1L << ((n) % NFDBITS)))
45+
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1L << ((n) % NFDBITS)))
46+
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1L << ((n) % NFDBITS)))
47+
#define FD_ZERO(p) memset((void*)(p), 0, sizeof(*(p)))
48+
#endif /* _SYS_TYPES_FD_SET */
49+
50+
int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout);
51+
52+
#endif /* __SYS_SELECT_H__ */

0 commit comments

Comments
 (0)