diff --git a/options/linux/generic/sys-sysinfo.cpp b/options/linux/generic/sys-sysinfo.cpp index 950c38a33..6d86bc90b 100644 --- a/options/linux/generic/sys-sysinfo.cpp +++ b/options/linux/generic/sys-sysinfo.cpp @@ -6,6 +6,7 @@ #include int sysinfo(struct sysinfo *info) { + mlibc::infoLogger() << "mlibc: sysinfo top" << frg::endlog; MLIBC_CHECK_OR_ENOSYS(mlibc::sys_sysinfo, -1); if(int e = mlibc::sys_sysinfo(info); e) { errno = e; diff --git a/sysdeps/managarm/generic/sched.cpp b/sysdeps/managarm/generic/sched.cpp index 99f81a28b..655a3c358 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,4 @@ int sys_setthreadaffinity(pid_t tid, size_t cpusetsize, const cpu_set_t *mask) { return 0; } - } diff --git a/sysdeps/managarm/generic/sysinfo.cpp b/sysdeps/managarm/generic/sysinfo.cpp new file mode 100644 index 000000000..2dfe4bb53 --- /dev/null +++ b/sysdeps/managarm/generic/sysinfo.cpp @@ -0,0 +1,33 @@ +#include + +#include +#include +#include +#include +#include +#include + +int sys_sysinfo(struct sysinfo *info) { + mlibc::infoLogger() << "mlibc: sys_sysinfo top" << frg::endlog; + // TODO: fill in missing fields + uint64_t uptimeNanos; + HEL_CHECK(helGetSystemInformation(&uptimeNanos)); + + info->uptime = uptimeNanos / 1'000'000'000; + 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/meson.build b/sysdeps/managarm/meson.build index 671f18090..b3d2b81c5 100644 --- a/sysdeps/managarm/meson.build +++ b/sysdeps/managarm/meson.build @@ -44,6 +44,7 @@ libc_sources += files( 'generic/sched.cpp', 'generic/signals.cpp', 'generic/socket.cpp', + 'generic/sysinfo.cpp', 'generic/time.cpp' ) libc_sources += [