Get page size through sysconf()

parent f13bd7fd
//! stdlib implementation for Redox, following
use core::{intrinsics, iter, mem, ptr, slice};
use core::convert::TryFrom;
use rand::distributions::{Alphanumeric, Distribution, Uniform};
use rand::prng::XorShiftRng;
use rand::rngs::JitterRng;
......@@ -14,6 +15,7 @@ use header::limits;
use header::string::*;
use header::time::constants::CLOCK_MONOTONIC;
use header::time::timespec;
use header::unistd::{sysconf, _SC_PAGESIZE};
use header::wchar::*;
use header::{ctype, errno, unistd};
use platform;
......@@ -1008,7 +1010,15 @@ pub unsafe extern "C" fn unsetenv(key: *const c_char) -> c_int {
pub unsafe extern "C" fn valloc(size: size_t) -> *mut c_void {
memalign(4096, size)
/* _SC_PAGESIZE is a c_long and may in principle not convert
* correctly to a size_t. */
match size_t::try_from(sysconf(_SC_PAGESIZE)) {
Ok(page_size) => memalign(page_size, size),
Err(_) => {
// A corner case. No errno setting.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment