Have our copy of the now deprecated std::env::page_size

This commit is contained in:
Simon Sapin 2015-07-30 17:31:50 +02:00
parent f10851e788
commit 85aa1658cc
2 changed files with 8 additions and 2 deletions

View file

@ -4,7 +4,6 @@
#![feature(box_syntax)]
#![feature(iter_arith)]
#![cfg_attr(target_os="linux", feature(page_size))]
#![feature(slice_splits)]
#[macro_use] extern crate log;

View file

@ -436,6 +436,13 @@ mod system_reporter {
($e:expr) => (match $e { Some(e) => e, None => return None })
);
#[cfg(target_os="linux")]
fn page_size() -> usize {
unsafe {
::libc::sysconf(::libc::_SC_PAGESIZE) as usize
}
}
#[cfg(target_os="linux")]
fn get_proc_self_statm_field(field: usize) -> Option<usize> {
use std::fs::File;
@ -446,7 +453,7 @@ mod system_reporter {
option_try!(f.read_to_string(&mut contents).ok());
let s = option_try!(contents.split_whitespace().nth(field));
let npages = option_try!(s.parse::<usize>().ok());
Some(npages * ::std::env::page_size())
Some(npages * page_size())
}
#[cfg(target_os="linux")]