diff options
author | Ian Moffett <ian@osmora.org> | 2024-03-07 17:28:52 -0500 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-03-07 18:24:51 -0500 |
commit | f5e48e94a2f4d4bbd6e5628c7f2afafc6dbcc459 (patch) | |
tree | 93b156621dc0303816b37f60ba88051b702d92f6 /lib/mlibc/sysdeps/keyronex | |
parent | bd5969fc876a10b18613302db7087ef3c40f18e1 (diff) |
build: Build mlibc + add distclean target
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/mlibc/sysdeps/keyronex')
55 files changed, 0 insertions, 1557 deletions
diff --git a/lib/mlibc/sysdeps/keyronex/generic/entry.cpp b/lib/mlibc/sysdeps/keyronex/generic/entry.cpp deleted file mode 100644 index ff15c62..0000000 --- a/lib/mlibc/sysdeps/keyronex/generic/entry.cpp +++ /dev/null @@ -1,108 +0,0 @@ -#include <bits/ensure.h> -#include <bits/posix/posix_signal.h> -#include <keyronex/syscall.h> -#include <mlibc/all-sysdeps.hpp> -#include <mlibc/debug.hpp> -#include <mlibc/elf/startup.h> -#include <stdint.h> -#include <stdlib.h> - -// defined by the POSIX library -void __mlibc_initLocale(); - -extern "C" uintptr_t *__dlapi_entrystack(); - -extern char **environ; -static mlibc::exec_stack_data __mlibc_stack_data; - -struct LibraryGuard { - LibraryGuard(); -}; - -static LibraryGuard guard; - -LibraryGuard::LibraryGuard() -{ - __mlibc_initLocale(); - - // Parse the exec() stack. - mlibc::parse_exec_stack(__dlapi_entrystack(), &__mlibc_stack_data); - mlibc::set_startup_data(__mlibc_stack_data.argc, - __mlibc_stack_data.argv, __mlibc_stack_data.envp); -} - -namespace mlibc { -int -sys_sigentry(void *sigentry) -{ - uintptr_t ret = syscall1(kPXSysSigEntry, (uintptr_t)sigentry, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -[[noreturn]] int -sys_sigreturn(ucontext_t *context) -{ - syscall1(kPXSysSigReturn, (uintptr_t)context, NULL); - __builtin_unreachable(); -} -} - -static void -do_stacktrace(ucontext_t *ctx) -{ - size_t *base_ptr = (size_t *)ctx->uc_mcontext.gregs[REG_RBP]; - - mlibc::infoLogger() << "Stacktrace:" << frg::endlog; - mlibc::infoLogger() << " [" << (void *)ctx->uc_mcontext.gregs[REG_RIP] - << "]" << frg::endlog; - for (;;) { - size_t old_bp = base_ptr[0]; - size_t ret_addr = base_ptr[1]; - if (!ret_addr) - break; - mlibc::infoLogger() - << " [" << (void *)ret_addr << "]" << frg::endlog; - if (!old_bp) - break; - base_ptr = (size_t *)old_bp; - } -} - -static void -__mlibc_sigentry(int which, siginfo_t *siginfo, void *handler, - bool is_sigaction, ucontext_t *ret_context) -{ - if ((uintptr_t)handler == (uintptr_t)SIG_DFL) { - mlibc::infoLogger() - << "mlibc: Unhandled signal " << which << frg::endlog; - do_stacktrace(ret_context); - mlibc::sys_exit(128 + which); - } else if ((uintptr_t)handler == (uintptr_t)SIG_IGN) { - /* epsilon */ - } else { - if (is_sigaction) - ((void (*)(int, siginfo_t *, void *))handler)(which, - siginfo, ret_context); - else - ((void (*)(int))handler)(which); - } - - mlibc::sys_sigreturn(ret_context); - - __builtin_unreachable(); -} - -extern "C" void -__mlibc_entry(int (*main_fn)(int argc, char *argv[], char *env[])) -{ - /* communicate the signal handler entry point to the kernel */ - mlibc::sys_sigentry((void *)__mlibc_sigentry); - - // TODO: call __dlapi_enter, otherwise static builds will break (see - // Linux sysdeps) - auto result = main_fn(__mlibc_stack_data.argc, __mlibc_stack_data.argv, - environ); - exit(result); -} diff --git a/lib/mlibc/sysdeps/keyronex/generic/generic.cpp b/lib/mlibc/sysdeps/keyronex/generic/generic.cpp deleted file mode 100644 index a3e77fb..0000000 --- a/lib/mlibc/sysdeps/keyronex/generic/generic.cpp +++ /dev/null @@ -1,753 +0,0 @@ -#include <asm/ioctls.h> - -#include <bits/ensure.h> -#include <dirent.h> -#include <errno.h> -#include <fcntl.h> -#include <frg/logging.hpp> -#include <keyronex/syscall.h> -#include <limits.h> -#include <mlibc/all-sysdeps.hpp> -#include <mlibc/debug.hpp> -#include <stdlib.h> - -#define STUB_ONLY \ - { \ - __ensure(!"STUB_ONLY function was called"); \ - __builtin_unreachable(); \ - } - -namespace mlibc { - -void -sys_libc_log(const char *message) -{ - syscall1(kPXSysDebug, (uintptr_t)message, NULL); -} - -void -sys_libc_panic() -{ - sys_libc_log("\nMLIBC PANIC\n"); - for (;;) - ; - STUB_ONLY -} - -void -sys_exit(int status) -{ - syscall1(kPXSysExit, status, NULL); - mlibc::panicLogger() << "sys_exit() returned!" << frg::endlog; - __builtin_unreachable(); -} - -#ifndef MLIBC_BUILDING_RTDL -int -sys_tcgetattr(int fd, struct termios *attr) -{ - int ret; - - if (int r = sys_ioctl(fd, TCGETS, attr, &ret) != 0) { - return r; - } - - return 0; -} - -int -sys_tcsetattr(int fd, int optional_action, const struct termios *attr) -{ - int ret; - - switch (optional_action) { - case TCSANOW: - optional_action = TCSETS; - break; - case TCSADRAIN: - optional_action = TCSETSW; - break; - case TCSAFLUSH: - optional_action = TCSETSF; - break; - default: - __ensure(!"Unsupported tcsetattr"); - } - - if (int r = sys_ioctl(fd, optional_action, (void *)attr, &ret) != 0) { - return r; - } - - return 0; -} -#endif - -int -sys_tcb_set(void *pointer) -{ - return syscall1(kPXSysSetFSBase, (uintptr_t)pointer, NULL); -} - -int -sys_ppoll(struct pollfd *fds, int nfds, const struct timespec *timeout, - const sigset_t *sigmask, int *num_events) -{ - uintptr_t ret = syscall4(kPXSysPPoll, (uintptr_t)fds, (uintptr_t)nfds, - (uintptr_t)timeout, (uintptr_t)sigmask, NULL); - if (int e = sc_error(ret); e) - return e; - *num_events = (ssize_t)ret; - return 0; -} - -int -sys_poll(struct pollfd *fds, nfds_t count, int timeout, int *num_events) -{ - struct timespec ts; - ts.tv_sec = timeout / 1000; - ts.tv_nsec = (timeout % 1000) * 1000000; - return sys_ppoll(fds, count, timeout < 0 ? NULL : &ts, NULL, - num_events); -} - -#ifndef MLIBC_BUILDING_RTDL -int -sys_pselect(int nfds, fd_set *read_set, fd_set *write_set, fd_set *except_set, - const struct timespec *timeout, const sigset_t *sigmask, int *num_events) -{ - struct pollfd *fds = (struct pollfd *)malloc( - nfds * sizeof(struct pollfd)); - - for (int i = 0; i < nfds; i++) { - struct pollfd *fd = &fds[i]; - memset(fd, 0, sizeof(struct pollfd)); - - if (read_set && FD_ISSET(i, read_set)) - fd->events |= POLLIN; // TODO: Additional events. - if (write_set && FD_ISSET(i, write_set)) - fd->events |= POLLOUT; // TODO: Additional events. - if (except_set && FD_ISSET(i, except_set)) - fd->events |= POLLPRI; - - if (!fd->events) { - fd->fd = -1; - continue; - } - - fd->fd = i; - } - - int e = sys_ppoll(fds, nfds, timeout, sigmask, num_events); - - if (e != 0) { - free(fds); - return e; - } - - fd_set res_read_set; - fd_set res_write_set; - fd_set res_except_set; - FD_ZERO(&res_read_set); - FD_ZERO(&res_write_set); - FD_ZERO(&res_except_set); - - for (int i = 0; i < nfds; i++) { - struct pollfd *fd = &fds[i]; - - if (read_set && FD_ISSET(i, read_set) && - fd->revents & (POLLIN | POLLERR | POLLHUP)) { - FD_SET(i, &res_read_set); - } - - if (write_set && FD_ISSET(i, write_set) && - fd->revents & (POLLOUT | POLLERR | POLLHUP)) { - FD_SET(i, &res_write_set); - } - - if (except_set && FD_ISSET(i, except_set) && - fd->revents & POLLPRI) { - FD_SET(i, &res_except_set); - } - } - - free(fds); - - if (read_set) - memcpy(read_set, &res_read_set, sizeof(fd_set)); - if (write_set) - memcpy(write_set, &res_write_set, sizeof(fd_set)); - if (except_set) - memcpy(except_set, &res_except_set, sizeof(fd_set)); - - return 0; -} -#endif - -int -sys_fcntl(int fd, int request, va_list args, int *result) -{ - auto ret = syscall3(kPXSysFCntl, fd, request, va_arg(args, uint64_t), - NULL); - if (int e = sc_error(ret); e) - return e; - *result = ret; - return 0; -} - -int -sys_futex_wait(int *pointer, int expected, const struct timespec *time) -{ - auto ret = syscall3(kPXSysFutexWait, (uintptr_t)pointer, expected, - (uintptr_t)time, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_futex_wake(int *pointer) -{ - auto ret = syscall1(kPXSysFutexWake, (uintptr_t)pointer, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -#ifndef MLIBC_BUILDING_RTDL -int -sys_ioctl(int fd, unsigned long request, void *arg, int *result) -{ - uintptr_t r = syscall3(kPXSysIOCtl, fd, request, (uintptr_t)arg, NULL); - if (int e = sc_error(r); e) - return e; - *result = r; - return 0; -} -#endif - -int -sys_isatty(int fd) -{ - uintptr_t ret = syscall1(kPXSysIsATTY, fd, NULL); - if (int e = sc_error(ret); e) { - return e; - } - return 0; -} - -#ifndef MLIBC_BUILDING_RTDL -int -sys_getcwd(char *buffer, size_t size) -{ - uintptr_t ret = syscall2(kPXSysGetCWD, (uintptr_t)buffer, size, NULL); - if (int e = sc_error(ret); e) { - return e; - } - return 0; -} -#endif - -int -sys_dup(int fd, int flags, int *newfd) -{ - uintptr_t ret = syscall2(kPXSysDup, fd, flags, NULL); - if (int e = sc_error(ret); e) { - return e; - } - *newfd = ret; - return 0; -} - -int -sys_dup2(int fd, int flags, int newfd) -{ - uintptr_t ret = syscall3(kPXSysDup3, fd, newfd, flags, NULL); - if (int e = sc_error(ret); e) { - return e; - } - return 0; -} - -int -sys_openat(int dirfd, const char *path, int flags, mode_t mode, int *fd) -{ - uintptr_t r = syscall4(kPXSysOpenAt, dirfd, (uintptr_t)path, - (uintptr_t)flags, (uintptr_t)mode, NULL); - if (int e = sc_error(r); e) - return e; - *fd = (int)r; - return 0; -} - -int -sys_open(const char *path, int flags, mode_t mode, int *fd) -{ - return sys_openat(AT_FDCWD, path, flags, mode, fd); -} - -int -sys_open_dir(const char *path, int *handle) -{ - return sys_open(path, O_DIRECTORY, 0, handle); -} - -int -sys_read_entries(int fd, void *buffer, size_t max_size, size_t *bytes_read) -{ - uintptr_t r = syscall3(kPXSysReadDir, fd, (uintptr_t)buffer, max_size, - NULL); - - if (int e = sc_error(r); e) - return e; - - *bytes_read = r; - return 0; -} - -int -sys_close(int fd) -{ - return (int)syscall1(kPXSysClose, fd, NULL); -} - -int -sys_link(const char *old_path, const char *new_path) -{ - uintptr_t ret = syscall2(kPXSysLink, (uintptr_t)old_path, - (uintptr_t)new_path, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_seek(int fd, off_t offset, int whence, off_t *new_offset) -{ - uintptr_t ret = syscall3(kPXSysSeek, fd, offset, whence, NULL); - if (int e = sc_error(ret); e) - return e; - *new_offset = (ssize_t)ret; - return 0; -} - -int -sys_read(int fd, void *buf, size_t count, ssize_t *bytes_read) -{ - uintptr_t ret = syscall3(kPXSysRead, fd, (uintptr_t)buf, - (uintptr_t)count, NULL); - if (int e = sc_error(ret); e) - return e; - *bytes_read = (ssize_t)ret; - return 0; -} - -int -sys_write(int fd, const void *buf, size_t count, ssize_t *bytes_written) -{ - uintptr_t ret = syscall3(kPXSysWrite, fd, (uintptr_t)buf, - (uintptr_t)count, NULL); - if (int e = sc_error(ret); e) - return e; - *bytes_written = (ssize_t)ret; - return 0; -} - -int -sys_readlink(const char *path, void *buffer, size_t max_size, ssize_t *length) -{ - uintptr_t ret = syscall3(kPXSysReadLink, (uintptr_t)path, - (uintptr_t)buffer, (uintptr_t)max_size, NULL); - if (int e = sc_error(ret); e) - return e; - *length = (ssize_t)ret; - return 0; -} - -int -sys_pipe(int *fds, int flags) -{ - uintptr_t ret = syscall2(kPXSysPipe, (uintptr_t)fds, flags, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_unlinkat(int fd, const char *path, int flags) -{ - uintptr_t ret = syscall3(kPXSysUnlinkAt, fd, (uintptr_t)path, flags, - NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_vm_map(void *hint, size_t size, int prot, int flags, int fd, off_t offset, - void **window) -{ - uintptr_t r = syscall6(kPXSysMmap, (uintptr_t)hint, size, prot, flags, - fd, offset, NULL); - if (int e = sc_error(r); e) - return e; - *window = (void *)r; - return 0; -} - -int -sys_vm_unmap(void *pointer, size_t size) -{ - uintptr_t r = syscall2(kPXSysMunmap, (uintptr_t)pointer, size, NULL); - if (int e = sc_error(r); e) - return e; - return 0; -} - -int -sys_vm_protect(void *pointer, size_t size, int prot) -{ - - mlibc::infoLogger() << "mlibc: sys_vm_protect(" << pointer << ", " - << size << ", " << prot << "); stub!\n" - << frg::endlog; - return 0; -} - -int -sys_anon_allocate(size_t size, void **pointer) -{ - return sys_vm_map(NULL, size, PROT_EXEC | PROT_READ | PROT_WRITE, - MAP_ANONYMOUS, -1, 0, pointer); -} - -int -sys_anon_free(void *pointer, size_t size) -{ - return sys_vm_unmap(pointer, size); -} - -pid_t -sys_getpid() -{ - return syscall0(kPXSysGetPID, NULL); -} - -pid_t -sys_getppid() -{ - return syscall0(kPXSysGetPPID, NULL); -} - -uid_t -sys_getuid() -{ - return 0; -} - -uid_t -sys_geteuid() -{ - return 0; -} - -gid_t -sys_getgid() -{ - return 0; -} - -int -sys_getsid(pid_t pid, pid_t *sid) -{ - auto ret = syscall1(kPXSysGetSID, pid, NULL); - if (int e = sc_error(ret); e) - return e; - *sid = (pid_t)(ret); - return 0; -} - -int -sys_setgid(gid_t gid) -{ - (void)gid; - return 0; -} - -int -sys_getpgid(pid_t pid, pid_t *out) -{ - auto ret = syscall1(kPXSysGetPGID, pid, NULL); - if (int e = sc_error(ret); e) - return e; - *out = (pid_t)(ret); - return 0; -} - -int -sys_setpgid(pid_t pid, pid_t pgid) -{ - auto ret = syscall2(kPXSysSetPGID, pid, pgid, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_setsid(pid_t *sid) -{ - auto ret = syscall0(kPXSysSetSID, NULL); - if (int e = sc_error(ret); e) - return e; - *sid = (pid_t)ret; - return 0; -} - -gid_t -sys_getegid() -{ - mlibc::infoLogger() << "mlibc: " << __func__ << " is a stub!\n" - << frg::endlog; - return 0; -} - -pid_t -sys_gettid() -{ - return syscall0(kPXSysGetTID, NULL); -} - -int -sys_clock_get(int clock, time_t *secs, long *nanos) -{ - auto ret = syscall1(kPXSysClockGet, clock, NULL); - *secs = ret / 1000000000; - *nanos = ret % 1000000000; - return 0; -} - -int -sys_stat(fsfd_target fsfdt, int fd, const char *path, int flags, - struct stat *statbuf) -{ - uintptr_t r; - enum posix_stat_kind kind; - - switch (fsfdt) { - case fsfd_target::fd: - kind = kPXStatKindFD; - break; - - case fsfd_target::path: - kind = kPXStatKindCWD; - break; - case fsfd_target::fd_path: - kind = kPXStatKindAt; - break; - - default: - __ensure(!"stat: Invalid fsfdt"); - __builtin_unreachable(); - } - - r = syscall5(kPXSysStat, kind, fd, (uintptr_t)path, flags, - (uintptr_t)statbuf, NULL); - if (int e = sc_error(r); e) - return e; - return 0; -} - -int -sys_statfs(const char *path, struct statfs *buf) -{ - uintptr_t ret = syscall2(kPXSysStatFS, (uintptr_t)path, (uintptr_t)buf, - NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_statvfs(const char *path, struct statvfs *buf) -{ - struct statfs sb; - uintptr_t ret = syscall2(kPXSysStatFS, (uintptr_t)path, (uintptr_t)&sb, - NULL); - if (int e = sc_error(ret); e) - return e; - - buf->f_bsize = sb.f_bsize; - buf->f_frsize = sb.f_frsize; - buf->f_blocks = sb.f_blocks; - buf->f_bfree = sb.f_bfree; - buf->f_bavail = sb.f_bavail; - - buf->f_files = sb.f_files; - buf->f_ffree = sb.f_ffree; - buf->f_favail = sb.f_ffree; - - buf->f_fsid = sb.f_fsid.__val[1] | (uint64_t)sb.f_fsid.__val[0] << 32; - buf->f_flag = sb.f_flags; - buf->f_namemax = sb.f_namelen; - - return 0; -} - -int -sys_faccessat(int dirfd, const char *pathname, int mode, int flags) -{ - (void)flags; - struct stat buf; - if (int r = sys_stat(dirfd == AT_FDCWD ? fsfd_target::path : - fsfd_target::fd_path, - dirfd, pathname, mode & AT_SYMLINK_FOLLOW, &buf)) { - return r; - } - return 0; -} - -int -sys_access(const char *path, int mode) -{ - return sys_faccessat(AT_FDCWD, path, mode, 0); -} - -int -sys_fork(pid_t *child) -{ - uintptr_t ret = syscall0(kPXSysFork, NULL); - if (int e = sc_error(ret); e) - return e; - *child = (int)ret; - return 0; -} - -int -sys_execve(const char *path, char *const argv[], char *const envp[]) -{ - uintptr_t ret = syscall3(kPXSysExecVE, (uintptr_t)path, (uintptr_t)argv, - (uintptr_t)envp, NULL); - if (int e = sc_error(ret); e) - return e; - mlibc::panicLogger() << "execve returned! " << ret << frg::endlog; - __builtin_unreachable(); -} - -int -sys_waitpid(pid_t pid, int *status, int flags, struct rusage *ru, - pid_t *ret_pid) -{ - (void)ru; - - uintptr_t ret = syscall3(kPXSysWaitPID, pid, (uintptr_t)status, flags, - NULL); - if (int e = sc_error(ret); e) - return e; - *ret_pid = (pid_t)ret; - return 0; -} - -#ifndef MLIBC_BUILDING_RTDL -int -sys_sleep(time_t *sec, long *nanosec) -{ - auto ret = syscall1(kPXSysSleep, *sec * 1000000000 + *nanosec, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_uname(struct utsname *buf) -{ - uintptr_t ret = syscall1(kPXSysUTSName, (uintptr_t)buf, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_gethostname(char *buf, size_t bufsize) -{ - struct utsname uname_buf; - if (auto e = sys_uname(&uname_buf); e) - return e; - - auto node_len = strlen(uname_buf.nodename); - if (node_len >= bufsize) - return ENAMETOOLONG; - - memcpy(buf, uname_buf.nodename, node_len); - buf[node_len] = '\0'; - return 0; -} - -int -sys_fsync(int) -{ - mlibc::infoLogger() << "mlibc: fsync is a stub" << frg::endlog; - return 0; -} - -int -sys_getentropy(void *buffer, size_t length) -{ - /* todo: improve lmao */ - mlibc::infoLogger() << "mlibc: getentropy is a stub" << frg::endlog; - memset(buffer, 123, length); - return 0; -} -#endif - -int -sys_mkdir(const char *path, mode_t mode) -{ - return sys_mkdirat(AT_FDCWD, path, mode); -} - -int -sys_mkdirat(int dirfd, const char *path, mode_t mode) -{ - uintptr_t ret = syscall3(kPXSysMkDirAt, dirfd, (uintptr_t)path, mode, - NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_chdir(const char *path) -{ - uintptr_t ret = syscall1(kPXSysChDir, (uintptr_t)path, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_umask(mode_t mode, mode_t *old) -{ - uintptr_t ret = syscall1(kPXSysUMask, mode, NULL); - if (int e = sc_error(ret); e) - return e; - *old = (mode_t)ret; - return 0; -} - -int -sys_rename(const char *old_path, const char *new_path) -{ - return sys_renameat(AT_FDCWD, old_path, AT_FDCWD, new_path); -} - -int -sys_renameat(int old_dirfd, const char *old_path, int new_dirfd, - const char *new_path) -{ - auto ret = syscall4(kPXSysRenameAt, old_dirfd, (uintptr_t)old_path, - new_dirfd, (uintptr_t)new_path, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -} // namespace mlibc diff --git a/lib/mlibc/sysdeps/keyronex/generic/linux.cpp b/lib/mlibc/sysdeps/keyronex/generic/linux.cpp deleted file mode 100644 index 9b4a4c7..0000000 --- a/lib/mlibc/sysdeps/keyronex/generic/linux.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include <sys/types.h> - -#include <keyronex/syscall.h> -#include <mlibc/ansi-sysdeps.hpp> -#include <mlibc/debug.hpp> -#include <mlibc/posix-sysdeps.hpp> -#include <mlibc/linux-sysdeps.hpp> - -namespace mlibc { - -int -sys_epoll_pwait(int epfd, struct epoll_event *ev, int n, int timeout, - const sigset_t *sigmask, int *raised) -{ - uintptr_t ret = syscall5(kPXSysEPollWait, epfd, (uintptr_t)ev, n, - timeout, (uintptr_t)sigmask, NULL); - if (int e = sc_error(ret); e) - return e; - *raised = ret; - return 0; -} - -int -sys_epoll_create(int flags, int *fd) -{ - uintptr_t ret = syscall1(kPXSysEPollCreate, flags, NULL); - if (int e = sc_error(ret); e) - return e; - *fd = ret; - return 0; -} - -int -sys_epoll_ctl(int epfd, int mode, int fd, struct epoll_event *ev) -{ - uintptr_t ret = syscall4(kPXSysEPollCtl, epfd, mode, fd, (uintptr_t)ev, - NULL); - return sc_error(ret); -} - -}
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/generic/signal.cpp b/lib/mlibc/sysdeps/keyronex/generic/signal.cpp deleted file mode 100644 index ead3dee..0000000 --- a/lib/mlibc/sysdeps/keyronex/generic/signal.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include <sys/types.h> - -#include <keyronex/syscall.h> -#include <mlibc/ansi-sysdeps.hpp> -#include <mlibc/posix-sysdeps.hpp> -#include <mlibc/debug.hpp> - -namespace mlibc { - -int -sys_sigprocmask(int how, const sigset_t *__restrict set, - sigset_t *__restrict retrieve) -{ - auto ret = syscall3(kPXSysSigMask, how, (uintptr_t)set, - (uintptr_t)retrieve, NULL); - if (int e = sc_error(ret); e) { - return e; - } - - return 0; -} - -int -sys_sigaction(int signal, const struct sigaction *__restrict action, - struct sigaction *__restrict oldAction) -{ - auto ret = syscall3(kPXSysSigAction, signal, (uintptr_t)action, - (uintptr_t)oldAction, NULL); - if (int e = sc_error(ret); e) { - return e; - } - - return 0; -} - -int -sys_kill(int pid, int signal) -{ - if (signal == 0) { - mlibc::infoLogger() << "Sending signal 0! Allowing" << frg::endlog; - return 0; - } - - auto ret = syscall2(kPXSysSigSend, pid, signal, NULL); - if (int e = sc_error(ret); e) { - return e; - } - - return 0; -} - -int -sys_sigsuspend(const sigset_t *set) -{ - auto ret = syscall1(kPXSysSigSuspend, (uintptr_t)set, NULL); - if (int e = sc_error(ret); e) { - return e; - } - - mlibc::panicLogger() - << "Unexpected zero return from sigsuspend()" << frg::endlog; - - return 0; -} - -}
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/generic/socket.cpp b/lib/mlibc/sysdeps/keyronex/generic/socket.cpp deleted file mode 100644 index c6453bf..0000000 --- a/lib/mlibc/sysdeps/keyronex/generic/socket.cpp +++ /dev/null @@ -1,119 +0,0 @@ -#include <sys/errno.h> - -#include <keyronex/syscall.h> -#include <mlibc/all-sysdeps.hpp> -#include <mlibc/allocator.hpp> -#include <mlibc/debug.hpp> - -#define log_unimplemented() \ - mlibc::infoLogger() << "mlibc: " << __PRETTY_FUNCTION__ \ - << " is a stub!" << frg::endlog; - -namespace mlibc { - -int -sys_socket(int family, int type, int protocol, int *fd) -{ - auto ret = syscall3(kPXSysSocket, family, type, protocol, NULL); - if (int e = sc_error(ret); e) - return e; - *fd = ret; - return 0; -} - -int -sys_bind(int fd, const struct sockaddr *addr, socklen_t addrlen) -{ - auto ret = syscall3(kPXSysBind, fd, (uintptr_t)addr, addrlen, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_connect(int fd, const struct sockaddr *addr, socklen_t addrlen) -{ - auto ret = syscall3(kPXSysConnect, fd, (uintptr_t)addr, addrlen, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_listen(int fd, int backlog) -{ - auto ret = syscall2(kPXSysListen, fd, backlog, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_accept(int fd, int *newfd, struct sockaddr *addr, socklen_t *addrlen, - int flags) -{ - auto ret = syscall4(kPXSysAccept, fd, (uintptr_t)addr, - (uintptr_t)addrlen, flags, NULL); - if (int e = sc_error(ret); e) - return e; - *newfd = ret; - return 0; -} - -int -sys_msg_send(int fd, const struct msghdr *msg, int flags, ssize_t *length) -{ - auto ret = syscall3(kPXSysSendMsg, fd, (uintptr_t)msg, flags, NULL); - if (int e = sc_error(ret); e) - return e; - *length = ret; - return 0; -} - -int -sys_msg_recv(int fd, struct msghdr *msg, int flags, ssize_t *length) -{ - auto ret = syscall3(kPXSysRecvMsg, fd, (uintptr_t)msg, flags, NULL); - if (int e = sc_error(ret); e) - return e; - *length = ret; - return 0; -} - -int -sys_socketpair(int domain, int type_and_flags, int proto, int *fds) -{ - auto ret = syscall4(kPXSysSocketPair, domain, type_and_flags, proto, - (uintptr_t)fds, NULL); - if (int e = sc_error(ret); e) - return e; - return 0; -} - -int -sys_getsockopt(int fd, int layer, int number, void *__restrict buffer, - socklen_t *__restrict size) -{ - (void)fd; - (void)layer; - (void)number; - (void)buffer; - (void)size; - log_unimplemented(); - return ENOSYS; -} - -int -sys_setsockopt(int fd, int layer, int number, const void *buffer, - socklen_t size) -{ - (void)fd; - (void)layer; - (void)number; - (void)buffer; - (void)size; - log_unimplemented(); - return ENOSYS; -} - -} diff --git a/lib/mlibc/sysdeps/keyronex/generic/thread.S b/lib/mlibc/sysdeps/keyronex/generic/thread.S deleted file mode 100644 index 47ab6a9..0000000 --- a/lib/mlibc/sysdeps/keyronex/generic/thread.S +++ /dev/null @@ -1,9 +0,0 @@ -.section .text -.global __mlibc_thread_entry -__mlibc_thread_entry: - pop %rdi - pop %rsi - pop %rdx - call __mlibc_thread_trampoline - -.section .note.GNU-stack,"",%progbits diff --git a/lib/mlibc/sysdeps/keyronex/generic/thread.cpp b/lib/mlibc/sysdeps/keyronex/generic/thread.cpp deleted file mode 100644 index cafb74a..0000000 --- a/lib/mlibc/sysdeps/keyronex/generic/thread.cpp +++ /dev/null @@ -1,80 +0,0 @@ -#include <sys/mman.h> -#include <mlibc/debug.hpp> -#include <errno.h> -#include <mlibc/all-sysdeps.hpp> -#include <bits/ensure.h> -#include <mlibc/tcb.hpp> -#include <keyronex/syscall.h> - -extern "C" void __mlibc_thread_trampoline(void *(*fn)(void *), Tcb *tcb, void *arg) { - if (mlibc::sys_tcb_set(tcb)) { - __ensure(!"failed to set tcb for new thread"); - } - - while (__atomic_load_n(&tcb->tid, __ATOMIC_RELAXED) == 0) { - mlibc::sys_futex_wait(&tcb->tid, 0, nullptr); - } - - tcb->invokeThreadFunc(reinterpret_cast<void *>(fn), arg); - - __atomic_store_n(&tcb->didExit, 1, __ATOMIC_RELEASE); - mlibc::sys_futex_wake(&tcb->didExit); - - mlibc::sys_thread_exit(); -} - -#define DEFAULT_STACK 0x400000 - -namespace mlibc { - -extern "C" void __mlibc_thread_entry(); - - int sys_clone(void *tcb, pid_t *tid_out, void *stack) { - (void)tcb; - - auto ret = syscall2(kPXSysForkThread, (uintptr_t)__mlibc_thread_entry, (uintptr_t)stack, NULL); - if (int e = sc_error(ret); e) - return e; - - *tid_out = ret; - return 0; - } - - int sys_prepare_stack(void **stack, void *entry, void *arg, void *tcb, size_t *stack_size, size_t *guard_size, void **stack_base) { - // TODO guard - - mlibc::infoLogger() << "mlibc: sys_prepare_stack() does not setup a guard!" << frg::endlog; - - *guard_size = 0; - - *stack_size = *stack_size ? *stack_size : DEFAULT_STACK; - - if (!*stack) { - *stack_base = mmap(NULL, *stack_size, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); - if (*stack_base == MAP_FAILED) { - return errno; - } - } else { - *stack_base = *stack; - } - - *stack = (void *)((char *)*stack_base + *stack_size); - - void **stack_it = (void **)*stack; - - *--stack_it = arg; - *--stack_it = tcb; - *--stack_it = entry; - - *stack = (void *)stack_it; - - return 0; - } - - void sys_thread_exit() { - mlibc::panicLogger() << "mlibc: sys_thread_exit unimplemented!" << frg::endlog; - __builtin_unreachable(); - } - - -} diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/access.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/access.h deleted file mode 120000 index cb83931..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/access.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/access.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/auxv.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/auxv.h deleted file mode 120000 index c43f878..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/auxv.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/auxv.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/blkcnt_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/blkcnt_t.h deleted file mode 120000 index 0b0ec27..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/blkcnt_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/blkcnt_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/blksize_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/blksize_t.h deleted file mode 120000 index 7dc8d7c..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/blksize_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/blksize_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/clockid_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/clockid_t.h deleted file mode 120000 index 6a42da5..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/clockid_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/clockid_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/dev_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/dev_t.h deleted file mode 120000 index bca881e..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/dev_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/dev_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/epoll.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/epoll.h deleted file mode 120000 index eb4b76d..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/epoll.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/epoll.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/errno.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/errno.h deleted file mode 120000 index 6e507de..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/errno.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/errno.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/fcntl.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/fcntl.h deleted file mode 120000 index 463e2c9..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/fcntl.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/fcntl.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/fsblkcnt_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/fsblkcnt_t.h deleted file mode 120000 index 898dfb2..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/fsblkcnt_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/fsblkcnt_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/fsfilcnt_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/fsfilcnt_t.h deleted file mode 120000 index 791755c..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/fsfilcnt_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/fsfilcnt_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/gid_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/gid_t.h deleted file mode 120000 index abce6d6..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/gid_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/gid_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/in.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/in.h deleted file mode 120000 index 418d1d5..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/in.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/in.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/ino_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/ino_t.h deleted file mode 120000 index 4c20aca..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/ino_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/ino_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/inotify.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/inotify.h deleted file mode 120000 index b5cb282..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/inotify.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/inotify.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/ioctls.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/ioctls.h deleted file mode 120000 index 595106b..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/ioctls.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/ioctls.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/limits.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/limits.h deleted file mode 120000 index 6c88db2..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/limits.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/limits.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/mode_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/mode_t.h deleted file mode 120000 index 5d78fdf..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/mode_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/mode_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/mqueue.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/mqueue.h deleted file mode 120000 index fa87b07..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/mqueue.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/mqueue.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/msg.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/msg.h deleted file mode 120000 index f402b49..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/msg.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/msg.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/nlink_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/nlink_t.h deleted file mode 120000 index bb3b625..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/nlink_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/nlink_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/packet.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/packet.h deleted file mode 120000 index 998ef1a..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/packet.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/packet.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/pid_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/pid_t.h deleted file mode 120000 index baa90f6..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/pid_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/pid_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/poll.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/poll.h deleted file mode 120000 index 8ea6a0a..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/poll.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/poll.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/ptrace.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/ptrace.h deleted file mode 120000 index b2517b2..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/ptrace.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/ptrace.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/reboot.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/reboot.h deleted file mode 120000 index 77013a4..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/reboot.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/reboot.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/resource.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/resource.h deleted file mode 120000 index 88d7402..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/resource.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/resource.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/seek-whence.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/seek-whence.h deleted file mode 120000 index df7bccf..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/seek-whence.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/seek-whence.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/shm.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/shm.h deleted file mode 120000 index 067d8c4..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/shm.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/shm.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/signal.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/signal.h deleted file mode 120000 index 4dcb0b7..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/signal.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/signal.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/socket.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/socket.h deleted file mode 120000 index f1dc016..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/socket.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/socket.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/socklen_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/socklen_t.h deleted file mode 120000 index 41f3b11..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/socklen_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/socklen_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/stat.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/stat.h deleted file mode 120000 index 1f63b41..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/stat.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/stat.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/statfs.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/statfs.h deleted file mode 120000 index e3d202f..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/statfs.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/statfs.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/statvfs.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/statvfs.h deleted file mode 120000 index 1fc80c2..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/statvfs.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/statvfs.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/suseconds_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/suseconds_t.h deleted file mode 120000 index 9ed6597..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/suseconds_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/suseconds_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/termios.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/termios.h deleted file mode 120000 index ee8f0b0..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/termios.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/termios.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/time.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/time.h deleted file mode 120000 index 2a02625..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/time.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/time.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/uid_t.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/uid_t.h deleted file mode 120000 index b306777..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/uid_t.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/uid_t.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/utsname.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/utsname.h deleted file mode 120000 index b285754..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/utsname.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/utsname.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/vm-flags.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/vm-flags.h deleted file mode 120000 index bbe258c..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/vm-flags.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/vm-flags.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/wait.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/wait.h deleted file mode 120000 index feb2840..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/wait.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/wait.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/abi-bits/xattr.h b/lib/mlibc/sysdeps/keyronex/include/abi-bits/xattr.h deleted file mode 120000 index 66412d7..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/abi-bits/xattr.h +++ /dev/null @@ -1 +0,0 @@ -../../../../abis/linux/xattr.h
\ No newline at end of file diff --git a/lib/mlibc/sysdeps/keyronex/include/keyronex/syscall.h b/lib/mlibc/sysdeps/keyronex/include/keyronex/syscall.h deleted file mode 100644 index 9cbafd0..0000000 --- a/lib/mlibc/sysdeps/keyronex/include/keyronex/syscall.h +++ /dev/null @@ -1,213 +0,0 @@ -#ifndef _KEYRONEX__SYSCALL_H -#define _KEYRONEX__SYSCALL_H - -#include <stdint.h> - -enum posix_syscall { - /*! debug print */ - kPXSysDebug, - kPXSysMmap, - kPXSysMunmap, - - kPXSysIOCtl, - kPXSysOpenAt, - kPXSysClose, - kPXSysRead, - kPXSysReadLink, - kPXSysWrite, - kPXSysSeek, - kPXSysPPoll, - kPXSysIsATTY, - kPXSysReadDir, - kPXSysStat, - kPXSysUnlinkAt, - kPXSysGetCWD, - kPXSysPipe, - kPXSysDup, - kPXSysDup3, - kPXSysLink, - kPXSysChDir, - kPXSysUMask, - kPXSysMkDirAt, - kPXSysRenameAt, - kPXSysStatFS, - kPXSysFCntl, - - kPXSysSetFSBase, - kPXSysExecVE, - kPXSysExit, - kPXSysFork, - kPXSysWaitPID, - kPXSysGetPID, - kPXSysGetPPID, - kPXSysGetPGID, - kPXSysSetPGID, - kPXSysGetSID, - kPXSysSetSID, - kPXSysGetTID, - - kPXSysSigAction, - kPXSysSigMask, - kPXSysSigSend, - kPXSysSigSuspend, - kPXSysSigTimedWait, - - kPXSysSocket, - kPXSysBind, - kPXSysConnect, - kPXSysListen, - kPXSysAccept, - kPXSysSendMsg, - kPXSysRecvMsg, - kPXSysSocketPair, - kPXSysGetSockOpt, - kPXSysSetSockOpt, - - kPXSysEPollCreate, - kPXSysEPollCtl, - kPXSysEPollWait, - - kPXSysSleep, - kPXSysUTSName, - kPXSysClockGet, - - kPXSysForkThread, - kPXSysFutexWait, - kPXSysFutexWake, - - /*! register signal entry function */ - kPXSysSigEntry, - /*! return from a signal */ - kPXSysSigReturn, -}; - -enum posix_stat_kind { - kPXStatKindFD, - kPXStatKindAt, - kPXStatKindCWD, -}; - -#if defined(__x86_64__) -static inline uintptr_t -syscall0(uintptr_t num, uintptr_t *out) -{ - uintptr_t ret, ret2; - asm volatile("int $0x80" : "=a"(ret), "=D"(ret2) : "a"(num) : "memory"); - if (out) - *out = ret2; - return ret; -} - -static inline uintptr_t -syscall1(uintptr_t num, uintptr_t arg1, uintptr_t *out) -{ - uintptr_t ret, ret2; - asm volatile("int $0x80" - : "=a"(ret), "=D"(ret2) - : "a"(num), "D"(arg1) - : "memory"); - if (out) - *out = ret2; - return ret; -} - -static inline uintptr_t -syscall2(uintptr_t num, uintptr_t arg1, uintptr_t arg2, uintptr_t *out) -{ - uintptr_t ret, ret2; - - asm volatile("int $0x80" - : "=a"(ret), "=D"(ret2) - : "a"(num), "D"(arg1), "S"(arg2) - : "memory"); - - if (out) - *out = ret2; - - return ret; -} - -static inline uintptr_t -syscall3(intptr_t num, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, - uintptr_t *out) -{ - uintptr_t ret, ret2; - - asm volatile("int $0x80" - : "=a"(ret), "=D"(ret2) - : "a"(num), "D"(arg1), "S"(arg2), "d"(arg3) - : "memory"); - - if (out) - *out = ret2; - - return ret; -} - -static inline uintptr_t -syscall4(intptr_t num, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, - uintptr_t arg4, uintptr_t *out) -{ - register uintptr_t r10 asm("r10") = arg4; - uintptr_t ret, ret2; - - asm volatile("int $0x80" - : "=a"(ret), "=D"(ret2) - : "a"(num), "D"(arg1), "S"(arg2), "d"(arg3), "r"(r10) - : "memory"); - - if (out) - *out = ret2; - - return ret; -} - -static inline uintptr_t -syscall5(uintptr_t num, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, - uintptr_t arg4, uintptr_t arg5, uintptr_t *out) -{ - register uintptr_t r10 asm("r10") = arg4, r8 asm("r8") = arg5; - uintptr_t ret, ret2; - - asm volatile("int $0x80" - : "=a"(ret), "=D"(ret2) - : "a"(num), "D"(arg1), "S"(arg2), "d"(arg3), "r"(r10), - "r"(r8) - : "memory"); - - if (out) - *out = ret2; - - return ret; -} - -static inline uintptr_t -syscall6(uintptr_t num, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, - uintptr_t arg4, uintptr_t arg5, uintptr_t arg6, uintptr_t *out) -{ - register uintptr_t r10 asm("r10") = arg4, r8 asm("r8") = arg5, - r9 asm("r9") = arg6; - uintptr_t ret, ret2; - - asm volatile("int $0x80" - : "=a"(ret), "=D"(ret2) - : "a"(num), "D"(arg1), "S"(arg2), "d"(arg3), "r"(r10), - "r"(r8), "r"(r9) - : "memory"); - - if (out) - *out = ret2; - - return ret; -} - -static inline int -sc_error(uintptr_t ret) -{ - if (ret > -4096UL) - return -ret; - return 0; -} -#endif - -#endif diff --git a/lib/mlibc/sysdeps/keyronex/meson.build b/lib/mlibc/sysdeps/keyronex/meson.build deleted file mode 100644 index 42de7a8..0000000 --- a/lib/mlibc/sysdeps/keyronex/meson.build +++ /dev/null @@ -1,98 +0,0 @@ - -rtdl_sources += files( - 'generic/generic.cpp' -) - -libc_sources += files( - 'generic/entry.cpp', - 'generic/generic.cpp', - 'generic/linux.cpp', - 'generic/signal.cpp', - 'generic/socket.cpp', - 'generic/thread.cpp', - 'generic/thread.S' -) - -if not no_headers - install_headers( - 'include/abi-bits/auxv.h', - 'include/abi-bits/seek-whence.h', - 'include/abi-bits/vm-flags.h', - 'include/abi-bits/errno.h', - 'include/abi-bits/fcntl.h', - 'include/abi-bits/in.h', - 'include/abi-bits/reboot.h', - 'include/abi-bits/resource.h', - 'include/abi-bits/stat.h', - 'include/abi-bits/signal.h', - 'include/abi-bits/socket.h', - 'include/abi-bits/termios.h', - 'include/abi-bits/time.h', - 'include/abi-bits/blkcnt_t.h', - 'include/abi-bits/blksize_t.h', - 'include/abi-bits/dev_t.h', - 'include/abi-bits/gid_t.h', - 'include/abi-bits/ino_t.h', - 'include/abi-bits/mode_t.h', - 'include/abi-bits/nlink_t.h', - 'include/abi-bits/pid_t.h', - 'include/abi-bits/uid_t.h', - 'include/abi-bits/access.h', - 'include/abi-bits/wait.h', - 'include/abi-bits/limits.h', - 'include/abi-bits/utsname.h', - 'include/abi-bits/ptrace.h', - 'include/abi-bits/poll.h', - 'include/abi-bits/epoll.h', - 'include/abi-bits/packet.h', - 'include/abi-bits/inotify.h', - 'include/abi-bits/clockid_t.h', - 'include/abi-bits/shm.h', - 'include/abi-bits/mqueue.h', - 'include/abi-bits/suseconds_t.h', - 'include/abi-bits/fsfilcnt_t.h', - 'include/abi-bits/fsblkcnt_t.h', - 'include/abi-bits/socklen_t.h', - 'include/abi-bits/statfs.h', - 'include/abi-bits/statvfs.h', - 'include/abi-bits/ioctls.h', - 'include/abi-bits/xattr.h', - subdir: 'abi-bits', - follow_symlinks: true - ) - - install_headers( - 'include/keyronex/syscall.h', - subdir: 'keyronex', - ) -endif - -if not headers_only - crt = custom_target('crt0', - build_by_default: true, - command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'], - input: host_machine.cpu_family() / 'crt-src/crt0.S', - output: 'crt0.o', - install: true, - install_dir: get_option('libdir') - ) - - custom_target('crti', - build_by_default: true, - command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'], - input: host_machine.cpu_family() / 'crt-src/crti.S', - output: 'crti.o', - install: true, - install_dir: get_option('libdir') - ) - - custom_target('crtn', - build_by_default: true, - command: c_compiler.cmd_array() + ['-c', '-o', '@OUTPUT@', '@INPUT@'], - input: host_machine.cpu_family() / 'crt-src/crtn.S', - output: 'crtn.o', - install: true, - install_dir: get_option('libdir') - ) -endif - diff --git a/lib/mlibc/sysdeps/keyronex/x86_64/crt-src/crt0.S b/lib/mlibc/sysdeps/keyronex/x86_64/crt-src/crt0.S deleted file mode 100644 index d16a46f..0000000 --- a/lib/mlibc/sysdeps/keyronex/x86_64/crt-src/crt0.S +++ /dev/null @@ -1,7 +0,0 @@ -.section .text -.global _start -_start: - mov $main, %rdi - call __mlibc_entry -.section .note.GNU-stack,"",%progbits - diff --git a/lib/mlibc/sysdeps/keyronex/x86_64/crt-src/crti.S b/lib/mlibc/sysdeps/keyronex/x86_64/crt-src/crti.S deleted file mode 100644 index 911b078..0000000 --- a/lib/mlibc/sysdeps/keyronex/x86_64/crt-src/crti.S +++ /dev/null @@ -1,11 +0,0 @@ -.section .init -.global _init -_init: - push %rax - -.section .fini -.global _fini -_fini: - push %rax -.section .note.GNU-stack,"",%progbits - diff --git a/lib/mlibc/sysdeps/keyronex/x86_64/crt-src/crtn.S b/lib/mlibc/sysdeps/keyronex/x86_64/crt-src/crtn.S deleted file mode 100644 index 0187e50..0000000 --- a/lib/mlibc/sysdeps/keyronex/x86_64/crt-src/crtn.S +++ /dev/null @@ -1,9 +0,0 @@ -.section .init - pop %rax - ret - -.section .fini - pop %rax - ret -.section .note.GNU-stack,"",%progbits - |