Browse Source

Add _SC_PAGE_SIZE, use sysconf to provide getpagesize

Jeremy Soller 6 years ago
parent
commit
2e260a6b29

+ 1 - 1
src/header/unistd/mod.rs

@@ -332,7 +332,7 @@ pub extern "C" fn getlogin_r(name: *mut c_char, namesize: size_t) -> c_int {
 
 #[no_mangle]
 pub extern "C" fn getpagesize() -> c_int {
-    Sys::getpagesize()
+    sysconf(_SC_PAGESIZE) as c_int
 }
 
 // #[no_mangle]

+ 1 - 0
src/header/unistd/sysconf.rs

@@ -13,6 +13,7 @@ pub const _SC_TZNAME_MAX: c_int = 6;
 // ...
 pub const _SC_VERSION: c_int = 29;
 pub const _SC_PAGESIZE: c_int = 30;
+pub const _SC_PAGE_SIZE: c_int = 30;
 // ...
 pub const _SC_RE_DUP_MAX: c_int = 44;
 // ...

+ 0 - 5
src/platform/linux/mod.rs

@@ -237,11 +237,6 @@ impl Pal for Sys {
         e(unsafe { syscall!(GETGID) }) as gid_t
     }
 
-    fn getpagesize() -> c_int {
-        //TODO
-        4096
-    }
-
     fn getpgid(pid: pid_t) -> pid_t {
         e(unsafe { syscall!(GETPGID, pid) }) as pid_t
     }

+ 0 - 2
src/platform/pal/mod.rs

@@ -75,8 +75,6 @@ pub trait Pal {
 
     fn getgid() -> gid_t;
 
-    fn getpagesize() -> c_int;
-
     fn getpgid(pid: pid_t) -> pid_t;
 
     fn getpid() -> pid_t;

+ 0 - 4
src/platform/redox/mod.rs

@@ -534,10 +534,6 @@ impl Pal for Sys {
         e(syscall::getgid()) as gid_t
     }
 
-    fn getpagesize() -> c_int {
-        4096
-    }
-
     fn getpgid(pid: pid_t) -> pid_t {
         e(syscall::getpgid(pid as usize)) as pid_t
     }