summaryrefslogtreecommitdiff
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
parent8bb18fdc565f4fe133f80e64101fb0d663e27bf2 (diff)
downloadserenity-2bedabbd6cec0fcd323a665992a91d340291fdd5.zip
Stub out poll() syscall and LibC wrapper.
-rw-r--r--Kernel/.gitignore1
-rw-r--r--Kernel/Process.cpp7
-rw-r--r--Kernel/Process.h1
-rw-r--r--Kernel/Syscall.cpp2
-rw-r--r--Kernel/Syscall.h1
-rw-r--r--Kernel/UnixTypes.h13
-rwxr-xr-xKernel/sync-local.sh10
-rw-r--r--LibC/Makefile1
-rw-r--r--LibC/poll.cpp14
-rw-r--r--LibC/poll.h23
10 files changed, 63 insertions, 10 deletions
diff --git a/Kernel/.gitignore b/Kernel/.gitignore
index 624d3642e2..8431799f13 100644
--- a/Kernel/.gitignore
+++ b/Kernel/.gitignore
@@ -4,3 +4,4 @@ Boot/boot.bin
kernel
kernel.map
_fs_contents
+sync-local.sh
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 7b15986166..1a9620d782 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -2002,6 +2002,13 @@ int Process::sys$select(const Syscall::SC_select_params* params)
return markedfds;
}
+int Process::sys$poll(pollfd* fds, int nfds, int timeout)
+{
+ if (!validate_read_typed(fds))
+ return -EFAULT;
+ return 0;
+}
+
Inode* Process::cwd_inode()
{
// FIXME: This is retarded factoring.
diff --git a/Kernel/Process.h b/Kernel/Process.h
index b37fa4562c..0a33d52996 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -157,6 +157,7 @@ public:
int sys$munmap(void*, size_t size);
int sys$set_mmap_name(void*, size_t, const char*);
int sys$select(const Syscall::SC_select_params*);
+ int sys$poll(pollfd*, int nfds, int timeout);
ssize_t sys$get_dir_entries(int fd, void*, size_t);
int sys$getcwd(char*, size_t);
int sys$chdir(const char*);
diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp
index 57b98a535d..ee1bc07fb5 100644
--- a/Kernel/Syscall.cpp
+++ b/Kernel/Syscall.cpp
@@ -100,6 +100,8 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
return (dword)current->sys$mmap((const SC_mmap_params*)arg1);
case Syscall::SC_select:
return current->sys$select((const SC_select_params*)arg1);
+ case Syscall::SC_poll:
+ return current->sys$poll((pollfd*)arg1, (int)arg2, (int)arg3);
case Syscall::SC_munmap:
return current->sys$munmap((void*)arg1, (size_t)arg2);
case Syscall::SC_gethostname:
diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h
index 36c347c750..bfe7c660ec 100644
--- a/Kernel/Syscall.h
+++ b/Kernel/Syscall.h
@@ -75,6 +75,7 @@
__ENUMERATE_SYSCALL(gui_get_window_parameters) \
__ENUMERATE_SYSCALL(gui_set_window_parameters) \
__ENUMERATE_SYSCALL(unlink) \
+ __ENUMERATE_SYSCALL(poll) \
struct fd_set;
diff --git a/Kernel/UnixTypes.h b/Kernel/UnixTypes.h
index 46a4799718..c896a61c89 100644
--- a/Kernel/UnixTypes.h
+++ b/Kernel/UnixTypes.h
@@ -291,3 +291,16 @@ struct stat {
time_t st_mtime; /* time of last modification */
time_t st_ctime; /* time of last status change */
};
+
+#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;
+};
diff --git a/Kernel/sync-local.sh b/Kernel/sync-local.sh
deleted file mode 100755
index 8ff7bd2e39..0000000000
--- a/Kernel/sync-local.sh
+++ /dev/null
@@ -1,10 +0,0 @@
-cp ../../figlet-2.2.5/figlet mnt/bin/
-mkdir -p mnt/usr/local/share/figlet
-FIGLET_FONTDIR=/
-cp ../../figlet-2.2.5/fonts/standard.flf mnt/$FIGLET_FONTDIR
-cp ../../figlet-2.2.5/fonts/big.flf mnt/$FIGLET_FONTDIR
-cp ../../figlet-2.2.5/fonts/slant.flf mnt/$FIGLET_FONTDIR
-cp ../../figlet-2.2.5/fonts/lean.flf mnt/$FIGLET_FONTDIR
-
-cp ../../bash-2.05b/bash mnt/bin/bash
-
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
+