mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
ports: add poll to mlibc and make bash use readline
This commit is contained in:
@@ -133,10 +133,10 @@ index 0000000..e5b087a
|
||||
+
|
||||
diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||
new file mode 100644
|
||||
index 0000000..74cb539
|
||||
index 0000000..023c581
|
||||
--- /dev/null
|
||||
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||
@@ -0,0 +1,350 @@
|
||||
@@ -0,0 +1,422 @@
|
||||
+#include <bits/ensure.h>
|
||||
+#include <mlibc/debug.hpp>
|
||||
+#include <mlibc/all-sysdeps.hpp>
|
||||
@@ -211,6 +211,78 @@ index 0000000..74cb539
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ int sys_tcgetattr(int fd, struct termios *attr){
|
||||
+ int res;
|
||||
+ return sys_ioctl(fd, TCGETS, (void *)attr, &res);
|
||||
+ }
|
||||
+
|
||||
+ int sys_tcsetattr(int fd, int act, const struct termios *attr){
|
||||
+ int res;
|
||||
+ return sys_ioctl(fd, TCSETS, (void *)attr, &res);
|
||||
+ }
|
||||
+
|
||||
+ int sys_poll(struct pollfd *fds, nfds_t count, int timeout, int *num_events) {
|
||||
+ long ret;
|
||||
+ long error = syscall(SYSCALL_POLL, &ret, (uint64_t)fds, count, timeout);
|
||||
+ *num_events = ret;
|
||||
+ return error;
|
||||
+ }
|
||||
+
|
||||
+// XXX emulate with ppoll
|
||||
+#ifndef MLIBC_BUILDING_RTDL
|
||||
+ int sys_pselect(int num_fds, fd_set *read_set, fd_set *write_set, fd_set *except_set, const struct timespec *timeout, const sigset_t *sigmask, int *num_events) {
|
||||
+ pollfd *fds = (pollfd *)malloc(num_fds * sizeof(pollfd));
|
||||
+
|
||||
+ if(fds == NULL)
|
||||
+ return ENOMEM;
|
||||
+
|
||||
+ for (int fd = 0; fd < num_fds; ++fd) {
|
||||
+ short events;
|
||||
+ if (read_set && FD_ISSET(fd, read_set)) {
|
||||
+ events |= POLLIN;
|
||||
+ }
|
||||
+
|
||||
+ if (write_set && FD_ISSET(fd, write_set)) {
|
||||
+ events |= POLLOUT;
|
||||
+ }
|
||||
+
|
||||
+ if (except_set && FD_ISSET(fd, except_set)) {
|
||||
+ events |= POLLPRI;
|
||||
+ }
|
||||
+
|
||||
+ if (events) {
|
||||
+ fds[fd].fd = fd;
|
||||
+ fds[fd].events = events;
|
||||
+ fds[fd].revents = 0;
|
||||
+ } else {
|
||||
+ fds[fd].fd = -1;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ int time = timeout == NULL ? -1 : timeout->tv_sec * 1000 + timeout->tv_nsec / 1000000;
|
||||
+
|
||||
+ int err = sys_poll(fds, num_fds, time, num_events);
|
||||
+
|
||||
+ if (err) {
|
||||
+ free(fds);
|
||||
+ return err;
|
||||
+ }
|
||||
+
|
||||
+ for (int fd = 0; fd < num_fds; ++fd) {
|
||||
+ if (read_set && (fds[fd].revents & POLLIN) == 0)
|
||||
+ FD_CLR(fd, read_set);
|
||||
+
|
||||
+ if (write_set && (fds[fd].revents & POLLOUT) == 0)
|
||||
+ FD_CLR(fd, write_set);
|
||||
+
|
||||
+ if (except_set && (fds[fd].revents & POLLPRI) == 0)
|
||||
+ FD_CLR(fd, except_set);
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
+ int sys_umask(mode_t mode, mode_t *old) {
|
||||
+ long ret;
|
||||
+ long error = syscall(SYSCALL_UMASK, &ret, mode);
|
||||
@@ -506,10 +578,10 @@ index 0000000..990eca0
|
||||
+#endif
|
||||
diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||
new file mode 100644
|
||||
index 0000000..7f39915
|
||||
index 0000000..d4405b6
|
||||
--- /dev/null
|
||||
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||
@@ -0,0 +1,57 @@
|
||||
@@ -0,0 +1,58 @@
|
||||
+#ifndef _SYSCALL_H_INCLUDE
|
||||
+#define _SYSCALL_H_INCLUDE
|
||||
+
|
||||
@@ -547,6 +619,7 @@ index 0000000..7f39915
|
||||
+#define SYSCALL_FCHMOD 31
|
||||
+#define SYSCALL_FCHMODAT 32
|
||||
+#define SYSCALL_UMASK 33
|
||||
+#define SYSCALL_POLL 34
|
||||
+
|
||||
+#include <stddef.h>
|
||||
+#include <stdint.h>
|
||||
|
||||
+2
-2
@@ -3,10 +3,10 @@ revision=1
|
||||
from_source=bash
|
||||
imagedeps="base-devel"
|
||||
hostdeps="xgcc xbinutils"
|
||||
deps="mlibc"
|
||||
deps="readline mlibc"
|
||||
|
||||
configure() {
|
||||
${source_dir}/configure --host=x86_64-astral --prefix=${prefix} --without-bash-malloc --disable-readline
|
||||
${source_dir}/configure --host=x86_64-astral --prefix=${prefix} --without-bash-malloc
|
||||
}
|
||||
|
||||
build() {
|
||||
|
||||
Reference in New Issue
Block a user