OSDN Git Service

hidden_def/hidden_proto: convert all users (I hope) termios split, add some missing...
[uclinux-h8/uClibc.git] / libc / sysdeps / linux / common / poll.c
index cf3db35..c76df96 100644 (file)
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
-#include <alloca.h>
+#include "syscalls.h"
 #include <sys/poll.h>
+
+#ifdef __NR_poll
+_syscall3(int, poll, struct pollfd *, fds,
+       unsigned long int, nfds, int, timeout);
+#else
+
+#include <alloca.h>
 #include <sys/types.h>
 #include <errno.h>
 #include <string.h>
 #include <sys/param.h>
 #include <unistd.h>
 
+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)