Skip to content

Commit 7ac5155

Browse files
author
Jorge Aparicio
authored
Merge pull request #30 from Amanieu/various
Various changes
2 parents d546f18 + acceaa9 commit 7ac5155

File tree

8 files changed

+568
-466
lines changed

8 files changed

+568
-466
lines changed

README.md

+33-29
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ See [rust-lang/rust#35437][0].
3737
- [x] arm/aeabi_memcpy.S
3838
- [x] arm/aeabi_memmove.S
3939
- [x] arm/aeabi_memset.S
40-
- [ ] arm/aeabi_uidivmod.S
41-
- [ ] arm/aeabi_uldivmod.S
40+
- [x] arm/aeabi_uidivmod.S
41+
- [x] arm/aeabi_uldivmod.S
4242
- [ ] arm/divdf3vfp.S
4343
- [ ] arm/divmodsi4.S
4444
- [ ] arm/divsf3vfp.S
@@ -78,41 +78,30 @@ See [rust-lang/rust#35437][0].
7878
- [ ] arm/umodsi3.S
7979
- [ ] arm/unorddf2vfp.S
8080
- [ ] arm/unordsf2vfp.S
81-
- [ ] ashldi3.c
82-
- [ ] ashlti3.c
83-
- [ ] ashrdi3.c
84-
- [ ] ashrti3.c
81+
- [x] ashldi3.c
82+
- [x] ashrdi3.c
8583
- [ ] divdf3.c
8684
- [ ] divdi3.c
8785
- [ ] divsf3.c
8886
- [ ] divsi3.c
89-
- [ ] divti3.c
9087
- [ ] extendhfsf2.c
9188
- [ ] extendsfdf2.c
9289
- [ ] fixdfdi.c
9390
- [ ] fixdfsi.c
94-
- [ ] fixdfti.c
9591
- [ ] fixsfdi.c
9692
- [ ] fixsfsi.c
97-
- [ ] fixsfti.c
9893
- [ ] fixunsdfdi.c
9994
- [ ] fixunsdfsi.c
100-
- [ ] fixunsdfti.c
10195
- [ ] fixunssfdi.c
10296
- [ ] fixunssfsi.c
103-
- [ ] fixunssfti.c
10497
- [ ] floatdidf.c
10598
- [ ] floatdisf.c
10699
- [ ] floatsidf.c
107100
- [ ] floatsisf.c
108-
- [ ] floattidf.c
109-
- [ ] floattisf.c
110101
- [ ] floatundidf.c
111102
- [ ] floatundisf.c
112103
- [ ] floatunsidf.c
113104
- [ ] floatunsisf.c
114-
- [ ] floatuntidf.c
115-
- [ ] floatuntisf.c
116105
- [ ] i386/ashldi3.S
117106
- [ ] i386/ashrdi3.S
118107
- [ ] i386/chkstk.S
@@ -123,36 +112,51 @@ See [rust-lang/rust#35437][0].
123112
- [ ] i386/muldi3.S
124113
- [ ] i386/udivdi3.S
125114
- [ ] i386/umoddi3.S
126-
- [ ] lshrdi3.c
127-
- [ ] lshrti3.c
115+
- [x] lshrdi3.c
128116
- [ ] moddi3.c
129117
- [ ] modsi3.c
130-
- [ ] modti3.c
131118
- [ ] muldf3.c
132-
- [ ] muldi3.c
133-
- [ ] mulodi4.c
134-
- [ ] mulosi4.c
135-
- [ ] muloti4.c
119+
- [x] muldi3.c
120+
- [x] mulodi4.c
121+
- [x] mulosi4.c
136122
- [ ] mulsf3.c
137-
- [ ] multi3.c
138123
- [ ] powidf2.c
139124
- [ ] powisf2.c
140125
- [ ] subdf3.c
141126
- [ ] subsf3.c
142127
- [ ] truncdfhf2.c
143128
- [ ] truncdfsf2.c
144129
- [ ] truncsfhf2.c
145-
- [ ] udivdi3.c
130+
- [x] udivdi3.c
146131
- [x] udivmoddi4.c
147132
- [x] udivmodsi4.c
148-
- [ ] udivsi3.c
149-
- [ ] udivti3.c
150-
- [ ] umoddi3.c
151-
- [ ] umodsi3.c
152-
- [ ] umodti3.c
133+
- [x] udivsi3.c
134+
- [x] umoddi3.c
135+
- [x] umodsi3.c
153136
- [ ] x86_64/chkstk.S
154137
- [ ] x86_64/chkstk2.S
155138

139+
These builtins are needed to support 128-bit integers, which are in the process of being added to Rust.
140+
141+
- [ ] ashlti3.c
142+
- [ ] ashrti3.c
143+
- [ ] divti3.c
144+
- [ ] fixdfti.c
145+
- [ ] fixsfti.c
146+
- [ ] fixunsdfti.c
147+
- [ ] fixunssfti.c
148+
- [ ] floattidf.c
149+
- [ ] floattisf.c
150+
- [ ] floatuntidf.c
151+
- [ ] floatuntisf.c
152+
- [ ] lshrti3.c
153+
- [ ] modti3.c
154+
- [ ] muloti4.c
155+
- [ ] multi3.c
156+
- [ ] udivmodti4.c
157+
- [ ] udivti3.c
158+
- [ ] umodti3.c
159+
156160
## Unimplemented functions
157161

158162
These builtins involve floating-point types ("`f128`", "`f80`" and complex numbers) that are not supported by Rust.

src/arm.rs

+41-46
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,28 @@ use core::intrinsics;
22

33
// NOTE This function and the one below are implemented using assembly because they using a custom
44
// calling convention which can't be implemented using a normal Rust function
5-
// TODO use `global_asm!`
65
#[naked]
7-
#[no_mangle]
8-
pub unsafe extern "aapcs" fn __aeabi_uidivmod() {
9-
asm!("push { lr }
10-
sub sp, sp, #4
11-
mov r2, sp
12-
bl __udivmodsi4
13-
ldr r1, [sp]
14-
add sp, sp, #4
15-
pop { pc }");
6+
#[cfg_attr(not(test), no_mangle)]
7+
pub unsafe fn __aeabi_uidivmod() {
8+
asm!("push {lr}
9+
sub sp, sp, #4
10+
mov r2, sp
11+
bl __udivmodsi4
12+
ldr r1, [sp], #4
13+
pop {pc}");
1614
intrinsics::unreachable();
1715
}
1816

19-
// TODO use `global_asm!`
2017
#[naked]
21-
#[no_mangle]
22-
pub unsafe extern "aapcs" fn __aeabi_uldivmod() {
23-
asm!("push {r11, lr}
24-
sub sp, sp, #16
25-
add r12, sp, #8
26-
str r12, [sp]
27-
bl __udivmoddi4
28-
ldr r2, [sp, #8]
29-
ldr r3, [sp, #12]
30-
add sp, sp, #16
31-
pop {r11, pc}");
18+
#[cfg_attr(not(test), no_mangle)]
19+
pub unsafe fn __aeabi_uldivmod() {
20+
asm!("push {lr}
21+
sub r12, sp, #12
22+
str r12, [sp, #-20]!
23+
bl __udivmoddi4
24+
ldrd r2, r3, [sp, #8]
25+
add sp, sp, #20
26+
pop {pc}");
3227
intrinsics::unreachable();
3328
}
3429

@@ -40,55 +35,55 @@ extern "C" {
4035

4136
// FIXME: The `*4` and `*8` variants should be defined as aliases.
4237

43-
#[no_mangle]
44-
pub unsafe extern "aapcs" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, n: usize) {
38+
#[cfg_attr(not(test), no_mangle)]
39+
pub unsafe extern "C" fn __aeabi_memcpy(dest: *mut u8, src: *const u8, n: usize) {
4540
memcpy(dest, src, n);
4641
}
47-
#[no_mangle]
48-
pub unsafe extern "aapcs" fn __aeabi_memcpy4(dest: *mut u8, src: *const u8, n: usize) {
42+
#[cfg_attr(not(test), no_mangle)]
43+
pub unsafe extern "C" fn __aeabi_memcpy4(dest: *mut u8, src: *const u8, n: usize) {
4944
memcpy(dest, src, n);
5045
}
51-
#[no_mangle]
52-
pub unsafe extern "aapcs" fn __aeabi_memcpy8(dest: *mut u8, src: *const u8, n: usize) {
46+
#[cfg_attr(not(test), no_mangle)]
47+
pub unsafe extern "C" fn __aeabi_memcpy8(dest: *mut u8, src: *const u8, n: usize) {
5348
memcpy(dest, src, n);
5449
}
5550

56-
#[no_mangle]
57-
pub unsafe extern "aapcs" fn __aeabi_memmove(dest: *mut u8, src: *const u8, n: usize) {
51+
#[cfg_attr(not(test), no_mangle)]
52+
pub unsafe extern "C" fn __aeabi_memmove(dest: *mut u8, src: *const u8, n: usize) {
5853
memmove(dest, src, n);
5954
}
60-
#[no_mangle]
61-
pub unsafe extern "aapcs" fn __aeabi_memmove4(dest: *mut u8, src: *const u8, n: usize) {
55+
#[cfg_attr(not(test), no_mangle)]
56+
pub unsafe extern "C" fn __aeabi_memmove4(dest: *mut u8, src: *const u8, n: usize) {
6257
memmove(dest, src, n);
6358
}
64-
#[no_mangle]
65-
pub unsafe extern "aapcs" fn __aeabi_memmove8(dest: *mut u8, src: *const u8, n: usize) {
59+
#[cfg_attr(not(test), no_mangle)]
60+
pub unsafe extern "C" fn __aeabi_memmove8(dest: *mut u8, src: *const u8, n: usize) {
6661
memmove(dest, src, n);
6762
}
6863

6964
// Note the different argument order
70-
#[no_mangle]
71-
pub unsafe extern "aapcs" fn __aeabi_memset(dest: *mut u8, n: usize, c: i32) {
65+
#[cfg_attr(not(test), no_mangle)]
66+
pub unsafe extern "C" fn __aeabi_memset(dest: *mut u8, n: usize, c: i32) {
7267
memset(dest, c, n);
7368
}
74-
#[no_mangle]
75-
pub unsafe extern "aapcs" fn __aeabi_memset4(dest: *mut u8, n: usize, c: i32) {
69+
#[cfg_attr(not(test), no_mangle)]
70+
pub unsafe extern "C" fn __aeabi_memset4(dest: *mut u8, n: usize, c: i32) {
7671
memset(dest, c, n);
7772
}
78-
#[no_mangle]
79-
pub unsafe extern "aapcs" fn __aeabi_memset8(dest: *mut u8, n: usize, c: i32) {
73+
#[cfg_attr(not(test), no_mangle)]
74+
pub unsafe extern "C" fn __aeabi_memset8(dest: *mut u8, n: usize, c: i32) {
8075
memset(dest, c, n);
8176
}
8277

83-
#[no_mangle]
84-
pub unsafe extern "aapcs" fn __aeabi_memclr(dest: *mut u8, n: usize) {
78+
#[cfg_attr(not(test), no_mangle)]
79+
pub unsafe extern "C" fn __aeabi_memclr(dest: *mut u8, n: usize) {
8580
memset(dest, 0, n);
8681
}
87-
#[no_mangle]
88-
pub unsafe extern "aapcs" fn __aeabi_memclr4(dest: *mut u8, n: usize) {
82+
#[cfg_attr(not(test), no_mangle)]
83+
pub unsafe extern "C" fn __aeabi_memclr4(dest: *mut u8, n: usize) {
8984
memset(dest, 0, n);
9085
}
91-
#[no_mangle]
92-
pub unsafe extern "aapcs" fn __aeabi_memclr8(dest: *mut u8, n: usize) {
86+
#[cfg_attr(not(test), no_mangle)]
87+
pub unsafe extern "C" fn __aeabi_memclr8(dest: *mut u8, n: usize) {
9388
memset(dest, 0, n);
9489
}

0 commit comments

Comments
 (0)