Skip to content

Commit

Permalink
Added emscripten _sysconf
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Dec 5, 2018
1 parent 21c29de commit 92a97d1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion src/apis/emscripten/env.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::super::host;
/// NOTE: These syscalls only support wasm_32 for now because they take u32 offset
use libc::{c_int, getgrnam as libc_getgrnam, getpwnam as libc_getpwnam};
use libc::{c_int, getgrnam as libc_getgrnam, getpwnam as libc_getpwnam, c_long, sysconf};
use std::ffi::CStr;
use std::mem;
use std::os::raw::c_char;
Expand Down Expand Up @@ -110,3 +110,11 @@ pub extern "C" fn _getpagesize() -> u32 {
pub extern "C" fn ___build_environment(environ: c_int) {
debug!("emscripten::___build_environment {}", environ);
}

pub extern "C" fn _sysconf(name: c_int, instance: &mut Instance) -> c_long {
debug!("emscripten::_sysconf {}", name);
// TODO: Implement like emscripten expects regarding memory/page size
unsafe {
sysconf(name)
}
}
7 changes: 6 additions & 1 deletion src/apis/emscripten/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,12 +409,17 @@ pub fn generate_emscripten_env<'a, 'b>() -> ImportObject<&'a str, &'b str> {
"_getpagesize",
ImportValue::Func(env::_getpagesize as _),
);
import_object.set(
"env",
"_sysconf",
ImportValue::Func(env::_sysconf as _),
);

mock_external!(import_object, _waitpid);
mock_external!(import_object, _utimes);
mock_external!(import_object, _usleep);
// mock_external!(import_object, _time);
mock_external!(import_object, _sysconf);
// mock_external!(import_object, _sysconf);
// mock_external!(import_object, _strftime);
mock_external!(import_object, _sigsuspend);
// mock_external!(import_object, _sigprocmask);
Expand Down

0 comments on commit 92a97d1

Please sign in to comment.