Skip to content

Commit 3d07d3a

Browse files
Change memcmp and bcmp return type to c_int
1 parent 59b329a commit 3d07d3a

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

compiler-builtins/src/mem/impls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,13 +384,13 @@ pub unsafe fn set_bytes(mut s: *mut u8, c: u8, mut n: usize) {
384384
}
385385

386386
#[inline(always)]
387-
pub unsafe fn compare_bytes(s1: *const u8, s2: *const u8, n: usize) -> i32 {
387+
pub unsafe fn compare_bytes(s1: *const u8, s2: *const u8, n: usize) -> crate::mem::c_int {
388388
let mut i = 0;
389389
while i < n {
390390
let a = *s1.wrapping_add(i);
391391
let b = *s2.wrapping_add(i);
392392
if a != b {
393-
return a as i32 - b as i32;
393+
return a as crate::mem::c_int - b as crate::mem::c_int;
394394
}
395395
i += 1;
396396
}

compiler-builtins/src/mem/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ intrinsics! {
4444
}
4545

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

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

0 commit comments

Comments
 (0)