X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=libc%2Fsysdeps%2Flinux%2Fcommon%2Fpoll.c;h=c76df966f502a0342b9450362ea8c657ba8ea038;hb=af0172162f7c653cad6a11ed1c1a5459bc154465;hp=cf3db35eb8387b2823bb2ac9b4b15d666a6f562e;hpb=8e8099dcac7317d161b4341dbac5369164397f82;p=uclinux-h8%2FuClibc.git diff --git a/libc/sysdeps/linux/common/poll.c b/libc/sysdeps/linux/common/poll.c index cf3db35eb..c76df966f 100644 --- a/libc/sysdeps/linux/common/poll.c +++ b/libc/sysdeps/linux/common/poll.c @@ -17,8 +17,15 @@ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include +#include "syscalls.h" #include + +#ifdef __NR_poll +_syscall3(int, poll, struct pollfd *, fds, + unsigned long int, nfds, int, timeout); +#else + +#include #include #include #include @@ -26,6 +33,13 @@ #include #include +libc_hidden_proto(memcpy) +libc_hidden_proto(memset) +libc_hidden_proto(getdtablesize) +libc_hidden_proto(select) + +/* uClinux 2.0 doesn't have poll, emulate it using select */ + /* Poll the file descriptors described by the NFDS structures starting at FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for an event to occur; if TIMEOUT is -1, block until an event occurs. @@ -52,9 +66,9 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout) /* We can't call FD_ZERO, since FD_ZERO only works with sets of exactly __FD_SETSIZE size. */ - bzero (rset, bytes); - bzero (wset, bytes); - bzero (xset, bytes); + memset (rset, 0, bytes); + memset (wset, 0, bytes); + memset (xset, 0, bytes); for (f = fds; f < &fds[nfds]; ++f) { @@ -76,9 +90,9 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout) nwset = alloca (nbytes); nxset = alloca (nbytes); - bzero ((char *) nrset + bytes, nbytes - bytes); - bzero ((char *) nwset + bytes, nbytes - bytes); - bzero ((char *) nxset + bytes, nbytes - bytes); + memset ((char *) nrset + bytes, 0, nbytes - bytes); + memset ((char *) nwset + bytes, 0, nbytes - bytes); + memset ((char *) nxset + bytes, 0, nbytes - bytes); rset = memcpy (nrset, rset, bytes); wset = memcpy (nwset, wset, bytes); @@ -116,9 +130,9 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout) struct timeval sngl_tv; /* Clear the original set. */ - bzero (rset, bytes); - bzero (wset, bytes); - bzero (xset, bytes); + memset (rset, 0, bytes); + memset (wset, 0, bytes); + memset (xset, 0, bytes); /* This means we don't wait for input. */ sngl_tv.tv_sec = 0; @@ -135,9 +149,9 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout) { int n; - bzero (sngl_rset, bytes); - bzero (sngl_wset, bytes); - bzero (sngl_xset, bytes); + memset (sngl_rset, 0, bytes); + memset (sngl_wset, 0, bytes); + memset (sngl_xset, 0, bytes); if (f->events & POLLIN) FD_SET (f->fd, sngl_rset); @@ -190,3 +204,6 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout) return ready; } +#endif +libc_hidden_proto(poll) +libc_hidden_def(poll)