Skip to content
Snippets Groups Projects
Commit 9ef3374c authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Merge branch 'getpagesize-panic' into 'master'

Panic when getpagesize() cannot succeed as specified

See merge request redox-os/relibc!455
parents 534e7ef8 aea9e2b4
No related branches found
No related tags found
No related merge requests found
Pipeline #14352 passed
......@@ -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]
......
......@@ -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);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment