1
1
use core:: intrinsics;
2
2
3
3
// NOTE This function and the ones below are implemented using assembly because they using a custom
4
- // calling convention which can't be implemented using a normal Rust function
4
+ // calling convention which can't be implemented using a normal Rust function.
5
+ // NOTE The only difference between the iOS and non-iOS versions of those functions is that the iOS
6
+ // versions use 3 leading underscores in the names of called functions instead of 2.
7
+ #[ cfg( not( target_os = "ios" ) ) ]
8
+ #[ naked]
9
+ #[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
10
+ 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}" :: : "memory" : "volatile" ) ;
18
+ intrinsics:: unreachable ( ) ;
19
+ }
20
+
21
+ #[ cfg( target_os = "ios" ) ]
5
22
#[ naked]
6
23
#[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
7
24
pub unsafe fn __aeabi_uidivmod ( ) {
@@ -15,6 +32,23 @@ pub unsafe fn __aeabi_uidivmod() {
15
32
intrinsics:: unreachable ( ) ;
16
33
}
17
34
35
+ #[ cfg( not( target_os = "ios" ) ) ]
36
+ #[ naked]
37
+ #[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
38
+ pub unsafe fn __aeabi_uldivmod ( ) {
39
+ asm ! ( "push {r4, lr}
40
+ sub sp, sp, #16
41
+ add r4, sp, #8
42
+ str r4, [sp]
43
+ bl __udivmoddi4
44
+ ldr r2, [sp, #8]
45
+ ldr r3, [sp, #12]
46
+ add sp, sp, #16
47
+ pop {r4, pc}" :: : "memory" : "volatile" ) ;
48
+ intrinsics:: unreachable ( ) ;
49
+ }
50
+
51
+ #[ cfg( target_os = "ios" ) ]
18
52
#[ naked]
19
53
#[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
20
54
pub unsafe fn __aeabi_uldivmod ( ) {
@@ -30,6 +64,20 @@ pub unsafe fn __aeabi_uldivmod() {
30
64
intrinsics:: unreachable ( ) ;
31
65
}
32
66
67
+ #[ cfg( not( target_os = "ios" ) ) ]
68
+ #[ naked]
69
+ #[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
70
+ pub unsafe fn __aeabi_idivmod ( ) {
71
+ asm ! ( "push {r0, r1, r4, lr}
72
+ bl __aeabi_idiv
73
+ pop {r1, r2}
74
+ muls r2, r2, r0
75
+ subs r1, r1, r2
76
+ pop {r4, pc}" :: : "memory" : "volatile" ) ;
77
+ intrinsics:: unreachable ( ) ;
78
+ }
79
+
80
+ #[ cfg( target_os = "ios" ) ]
33
81
#[ naked]
34
82
#[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
35
83
pub unsafe fn __aeabi_idivmod ( ) {
@@ -42,6 +90,23 @@ pub unsafe fn __aeabi_idivmod() {
42
90
intrinsics:: unreachable ( ) ;
43
91
}
44
92
93
+ #[ cfg( not( target_os = "ios" ) ) ]
94
+ #[ naked]
95
+ #[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
96
+ pub unsafe fn __aeabi_ldivmod ( ) {
97
+ asm ! ( "push {r4, lr}
98
+ sub sp, sp, #16
99
+ add r4, sp, #8
100
+ str r4, [sp]
101
+ bl __divmoddi4
102
+ ldr r2, [sp, #8]
103
+ ldr r3, [sp, #12]
104
+ add sp, sp, #16
105
+ pop {r4, pc}" :: : "memory" : "volatile" ) ;
106
+ intrinsics:: unreachable ( ) ;
107
+ }
108
+
109
+ #[ cfg( target_os = "ios" ) ]
45
110
#[ naked]
46
111
#[ cfg_attr( not( feature = "mangled-names" ) , no_mangle) ]
47
112
pub unsafe fn __aeabi_ldivmod ( ) {
0 commit comments