Skip to content

Commit 23a969e

Browse files
committed
fix v2
1 parent 340fe36 commit 23a969e

File tree

1 file changed

+66
-1
lines changed

1 file changed

+66
-1
lines changed

src/arm.rs

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
use core::intrinsics;
22

33
// 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")]
522
#[naked]
623
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
724
pub unsafe fn __aeabi_uidivmod() {
@@ -15,6 +32,23 @@ pub unsafe fn __aeabi_uidivmod() {
1532
intrinsics::unreachable();
1633
}
1734

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")]
1852
#[naked]
1953
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
2054
pub unsafe fn __aeabi_uldivmod() {
@@ -30,6 +64,20 @@ pub unsafe fn __aeabi_uldivmod() {
3064
intrinsics::unreachable();
3165
}
3266

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")]
3381
#[naked]
3482
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
3583
pub unsafe fn __aeabi_idivmod() {
@@ -42,6 +90,23 @@ pub unsafe fn __aeabi_idivmod() {
4290
intrinsics::unreachable();
4391
}
4492

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")]
45110
#[naked]
46111
#[cfg_attr(not(feature = "mangled-names"), no_mangle)]
47112
pub unsafe fn __aeabi_ldivmod() {

0 commit comments

Comments
 (0)