@@ -9,19 +9,18 @@ unsafe extern "C" {
9
9
}
10
10
11
11
// SAFETY: these are defined in compiler-builtins
12
- // FIXME(extern_custom), this isn't always the correct ABI
13
- unsafe extern "aapcs" {
12
+ unsafe extern "custom" {
14
13
// AAPCS is not always the correct ABI for these intrinsics, but we only use this to
15
14
// forward another `__aeabi_` call so it doesn't matter.
16
- fn __aeabi_idiv ( a : i32 , b : i32 ) -> i32 ;
15
+ fn __aeabi_idiv ( ) ;
17
16
}
18
17
19
18
intrinsics ! {
20
19
// NOTE This function and the ones below are implemented using assembly because they are using a
21
20
// custom calling convention which can't be implemented using a normal Rust function.
22
21
#[ unsafe ( naked) ]
23
22
#[ cfg( not( target_env = "msvc" ) ) ]
24
- pub unsafe extern "C " fn __aeabi_uidivmod( ) {
23
+ pub unsafe extern "custom " fn __aeabi_uidivmod( ) {
25
24
core:: arch:: naked_asm!(
26
25
"push {{lr}}" ,
27
26
"sub sp, sp, #4" ,
@@ -35,7 +34,7 @@ intrinsics! {
35
34
}
36
35
37
36
#[ unsafe ( naked) ]
38
- pub unsafe extern "C " fn __aeabi_uldivmod( ) {
37
+ pub unsafe extern "custom " fn __aeabi_uldivmod( ) {
39
38
core:: arch:: naked_asm!(
40
39
"push {{r4, lr}}" ,
41
40
"sub sp, sp, #16" ,
@@ -51,7 +50,7 @@ intrinsics! {
51
50
}
52
51
53
52
#[ unsafe ( naked) ]
54
- pub unsafe extern "C " fn __aeabi_idivmod( ) {
53
+ pub unsafe extern "custom " fn __aeabi_idivmod( ) {
55
54
core:: arch:: naked_asm!(
56
55
"push {{r0, r1, r4, lr}}" ,
57
56
"bl {trampoline}" ,
@@ -64,7 +63,7 @@ intrinsics! {
64
63
}
65
64
66
65
#[ unsafe ( naked) ]
67
- pub unsafe extern "C " fn __aeabi_ldivmod( ) {
66
+ pub unsafe extern "custom " fn __aeabi_ldivmod( ) {
68
67
core:: arch:: naked_asm!(
69
68
"push {{r4, lr}}" ,
70
69
"sub sp, sp, #16" ,
@@ -135,8 +134,8 @@ intrinsics! {
135
134
/// eight bytes.
136
135
#[ cfg( not( target_vendor = "apple" ) ) ]
137
136
pub unsafe extern "aapcs" fn __aeabi_memcpy8( dst: * mut u8 , src: * const u8 , n: usize ) {
138
- debug_assert!( dst. addr( ) & 7 == 0 ) ;
139
- debug_assert!( src. addr( ) & 7 == 0 ) ;
137
+ debug_assert!( dst. addr( ) . is_multiple_of ( 8 ) ) ;
138
+ debug_assert!( src. addr( ) . is_multiple_of ( 8 ) ) ;
140
139
141
140
// SAFETY: memcpy preconditions apply, less strict alignment.
142
141
unsafe { __aeabi_memcpy4( dst, src, n) } ;
@@ -161,8 +160,8 @@ intrinsics! {
161
160
/// four bytes.
162
161
#[ cfg( not( any( target_vendor = "apple" , target_env = "msvc" ) ) ) ]
163
162
pub unsafe extern "aapcs" fn __aeabi_memmove4( dst: * mut u8 , src: * const u8 , n: usize ) {
164
- debug_assert!( dst. addr( ) & 3 == 0 ) ;
165
- debug_assert!( src. addr( ) & 3 == 0 ) ;
163
+ debug_assert!( dst. addr( ) . is_multiple_of ( 4 ) ) ;
164
+ debug_assert!( src. addr( ) . is_multiple_of ( 4 ) ) ;
166
165
167
166
// SAFETY: same preconditions, less strict aligment.
168
167
unsafe { __aeabi_memmove( dst, src, n) } ;
@@ -176,8 +175,8 @@ intrinsics! {
176
175
/// eight bytes.
177
176
#[ cfg( not( any( target_vendor = "apple" , target_env = "msvc" ) ) ) ]
178
177
pub unsafe extern "aapcs" fn __aeabi_memmove8( dst: * mut u8 , src: * const u8 , n: usize ) {
179
- debug_assert!( dst. addr( ) & 7 == 0 ) ;
180
- debug_assert!( src. addr( ) & 7 == 0 ) ;
178
+ debug_assert!( dst. addr( ) . is_multiple_of ( 8 ) ) ;
179
+ debug_assert!( src. addr( ) . is_multiple_of ( 8 ) ) ;
181
180
182
181
// SAFETY: memmove preconditions apply, less strict alignment.
183
182
unsafe { __aeabi_memmove( dst, src, n) } ;
@@ -236,7 +235,7 @@ intrinsics! {
236
235
/// eight bytes.
237
236
#[ cfg( not( target_vendor = "apple" ) ) ]
238
237
pub unsafe extern "aapcs" fn __aeabi_memset8( dst: * mut u8 , n: usize , c: i32 ) {
239
- debug_assert!( dst. addr( ) & 7 == 0 ) ;
238
+ debug_assert!( dst. addr( ) . is_multiple_of ( 8 ) ) ;
240
239
241
240
// SAFETY: memset preconditions apply, less strict alignment.
242
241
unsafe { __aeabi_memset4( dst, n, c) } ;
@@ -261,7 +260,7 @@ intrinsics! {
261
260
/// four bytes.
262
261
#[ cfg( not( any( target_vendor = "apple" , target_env = "msvc" ) ) ) ]
263
262
pub unsafe extern "aapcs" fn __aeabi_memclr4( dst: * mut u8 , n: usize ) {
264
- debug_assert!( dst. addr( ) & 3 == 0 ) ;
263
+ debug_assert!( dst. addr( ) . is_multiple_of ( 4 ) ) ;
265
264
266
265
// SAFETY: memclr preconditions apply, less strict alignment.
267
266
unsafe { __aeabi_memset4( dst, n, 0 ) } ;
@@ -275,7 +274,7 @@ intrinsics! {
275
274
/// eight bytes.
276
275
#[ cfg( not( any( target_vendor = "apple" , target_env = "msvc" ) ) ) ]
277
276
pub unsafe extern "aapcs" fn __aeabi_memclr8( dst: * mut u8 , n: usize ) {
278
- debug_assert!( dst. addr( ) & 7 == 0 ) ;
277
+ debug_assert!( dst. addr( ) . is_multiple_of ( 8 ) ) ;
279
278
280
279
// SAFETY: memclr preconditions apply, less strict alignment.
281
280
unsafe { __aeabi_memset4( dst, n, 0 ) } ;
0 commit comments