Skip to content

Change memcmp and bcmp return type to c_int #144141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/compiler-builtins/compiler-builtins/src/mem/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,13 @@ pub unsafe fn set_bytes(mut s: *mut u8, c: u8, mut n: usize) {
}

#[inline(always)]
pub unsafe fn compare_bytes(s1: *const u8, s2: *const u8, n: usize) -> i32 {
pub unsafe fn compare_bytes(s1: *const u8, s2: *const u8, n: usize) -> crate::mem::c_int {
let mut i = 0;
while i < n {
let a = *s1.wrapping_add(i);
let b = *s2.wrapping_add(i);
if a != b {
return a as i32 - b as i32;
return a as crate::mem::c_int - b as crate::mem::c_int;
}
i += 1;
}
Expand Down
4 changes: 2 additions & 2 deletions library/compiler-builtins/compiler-builtins/src/mem/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ intrinsics! {
}

#[mem_builtin]
pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 {
pub unsafe extern "C" fn memcmp(s1: *const u8, s2: *const u8, n: usize) -> crate::mem::c_int {
impls::compare_bytes(s1, s2, n)
}

#[mem_builtin]
pub unsafe extern "C" fn bcmp(s1: *const u8, s2: *const u8, n: usize) -> i32 {
pub unsafe extern "C" fn bcmp(s1: *const u8, s2: *const u8, n: usize) -> crate::mem::c_int {
memcmp(s1, s2, n)
}

Expand Down
Loading