@@ -3,60 +3,69 @@ use core::intrinsics;
3
3
#[ cfg( feature = "mem" ) ]
4
4
use mem:: memmove;
5
5
6
- // NOTE This function and the ones below are implemented using assembly because they using a custom
7
- // calling convention which can't be implemented using a normal Rust function
6
+ // NOTE This function and the ones below are implemented using assembly
7
+ // because they using a custom calling convention which can't be implemented
8
+ // using a normal Rust function
8
9
#[ naked]
9
10
#[ cfg_attr( not( test) , no_mangle) ]
10
11
pub unsafe fn __aeabi_uidivmod ( ) {
11
- asm ! ( "push {lr}
12
- sub sp, sp, #4
13
- mov r2, sp
14
- bl __udivmodsi4
15
- ldr r1, [sp]
16
- add sp, sp, #4
17
- pop {pc}" ) ;
12
+ asm ! (
13
+ "push {lr}
14
+ sub sp, sp, #4
15
+ mov r2, sp
16
+ bl __udivmodsi4
17
+ ldr r1, [sp]
18
+ add sp, sp, #4
19
+ pop {pc}"
20
+ ) ;
18
21
intrinsics:: unreachable ( ) ;
19
22
}
20
23
21
24
#[ naked]
22
25
#[ cfg_attr( not( test) , no_mangle) ]
23
26
pub unsafe fn __aeabi_uldivmod ( ) {
24
- asm ! ( "push {r4, lr}
25
- sub sp, sp, #16
26
- add r4, sp, #8
27
- str r4, [sp]
28
- bl __udivmoddi4
29
- ldr r2, [sp, #8]
30
- ldr r3, [sp, #12]
31
- add sp, sp, #16
32
- pop {r4, pc}" ) ;
27
+ asm ! (
28
+ "push {r4, lr}
29
+ sub sp, sp, #16
30
+ add r4, sp, #8
31
+ str r4, [sp]
32
+ bl __udivmoddi4
33
+ ldr r2, [sp, #8]
34
+ ldr r3, [sp, #12]
35
+ add sp, sp, #16
36
+ pop {r4, pc}"
37
+ ) ;
33
38
intrinsics:: unreachable ( ) ;
34
39
}
35
40
36
41
#[ naked]
37
42
#[ cfg_attr( not( test) , no_mangle) ]
38
43
pub unsafe fn __aeabi_idivmod ( ) {
39
- asm ! ( "push {r0, r1, r4, lr}
40
- bl __divsi3
41
- pop {r1, r2}
42
- muls r2, r2, r0
43
- subs r1, r1, r2
44
- pop {r4, pc}" ) ;
44
+ asm ! (
45
+ "push {r0, r1, r4, lr}
46
+ bl __divsi3
47
+ pop {r1, r2}
48
+ muls r2, r2, r0
49
+ subs r1, r1, r2
50
+ pop {r4, pc}"
51
+ ) ;
45
52
intrinsics:: unreachable ( ) ;
46
53
}
47
54
48
55
#[ naked]
49
56
#[ cfg_attr( not( test) , no_mangle) ]
50
57
pub unsafe fn __aeabi_ldivmod ( ) {
51
- asm ! ( "push {r4, lr}
52
- sub sp, sp, #16
53
- add r4, sp, #8
54
- str r4, [sp]
55
- bl __divmoddi4
56
- ldr r2, [sp, #8]
57
- ldr r3, [sp, #12]
58
- add sp, sp, #16
59
- pop {r4, pc}" ) ;
58
+ asm ! (
59
+ "push {r4, lr}
60
+ sub sp, sp, #16
61
+ add r4, sp, #8
62
+ str r4, [sp]
63
+ bl __divmoddi4
64
+ ldr r2, [sp, #8]
65
+ ldr r3, [sp, #12]
66
+ add sp, sp, #16
67
+ pop {r4, pc}"
68
+ ) ;
60
69
intrinsics:: unreachable ( ) ;
61
70
}
62
71
@@ -80,7 +89,10 @@ pub extern "aapcs" fn __aeabi_fsub(a: f32, b: f32) -> f32 {
80
89
:: float:: sub:: __subsf3 ( a, b)
81
90
}
82
91
83
- #[ cfg( not( all( feature = "c" , target_arch = "arm" , not( target_os = "ios" ) , not( thumbv6m) ) ) ) ]
92
+ #[ cfg( not( all( feature = "c" ,
93
+ target_arch = "arm" ,
94
+ not( target_os = "ios" ) ,
95
+ not( thumbv6m) ) ) ) ]
84
96
#[ cfg_attr( not( test) , no_mangle) ]
85
97
pub extern "aapcs" fn __aeabi_idiv ( a : i32 , b : i32 ) -> i32 {
86
98
:: int:: sdiv:: __divsi3 ( a, b)
@@ -106,7 +118,10 @@ pub extern "aapcs" fn __aeabi_lmul(a: u64, b: u64) -> u64 {
106
118
:: int:: mul:: __muldi3 ( a, b)
107
119
}
108
120
109
- #[ cfg( not( all( feature = "c" , target_arch = "arm" , not( target_os = "ios" ) , not( thumbv6m) ) ) ) ]
121
+ #[ cfg( not( all( feature = "c" ,
122
+ target_arch = "arm" ,
123
+ not( target_os = "ios" ) ,
124
+ not( thumbv6m) ) ) ) ]
110
125
#[ cfg_attr( not( test) , no_mangle) ]
111
126
pub extern "aapcs" fn __aeabi_uidiv ( a : u32 , b : u32 ) -> u32 {
112
127
:: int:: udiv:: __udivsi3 ( a, b)
@@ -118,15 +133,8 @@ pub extern "C" fn __aeabi_ui2d(a: u32) -> f64 {
118
133
:: float:: conv:: __floatunsidf ( a)
119
134
}
120
135
121
- // TODO: These aeabi_* functions should be defined as aliases
122
- #[ cfg( not( feature = "mem" ) ) ]
123
- extern "C" {
124
- fn memcpy ( dest : * mut u8 , src : * const u8 , n : usize ) -> * mut u8 ;
125
- fn memmove ( dest : * mut u8 , src : * const u8 , n : usize ) -> * mut u8 ;
126
- fn memset ( dest : * mut u8 , c : i32 , n : usize ) -> * mut u8 ;
127
- }
128
-
129
136
// Assembly optimized memclr{,4,8} and memset{,4,8}
137
+ #[ cfg( feature = "mem" ) ]
130
138
global_asm ! ( r"
131
139
@ fn __aeabi_memclr(r0: *mut u8, r1: usize)
132
140
.global __aeabi_memclr
@@ -201,6 +209,7 @@ __aeabi_memset:
201
209
" #) ;
202
210
203
211
// Assembly optimized memcpy{,4,8}
212
+ #[ cfg( feature = "mem" ) ]
204
213
global_asm ! ( r"
205
214
@ fn __aeabi_memcpy(r0: *mut u8, r1: *const u8, r2: usize)
206
215
.global __aeabi_memcpy
@@ -243,16 +252,95 @@ __aeabi_memcpy:
243
252
2: bx lr
244
253
" #) ;
245
254
255
+ #[ cfg( not( feature = "mem" ) ) ]
256
+ extern "C" {
257
+ fn memcpy ( dest : * mut u8 , src : * const u8 , n : usize ) -> * mut u8 ;
258
+ fn memmove ( dest : * mut u8 , src : * const u8 , n : usize ) -> * mut u8 ;
259
+ fn memset ( dest : * mut u8 , c : i32 , n : usize ) -> * mut u8 ;
260
+ }
261
+
246
262
// FIXME: The `*4` and `*8` variants should be defined as aliases.
263
+ #[ cfg( not( feature = "mem" ) ) ]
264
+ #[ cfg_attr( not( test) , no_mangle) ]
265
+ pub unsafe extern "aapcs" fn __aeabi_memclr ( dest : * mut u8 , n : usize ) {
266
+ memset ( dest, 0 , n) ;
267
+ }
268
+ #[ cfg( not( feature = "mem" ) ) ]
269
+ #[ cfg_attr( not( test) , no_mangle) ]
270
+ pub unsafe extern "aapcs" fn __aeabi_memclr4 ( dest : * mut u8 , n : usize ) {
271
+ memset ( dest, 0 , n) ;
272
+ }
273
+ #[ cfg( not( feature = "mem" ) ) ]
247
274
#[ cfg_attr( not( test) , no_mangle) ]
248
- pub unsafe extern "aapcs" fn __aeabi_memmove ( dest : * mut u8 , src : * const u8 , n : usize ) {
275
+ pub unsafe extern "aapcs" fn __aeabi_memclr8 ( dest : * mut u8 , n : usize ) {
276
+ memset ( dest, 0 , n) ;
277
+ }
278
+
279
+ #[ cfg( not( feature = "mem" ) ) ]
280
+ #[ cfg_attr( not( test) , no_mangle) ]
281
+ pub unsafe extern "aapcs" fn __aeabi_memcpy (
282
+ dest : * mut u8 ,
283
+ src : * const u8 ,
284
+ n : usize ,
285
+ ) {
286
+ memcpy ( dest, src, n) ;
287
+ }
288
+ #[ cfg( not( feature = "mem" ) ) ]
289
+ #[ cfg_attr( not( test) , no_mangle) ]
290
+ pub unsafe extern "aapcs" fn __aeabi_memcpy4 (
291
+ dest : * mut u8 ,
292
+ src : * const u8 ,
293
+ n : usize ,
294
+ ) {
295
+ memcpy ( dest, src, n) ;
296
+ }
297
+ #[ cfg( not( feature = "mem" ) ) ]
298
+ #[ cfg_attr( not( test) , no_mangle) ]
299
+ pub unsafe extern "aapcs" fn __aeabi_memcpy8 (
300
+ dest : * mut u8 ,
301
+ src : * const u8 ,
302
+ n : usize ,
303
+ ) {
304
+ memcpy ( dest, src, n) ;
305
+ }
306
+
307
+ #[ cfg_attr( not( test) , no_mangle) ]
308
+ pub unsafe extern "aapcs" fn __aeabi_memmove (
309
+ dest : * mut u8 ,
310
+ src : * const u8 ,
311
+ n : usize ,
312
+ ) {
249
313
memmove ( dest, src, n) ;
250
314
}
251
315
#[ cfg_attr( not( test) , no_mangle) ]
252
- pub unsafe extern "aapcs" fn __aeabi_memmove4 ( dest : * mut u8 , src : * const u8 , n : usize ) {
316
+ pub unsafe extern "aapcs" fn __aeabi_memmove4 (
317
+ dest : * mut u8 ,
318
+ src : * const u8 ,
319
+ n : usize ,
320
+ ) {
253
321
memmove ( dest, src, n) ;
254
322
}
255
323
#[ cfg_attr( not( test) , no_mangle) ]
256
- pub unsafe extern "aapcs" fn __aeabi_memmove8 ( dest : * mut u8 , src : * const u8 , n : usize ) {
324
+ pub unsafe extern "aapcs" fn __aeabi_memmove8 (
325
+ dest : * mut u8 ,
326
+ src : * const u8 ,
327
+ n : usize ,
328
+ ) {
257
329
memmove ( dest, src, n) ;
258
330
}
331
+
332
+ #[ cfg( not( feature = "mem" ) ) ]
333
+ #[ cfg_attr( not( test) , no_mangle) ]
334
+ pub unsafe extern "aapcs" fn __aeabi_memset ( dest : * mut u8 , n : usize , c : i32 ) {
335
+ memset ( dest, c, n) ;
336
+ }
337
+ #[ cfg( not( feature = "mem" ) ) ]
338
+ #[ cfg_attr( not( test) , no_mangle) ]
339
+ pub unsafe extern "aapcs" fn __aeabi_memset4 ( dest : * mut u8 , n : usize , c : i32 ) {
340
+ memset ( dest, c, n) ;
341
+ }
342
+ #[ cfg( not( feature = "mem" ) ) ]
343
+ #[ cfg_attr( not( test) , no_mangle) ]
344
+ pub unsafe extern "aapcs" fn __aeabi_memset8 ( dest : * mut u8 , n : usize , c : i32 ) {
345
+ memset ( dest, c, n) ;
346
+ }
0 commit comments