diff --git a/src/header/unistd/mod.rs b/src/header/unistd/mod.rs index 03ffd0803da449b586e655ae4212ced5600053ed..2ec5fdde117989a303b5cb1c5e6ceeda6e5d74d0 100644 --- a/src/header/unistd/mod.rs +++ b/src/header/unistd/mod.rs @@ -443,21 +443,10 @@ pub extern "C" fn getlogin_r(name: *mut c_char, namesize: size_t) -> c_int { #[no_mangle] pub extern "C" fn getpagesize() -> c_int { - match c_int::try_from(sysconf(_SC_PAGESIZE)) { - Ok(page_size) => page_size, - Err(_) => { - /* Behavior not specified by POSIX for this case. The -1 - * value mimics sysconf()'s behavior, though. - * - * As specified for the limits.h header, the minimum - * acceptable value for {PAGESIZE} is 1. The -1 value thus - * cannot be mistaken for an acceptable value. - * - * POSIX does not specify any possible errors for this - * function, hence no errno setting. */ - -1 - } - } + // Panic if we can't uphold the required behavior (no errors are specified for this function) + Sys::getpagesize() + .try_into() + .expect("page size not representable as type `int`") } // #[no_mangle] diff --git a/tests/unistd/getpagesize.c b/tests/unistd/getpagesize.c index f26f7be21cce998d52b7b35d4b4afe7d4d48ec25..e7f2b43924b9fc5ac0c77831e4da41a380b5432d 100644 --- a/tests/unistd/getpagesize.c +++ b/tests/unistd/getpagesize.c @@ -5,10 +5,7 @@ #include "test_helpers.h" int main(void) { - errno = 0; int getpagesize_result = getpagesize(); - int getpagesize_errno = errno; - - printf("getpagesize(): %d, errno: %d = %s\n", getpagesize_result, - getpagesize_errno, strerror(getpagesize_errno)); + + printf("Page size: %d\n", getpagesize_result); }