-
Notifications
You must be signed in to change notification settings - Fork 255
Change memcmp and bcmp return type to c_int #980
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
Conversation
compiler-builtins/src/mem/impls.rs
Outdated
|
|
||
| #[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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you import core::ffi::c_int and use c_int here instead?
I didn't even realize we had crate::mem::c_int, I'll probably remove that to just use core::ffi instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes in compiler-builtins/src/mem/mod.rs still need a full path core::ffi::c_int though, unfortunately the macro makes imports a bit weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't even realize we had
crate::mem::c_int, I'll probably remove that to just usecore::ffiinstead.
Doing this here #981
compiler-builtins/src/mem/impls.rs
Outdated
| 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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return a as crate::mem::c_int - b as crate::mem::c_int; | |
| return crate::mem::c_int::from(a) - crate::mem::c_int::from(b); |
To make it clearer the conversions are lossless.
|
Ouuups pushed too early, I will do the other changes. |
|
Should I revert my change for the |
67a6e90 to
c6af92d
Compare
|
No need, it figured things out with a rebase. One nit though, in compiler-builtins/src/mem/impls.rs could you import Sorry, should have noticed before doing the rebase |
tgross35
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for the fix!
This PR fix the return type of
memcmpandbcmpbuiltin function on target with apointer_widthequals to 16.Linked issue: rust-lang/rust#144076