Oops, forgot to add the select() files to LibC a while ago.

This commit is contained in:
Andreas Kling 2019-01-17 01:41:13 +01:00
parent f92e721ae8
commit 5605295d00
Notes: sideshowbarker 2024-07-19 16:01:10 +09:00
2 changed files with 33 additions and 0 deletions

11
LibC/sys/select.cpp Normal file
View File

@ -0,0 +1,11 @@
#include <sys/select.h>
#include <Kernel/Syscall.h>
#include <errno.h>
#include <stdio.h>
int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout)
{
Syscall::SC_select_params params { nfds, readfds, writefds, exceptfds, timeout };
int rc = syscall(SC_select, &params);
__RETURN_WITH_ERRNO(rc, rc, -1);
}

22
LibC/sys/select.h Normal file
View File

@ -0,0 +1,22 @@
#pragma once
#include <sys/cdefs.h>
#include <sys/types.h>
#include <string.h>
__BEGIN_DECLS
#define FD_SETSIZE 64
#define FD_ZERO(set) memset((set), 0, sizeof(fd_set));
#define FD_CLR(fd, set) ((set)->bits[(fd / 8)] &= ~(1 << (fd) % 8))
#define FD_SET(fd, set) ((set)->bits[(fd / 8)] |= (1 << (fd) % 8))
#define FD_ISSET(fd, set) ((set)->bits[(fd / 8)] & (1 << (fd) % 8))
struct fd_set {
unsigned char bits[FD_SETSIZE / 8];
};
int select(int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout);
__END_DECLS