summaryrefslogtreecommitdiffstats
path: root/libc/sysdeps/linux/common/poll.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/sysdeps/linux/common/poll.c')
-rw-r--r--libc/sysdeps/linux/common/poll.c66
1 files changed, 44 insertions, 22 deletions
diff --git a/libc/sysdeps/linux/common/poll.c b/libc/sysdeps/linux/common/poll.c
index c957f1edf..61c6d18ea 100644
--- a/libc/sysdeps/linux/common/poll.c
+++ b/libc/sysdeps/linux/common/poll.c
@@ -17,16 +17,33 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
-#define getdtablesize __getdtablesize
-#define select __select
-
#include "syscalls.h"
#include <sys/poll.h>
+libc_hidden_proto(poll)
+
#ifdef __NR_poll
-#define __NR___poll __NR_poll
-attribute_hidden _syscall3(int, __poll, struct pollfd *, fds,
+# ifdef __UCLIBC__HAS_THREADS__
+# include <sysdep-cancel.h>
+
+/* The real implementation. */
+int poll (struct pollfd *fds, nfsd_t nfds, int timeout)
+{
+ if (SINGLE_THREAD_P)
+ return INLINE_SYSCALL (poll, 3, fds, nfds, timeout);
+
+ int oldtype = LIBC_CANCEL_ASYNC ();
+
+ int result = INLINE_SYSCALL (poll, 3, fds, nfds, timeout);
+
+ LIBC_CANCEL_RESET (oldtype);
+
+ return result;
+}
+# else
+_syscall3(int, poll, struct pollfd *, fds,
unsigned long int, nfds, int, timeout);
+# endif
#else
#include <alloca.h>
@@ -37,6 +54,11 @@ attribute_hidden _syscall3(int, __poll, struct pollfd *, fds,
#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
@@ -45,7 +67,7 @@ attribute_hidden _syscall3(int, __poll, struct pollfd *, fds,
Returns the number of file descriptors with events, zero if timed out,
or -1 for errors. */
-int attribute_hidden __poll(struct pollfd *fds, nfds_t nfds, int timeout)
+int poll(struct pollfd *fds, nfds_t nfds, int timeout)
{
static int max_fd_size;
struct timeval tv;
@@ -65,9 +87,9 @@ int attribute_hidden __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. */
- __memset (rset, 0, bytes);
- __memset (wset, 0, bytes);
- __memset (xset, 0, bytes);
+ memset (rset, 0, bytes);
+ memset (wset, 0, bytes);
+ memset (xset, 0, bytes);
for (f = fds; f < &fds[nfds]; ++f)
{
@@ -89,13 +111,13 @@ int attribute_hidden __poll(struct pollfd *fds, nfds_t nfds, int timeout)
nwset = alloca (nbytes);
nxset = alloca (nbytes);
- __memset ((char *) nrset + bytes, 0, nbytes - bytes);
- __memset ((char *) nwset + bytes, 0, nbytes - bytes);
- __memset ((char *) nxset + bytes, 0, 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);
- xset = __memcpy (nxset, xset, bytes);
+ rset = memcpy (nrset, rset, bytes);
+ wset = memcpy (nwset, wset, bytes);
+ xset = memcpy (nxset, xset, bytes);
bytes = nbytes;
}
@@ -129,9 +151,9 @@ int attribute_hidden __poll(struct pollfd *fds, nfds_t nfds, int timeout)
struct timeval sngl_tv;
/* Clear the original set. */
- __memset (rset, 0, bytes);
- __memset (wset, 0, bytes);
- __memset (xset, 0, 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;
@@ -148,9 +170,9 @@ int attribute_hidden __poll(struct pollfd *fds, nfds_t nfds, int timeout)
{
int n;
- __memset (sngl_rset, 0, bytes);
- __memset (sngl_wset, 0, bytes);
- __memset (sngl_xset, 0, 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);
@@ -204,4 +226,4 @@ int attribute_hidden __poll(struct pollfd *fds, nfds_t nfds, int timeout)
}
#endif
-strong_alias(__poll,poll)
+libc_hidden_def(poll)