1 /*
2 * Copyright (C) 2015-2017 Alibaba Group Holding Limited
3 */
4
5 #include <aos/kernel.h>
6 #include <sys/select.h>
7 //#include "lwip/opt.h"
8 //#include "lwip/sockets.h"
9
select2(int maxfdp1,fd_set * readset,fd_set * writeset,fd_set * exceptset,struct timeval * timeout,void * semaphore)10 __attribute__((weak)) int select2(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
11 struct timeval *timeout, void *semaphore)
12 {
13 uint32_t tomeout_ms;
14
15 if (timeout) {
16 tomeout_ms = timeout->tv_sec * 1000 + timeout->tv_usec / 1000;
17 } else {
18 tomeout_ms = AOS_WAIT_FOREVER;
19 }
20
21 if (semaphore && aos_sem_is_valid(semaphore)) {
22 aos_sem_wait(semaphore, tomeout_ms);
23 } else {
24 aos_msleep(tomeout_ms);
25 }
26
27 return 0;
28 }
29
30
31 /* dummy select, fix compile error with no net evn */
select(int maxfdp1,fd_set * readset,fd_set * writeset,fd_set * exceptset,struct timeval * timeout)32 __attribute__((weak)) int select(int maxfdp1, fd_set *readset, fd_set *writeset, fd_set *exceptset,
33 struct timeval *timeout)
34 {
35 return select2(maxfdp1, readset, writeset, exceptset, timeout, NULL);
36 }
37