Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] sysdeps/managarm: implement sys_sysconf #929

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions options/linux/generic/sys-sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <mlibc/linux-sysdeps.hpp>

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;
Expand Down
3 changes: 2 additions & 1 deletion sysdeps/managarm/generic/sched.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#include <bits/ensure.h>
#include <unistd.h>
#include <pwd.h>

#include <hel.h>
#include <hel-syscalls.h>
#include <mlibc/debug.hpp>
#include <mlibc/allocator.hpp>
// #include <mlibc/arch-defs.hpp>
#include <mlibc/posix-pipe.hpp>
#include <mlibc/posix-sysdeps.hpp>

Expand Down Expand Up @@ -94,5 +96,4 @@ int sys_setthreadaffinity(pid_t tid, size_t cpusetsize, const cpu_set_t *mask) {
return 0;
}


}
33 changes: 33 additions & 0 deletions sysdeps/managarm/generic/sysinfo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#include <unistd.h>

#include <hel.h>
#include <hel-syscalls.h>
#include <mlibc/debug.hpp>
#include <mlibc/allocator.hpp>
#include <mlibc/linux-sysdeps.hpp>
#include <mlibc/posix-sysdeps.hpp>

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;
}
}
1 change: 1 addition & 0 deletions sysdeps/managarm/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ libc_sources += files(
'generic/sched.cpp',
'generic/signals.cpp',
'generic/socket.cpp',
'generic/sysinfo.cpp',
'generic/time.cpp'
)
libc_sources += [
Expand Down
Loading