diff --git mlibc-clean/options/ansi/generic/wchar.cpp mlibc-workdir/options/ansi/generic/wchar.cpp index b44ebc2..9339316 100644 --- mlibc-clean/options/ansi/generic/wchar.cpp +++ mlibc-workdir/options/ansi/generic/wchar.cpp @@ -54,8 +54,13 @@ size_t mbrlen(const char *__restrict mbs, size_t mb_limit, mbstate_t *__restrict mlibc::code_seq nseq{mbs, mbs + mb_limit}; mlibc::code_seq wseq{&wc, &wc + 1}; - if(auto e = cc->decode_wtranscode(nseq, wseq, *stp); e != mlibc::charcode_error::null) - __ensure(!"decode_wtranscode() errors are not handled"); + if(auto e = cc->decode_wtranscode(nseq, wseq, *stp); e != mlibc::charcode_error::null) { + if(e == mlibc::charcode_error::input_underflow) + return static_cast(-1); + __ensure(e == mlibc::charcode_error::illegal_input); + errno = EILSEQ; + return static_cast(-1); + } return nseq.it - mbs; } diff --git mlibc-clean/options/glibc/generic/execinfo.cpp mlibc-workdir/options/glibc/generic/execinfo.cpp index 1ed110d..ded9114 100644 --- mlibc-clean/options/glibc/generic/execinfo.cpp +++ mlibc-workdir/options/glibc/generic/execinfo.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -52,29 +53,7 @@ _Unwind_Reason_Code trace(_Unwind_Context *context, void *arg) { } // namespace int backtrace(void **buffer, int size) { - if (size <= 0) - return 0; - - if (!libgccHandle) { - libgccHandle = dlopen("libgcc_s.so.1", RTLD_LAZY | RTLD_LOCAL); - if (!libgccHandle || libgccHandle.value() == nullptr) { - auto error = dlerror(); - mlibc::infoLogger() << "Failed to load libgcc_s.so.1: " << (error ? error : "") << frg::endlog; - return 0; - } - - unwindBacktrace = reinterpret_cast(dlsym(libgccHandle.value(), "_Unwind_Backtrace")); - unwindGetIP = reinterpret_cast(dlsym(libgccHandle.value(), "_Unwind_GetIP")); - - if (!unwindBacktrace || !unwindGetIP) { - mlibc::infoLogger() << "Failed to find unwind functions in libgcc_s.so.1: " << dlerror() << frg::endlog; - return 0; - } - } - - UnwindState state{buffer, size}; - unwindBacktrace(trace, &state); - return state.current_frame; + return ENOSYS; } char **backtrace_symbols(void *const *, int) { @@ -82,25 +61,5 @@ char **backtrace_symbols(void *const *, int) { __builtin_unreachable(); } -void backtrace_symbols_fd(void *const *buffer, int size, int fd) { - if (size <= 0 || fd < 0) - return; - - for (int frame_num = 0; frame_num < size; frame_num++) { - Dl_info info; - if (dladdr(buffer[frame_num], &info) != 0) { - if (info.dli_fname != nullptr) - write(fd, info.dli_fname, strlen(info.dli_fname)); - - if (info.dli_sname != nullptr) - dprintf(fd, "(%s+0x%" PRIxPTR ") ", info.dli_sname, - reinterpret_cast(buffer[frame_num]) - reinterpret_cast(info.dli_saddr)); - else if(info.dli_saddr) - dprintf(fd, "(+%p) ", info.dli_saddr); - else - dprintf(fd, "() "); - } - - dprintf(fd, "[%p]\n", buffer[frame_num]); - } +void backtrace_symbols_fd(void *const *, int, int) { } diff --git mlibc-clean/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp index 939925e..5ee7fad 100644 --- mlibc-clean/sysdeps/astral/generic/generic.cpp +++ mlibc-workdir/sysdeps/astral/generic/generic.cpp @@ -47,6 +47,12 @@ namespace mlibc { return 0; } + int sys_unlockpt(int fd) { + int r; + // unlockpt is a no-op kernel side, so use this to check for an invalid pty + return sys_ioctl(fd, 0x13376167, NULL, &r); + } + int sys_readv(int fd, const struct iovec *iovs, int iovc, ssize_t *bytes_read) { long r; int error = syscall(SYSCALL_READV, &r, fd, (uint64_t)iovs, iovc); diff --git mlibc-clean/sysdeps/astral/include/astral/archctl.h mlibc-workdir/sysdeps/astral/include/astral/archctl.h index 7e4f2a1..a5f382d 100644 --- mlibc-clean/sysdeps/astral/include/astral/archctl.h +++ mlibc-workdir/sysdeps/astral/include/astral/archctl.h @@ -5,6 +5,11 @@ #define ARCH_CTL_SET_FSBASE 1 #define ARCH_CTL_GET_GSBASE 2 #define ARCH_CTL_GET_FSBASE 3 +#define ARCH_CTL_SET_SYSTRACE 4 + +#define ARCH_CTL_SYSTRACE_OFF 0 +#define ARCH_CTL_SYSTRACE_SELF 1 +#define ARCH_CTL_SYSTRACE_ALL 2 #ifdef __cplusplus extern "C" {