From cf27a71848cddfa19c845555d22e260c185cd955 Mon Sep 17 00:00:00 2001 From: Alexander Richards Date: Wed, 11 Oct 2023 15:07:09 +0200 Subject: [PATCH] [WIP] sysdeps/managarm: implement sys_sysconf --- sysdeps/managarm/generic/sched.cpp | 16 ++++++++++++++++ sysdeps/managarm/rtdl-generic/support.cpp | 1 + 2 files changed, 17 insertions(+) diff --git a/sysdeps/managarm/generic/sched.cpp b/sysdeps/managarm/generic/sched.cpp index 99f81a28ba..8656576922 100644 --- a/sysdeps/managarm/generic/sched.cpp +++ b/sysdeps/managarm/generic/sched.cpp @@ -1,10 +1,12 @@ #include #include +#include #include #include #include #include +// #include #include #include @@ -94,5 +96,19 @@ int sys_setthreadaffinity(pid_t tid, size_t cpusetsize, const cpu_set_t *mask) { return 0; } +int sys_sysconf(int num, long *ret) { + mlibc::infoLogger() << "mlibc: sys_sysconf top" << frg::endlog; + switch(num) { + case _SC_NPROCESSORS_ONLN: + case _SC_NPROCESSORS_CONF: + *ret = 0; + mlibc::infoLogger() << "mlibc: ret = " << ret << ", *ret = " << *ret << frg::endlog; + HEL_CHECK(helGetCpuInformation((uint32_t*)ret)); + mlibc::infoLogger() << "mlibc: ret = " << ret << ", *ret = " << *ret << frg::endlog; + return 0; + default: + return EINVAL; + } +} } diff --git a/sysdeps/managarm/rtdl-generic/support.cpp b/sysdeps/managarm/rtdl-generic/support.cpp index ee8ecbb323..41e8e24889 100644 --- a/sysdeps/managarm/rtdl-generic/support.cpp +++ b/sysdeps/managarm/rtdl-generic/support.cpp @@ -372,6 +372,7 @@ int sys_vm_map(void *hint, size_t size, int prot, int flags, int fd, off_t offse managarm::posix::SvrResponse resp(getAllocator()); resp.ParseFromArray(recv_resp->data, recv_resp->length); + mlibc::infoLogger() << "mlibc: sys_vm_map resp.error()=" << (int)resp.error() << frg::endlog; __ensure(resp.error() == managarm::posix::Errors::SUCCESS); *window = reinterpret_cast(resp.offset()); return 0;