diff --git a/src/header/regex/mod.rs b/src/header/regex/mod.rs index 3742a34c7c4c76a9364086510ec43c423696e0c2..79e9c411b66f322cab694ebb4f98e1cb7419a732 100644 --- a/src/header/regex/mod.rs +++ b/src/header/regex/mod.rs @@ -149,7 +149,7 @@ pub extern "C" fn regexec( #[no_mangle] #[linkage = "weak"] // redefined in GIT -pub extern "C" fn regerror(code: c_int, _regex: *const regex_t, out: *mut c_char, max: c_int) { +pub extern "C" fn regerror(code: c_int, _regex: *const regex_t, out: *mut c_char, max: size_t) -> size_t { let string = match code { 0 => "No error\0", REG_NOMATCH => "No match\0", @@ -174,6 +174,8 @@ pub extern "C" fn regerror(code: c_int, _regex: *const regex_t, out: *mut c_char string.as_ptr(), out as *mut u8, string.len().min(max as usize), - ) + ); } + + string.len() } diff --git a/src/header/stdio/mod.rs b/src/header/stdio/mod.rs index b1153663971808301a7c4e9d7357e7b9ab2f9640..9dc4e8cbf5588f4034e03144fec7384d9ff7c30c 100644 --- a/src/header/stdio/mod.rs +++ b/src/header/stdio/mod.rs @@ -563,10 +563,10 @@ pub unsafe extern "C" fn funlockfile(file: *mut FILE) { #[no_mangle] pub extern "C" fn fwrite( ptr: *const c_void, - size: usize, - count: usize, + size: size_t, + count: size_t, stream: *mut FILE, -) -> usize { +) -> size_t { let mut stream = unsafe { &mut *stream }.lock(); let buf = unsafe { slice::from_raw_parts_mut(ptr as *mut u8, size as usize * count as usize) }; let mut written = 0; @@ -929,7 +929,7 @@ pub unsafe extern "C" fn vprintf(format: *const c_char, ap: va_list) -> c_int { #[no_mangle] pub unsafe extern "C" fn vsnprintf( s: *mut c_char, - n: usize, + n: size_t, format: *const c_char, ap: va_list, ) -> c_int { diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs index e518b050562bfab8b06538049195927924033a6f..859b7bba8d535ad067bf2015fff0dd9498628215 100644 --- a/src/header/stdlib/mod.rs +++ b/src/header/stdlib/mod.rs @@ -855,7 +855,7 @@ pub unsafe extern "C" fn strtoull( s: *const c_char, endptr: *mut *mut c_char, base: c_int, -) -> c_ulong { +) -> c_ulonglong { strtoul(s, endptr, base) } @@ -864,7 +864,7 @@ pub unsafe extern "C" fn strtoll( s: *const c_char, endptr: *mut *mut c_char, base: c_int, -) -> c_long { +) -> c_longlong { strtol(s, endptr, base) } diff --git a/src/header/string/mod.rs b/src/header/string/mod.rs index 013da7c493a68168649fc02c979f4185f4179014..0162e409f7b6cf18ad4ab688c753ff4411b0bf04 100644 --- a/src/header/string/mod.rs +++ b/src/header/string/mod.rs @@ -16,7 +16,7 @@ pub unsafe extern "C" fn memccpy( dest: *mut c_void, src: *const c_void, c: c_int, - n: usize, + n: size_t, ) -> *mut c_void { let to = memchr(src, c, n); if to.is_null() { @@ -30,7 +30,7 @@ pub unsafe extern "C" fn memccpy( } #[no_mangle] -pub unsafe extern "C" fn memchr(s: *const c_void, c: c_int, n: usize) -> *mut c_void { +pub unsafe extern "C" fn memchr(s: *const c_void, c: c_int, n: size_t) -> *mut c_void { let mut s = s as *const u8; let c = c as u8; let mut n = n; @@ -72,7 +72,7 @@ pub unsafe extern "C" fn memchr(s: *const c_void, c: c_int, n: usize) -> *mut c_ } #[no_mangle] -pub unsafe extern "C" fn memcmp(s1: *const c_void, s2: *const c_void, n: usize) -> c_int { +pub unsafe extern "C" fn memcmp(s1: *const c_void, s2: *const c_void, n: size_t) -> c_int { let (div, rem) = (n / mem::size_of::<usize>(), n % mem::size_of::<usize>()); let mut a = s1 as *const usize; let mut b = s2 as *const usize; @@ -104,7 +104,7 @@ pub unsafe extern "C" fn memcmp(s1: *const c_void, s2: *const c_void, n: usize) } #[no_mangle] -pub unsafe extern "C" fn memcpy(s1: *mut c_void, s2: *const c_void, n: usize) -> *mut c_void { +pub unsafe extern "C" fn memcpy(s1: *mut c_void, s2: *const c_void, n: size_t) -> *mut c_void { let mut i = 0; while i + 7 < n { *(s1.offset(i as isize) as *mut u64) = *(s2.offset(i as isize) as *const u64); @@ -118,7 +118,7 @@ pub unsafe extern "C" fn memcpy(s1: *mut c_void, s2: *const c_void, n: usize) -> } #[no_mangle] -pub unsafe extern "C" fn memmove(s1: *mut c_void, s2: *const c_void, n: usize) -> *mut c_void { +pub unsafe extern "C" fn memmove(s1: *mut c_void, s2: *const c_void, n: size_t) -> *mut c_void { if s2 < s1 as *const c_void { // copy from end let mut i = n; @@ -138,7 +138,7 @@ pub unsafe extern "C" fn memmove(s1: *mut c_void, s2: *const c_void, n: usize) - } #[no_mangle] -pub unsafe extern "C" fn memset(s: *mut c_void, c: c_int, n: usize) -> *mut c_void { +pub unsafe extern "C" fn memset(s: *mut c_void, c: c_int, n: size_t) -> *mut c_void { let mut i = 0; while i < n { *(s as *mut u8).offset(i as isize) = c as u8; @@ -231,7 +231,7 @@ pub unsafe extern "C" fn strdup(s1: *const c_char) -> *mut c_char { } #[no_mangle] -pub unsafe extern "C" fn strndup(s1: *const c_char, size: usize) -> *mut c_char { +pub unsafe extern "C" fn strndup(s1: *const c_char, size: size_t) -> *mut c_char { let len = strnlen(s1, size); // the "+ 1" is to account for the NUL byte @@ -272,7 +272,7 @@ pub unsafe extern "C" fn strlen(s: *const c_char) -> size_t { } #[no_mangle] -pub unsafe extern "C" fn strnlen(s: *const c_char, size: usize) -> size_t { +pub unsafe extern "C" fn strnlen(s: *const c_char, size: size_t) -> size_t { let mut i = 0; while i < size { if *s.offset(i as isize) == 0 { @@ -284,7 +284,7 @@ pub unsafe extern "C" fn strnlen(s: *const c_char, size: usize) -> size_t { } #[no_mangle] -pub unsafe extern "C" fn strncat(s1: *mut c_char, s2: *const c_char, n: usize) -> *mut c_char { +pub unsafe extern "C" fn strncat(s1: *mut c_char, s2: *const c_char, n: size_t) -> *mut c_char { let mut idx = strlen(s1 as *const _) as isize; for i in 0..n as isize { if *s2.offset(i) == 0 { @@ -300,7 +300,7 @@ pub unsafe extern "C" fn strncat(s1: *mut c_char, s2: *const c_char, n: usize) - } #[no_mangle] -pub unsafe extern "C" fn strncmp(s1: *const c_char, s2: *const c_char, n: usize) -> c_int { +pub unsafe extern "C" fn strncmp(s1: *const c_char, s2: *const c_char, n: size_t) -> c_int { let s1 = core::slice::from_raw_parts(s1 as *const c_uchar, n); let s2 = core::slice::from_raw_parts(s2 as *const c_uchar, n); @@ -315,7 +315,7 @@ pub unsafe extern "C" fn strncmp(s1: *const c_char, s2: *const c_char, n: usize) } #[no_mangle] -pub unsafe extern "C" fn strncpy(dst: *mut c_char, src: *const c_char, n: usize) -> *mut c_char { +pub unsafe extern "C" fn strncpy(dst: *mut c_char, src: *const c_char, n: size_t) -> *mut c_char { let mut i = 0; while *src.offset(i) != 0 && (i as usize) < n { @@ -446,7 +446,7 @@ pub extern "C" fn strtok_r( } #[no_mangle] -pub unsafe extern "C" fn strxfrm(s1: *mut c_char, s2: *const c_char, n: usize) -> size_t { +pub unsafe extern "C" fn strxfrm(s1: *mut c_char, s2: *const c_char, n: size_t) -> size_t { // relibc has no locale stuff (yet) let len = strlen(s2); if len < n { diff --git a/src/header/sys_mman/mod.rs b/src/header/sys_mman/mod.rs index 013050a053bd119c99c07f11fa1a37d3f5f4ba54..9ff48c1faa8e1aa41f2b1e1422993f0fb32e154f 100644 --- a/src/header/sys_mman/mod.rs +++ b/src/header/sys_mman/mod.rs @@ -24,7 +24,7 @@ pub extern "C" fn mlockall(flags: c_int) -> c_int { #[no_mangle] pub unsafe extern "C" fn mmap( addr: *mut c_void, - len: usize, + len: size_t, prot: c_int, flags: c_int, fildes: c_int, @@ -54,7 +54,7 @@ pub extern "C" fn munlockall() -> c_int { } #[no_mangle] -pub unsafe extern "C" fn munmap(addr: *mut c_void, len: usize) -> c_int { +pub unsafe extern "C" fn munmap(addr: *mut c_void, len: size_t) -> c_int { Sys::munmap(addr, len) }