Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ rely on CI.
- [x] arm/aeabi_memset.S
- [x] arm/aeabi_uidivmod.S
- [x] arm/aeabi_uldivmod.S
- [ ] arm/chkstk.S
- [x] arm/chkstk.S
- [ ] arm/divmodsi4.S (generic version is done)
- [ ] arm/divsi3.S (generic version is done)
- [ ] arm/modsi3.S (generic version is done)
Expand Down
21 changes: 21 additions & 0 deletions compiler-builtins/src/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,25 @@ intrinsics! {
pub unsafe extern "aapcs" fn __aeabi_memclr8(dest: *mut u8, n: usize) {
__aeabi_memset4(dest, n, 0);
}

// NOTE This function is implemented using assembly because they are using
// a custom calling convention
#[naked]
#[cfg(all(target_env = "msvc", not(feature = "no-asm")))]
pub unsafe extern "C" fn __chkstk() {
core::arch::naked_asm!(
".p2align 2",
"lsl r4, r4, #2",
"mov r12, sp",
"push {{ r5, r6 }}",
"mov r5, r4",
"1:",
"sub r12, r12, 4096",
"subs r5, r5, 4096",
"ldr r6, [r12]",
"bgt 1b",
"pop {{ r5, r6 }}",
"bx lr",
);
}
}
Loading