summaryrefslogtreecommitdiff
path: root/LibC
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-01-23 07:27:41 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-01-23 07:28:25 +0100
commit2bedabbd6cec0fcd323a665992a91d340291fdd5 (patch)
tree0554208f21628cc080451b7cd449fa8c2a21b6df /LibC
parent8bb18fdc565f4fe133f80e64101fb0d663e27bf2 (diff)
downloadserenity-2bedabbd6cec0fcd323a665992a91d340291fdd5.zip
Stub out poll() syscall and LibC wrapper.
Diffstat (limited to 'LibC')
-rw-r--r--LibC/Makefile1
-rw-r--r--LibC/poll.cpp14
-rw-r--r--LibC/poll.h23
3 files changed, 38 insertions, 0 deletions
diff --git a/LibC/Makefile b/LibC/Makefile
index 5a471c7c3b..90dbd15ed5 100644
--- a/LibC/Makefile
+++ b/LibC/Makefile
@@ -43,6 +43,7 @@ LIBC_OBJS = \
utime.o \
gui.o \
sys/select.o \
+ poll.o \
entry.o
OBJS = $(AK_OBJS) $(WIDGETS_OBJS) $(LIBC_OBJS) $(SHAREDGRAPHICS_OBJS)
diff --git a/LibC/poll.cpp b/LibC/poll.cpp
new file mode 100644
index 0000000000..2e3f939a80
--- /dev/null
+++ b/LibC/poll.cpp
@@ -0,0 +1,14 @@
+#include <poll.h>
+#include <Kernel/Syscall.h>
+#include <errno.h>
+
+extern "C" {
+
+int poll(struct pollfd* fds, int nfds, int timeout)
+{
+ int rc = syscall(SC_poll, fds, nfds, timeout);
+ __RETURN_WITH_ERRNO(rc, rc, -1);
+}
+
+}
+
diff --git a/LibC/poll.h b/LibC/poll.h
new file mode 100644
index 0000000000..1a52049c82
--- /dev/null
+++ b/LibC/poll.h
@@ -0,0 +1,23 @@
+#pragma once
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+
+#define POLLIN (1u << 0)
+#define POLLPRI (1u << 2)
+#define POLLOUT (1u << 3)
+#define POLLERR (1u << 4)
+#define POLLHUP (1u << 5)
+#define POLLNVAL (1u << 6)
+
+struct pollfd {
+ int fd;
+ short events;
+ short revents;
+};
+
+int poll(struct pollfd* fds, int nfds, int timeout);
+
+__END_DECLS
+