Stub out poll() syscall and LibC wrapper.

This commit is contained in:
Andreas Kling 2019-01-23 07:27:41 +01:00
parent 8bb18fdc56
commit 2bedabbd6c
Notes: sideshowbarker 2024-07-19 15:58:25 +09:00
10 changed files with 63 additions and 10 deletions

1
Kernel/.gitignore vendored
View file

@ -4,3 +4,4 @@ Boot/boot.bin
kernel
kernel.map
_fs_contents
sync-local.sh

View file

@ -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.

View file

@ -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*);

View file

@ -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:

View file

@ -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;

View file

@ -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;
};

View file

@ -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

View file

@ -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)

14
LibC/poll.cpp Normal file
View file

@ -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);
}
}

23
LibC/poll.h Normal file
View file

@ -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