[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT/LWIP PATCH] sockets.c: Add ppoll() function



This ppoll() implementation is adapted from its man page.

Signed-off-by: Costin Lupu <costin.lupu@xxxxxxxxx>
---
 Config.uk |  6 ++++++
 sockets.c | 26 ++++++++++++++++++++++++++
 2 files changed, 32 insertions(+)

diff --git a/Config.uk b/Config.uk
index 8f501fc..debf0c7 100644
--- a/Config.uk
+++ b/Config.uk
@@ -170,6 +170,12 @@ if LWIP_SOCKET
                        lwip's select() implementation supports only sockets. 
This
                        configuration option makes it possible to use other 
file descriptor
                        types as well, even though they are not supported by 
lwip.
+
+       config LWIP_SOCKET_PPOLL
+               bool "Enable ppoll()"
+               default y
+               help
+                       Enable ppoll() implementation.
 endif
 
 menuconfig LWIP_DEBUG
diff --git a/sockets.c b/sockets.c
index c2cf57f..5b499af 100644
--- a/sockets.c
+++ b/sockets.c
@@ -34,7 +34,11 @@
  */
 
 /* network stub calls */
+#include <uk/config.h>
 #include <sys/time.h>
+#if CONFIG_LWIP_SOCKET_PPOLL
+#include <signal.h>
+#endif
 #include <vfscore/dentry.h>
 #include <vfscore/file.h>
 #include <vfscore/fs.h>
@@ -473,6 +477,28 @@ EXIT:
        return ret;
 }
 
+#if CONFIG_LWIP_SOCKET_PPOLL
+#if CONFIG_LIBPTHREAD_EMBEDDED
+#define __sigmask   pthread_sigmask
+#else
+#define __sigmask   sigprocmask
+#endif
+int ppoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmo_p,
+               const sigset_t *sigmask)
+{
+       sigset_t origmask;
+       int timeout, rc;
+
+       timeout = (tmo_p == NULL) ? -1 :
+               (tmo_p->tv_sec * 1000 + tmo_p->tv_nsec / 1000000);
+       __sigmask(SIG_SETMASK, sigmask, &origmask);
+       rc = poll(fds, nfds, timeout);
+       __sigmask(SIG_SETMASK, &origmask, NULL);
+
+       return rc;
+}
+#endif /* CONFIG_LWIP_SOCKET_PPOLL */
+
 int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds,
                struct timeval *timeout)
 {
-- 
2.20.1


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.