]>
git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/src/x86.rs
1 #![allow(unused_imports)]
5 // NOTE These functions are implemented using assembly because they using a custom
6 // calling convention which can't be implemented using a normal Rust function
8 // NOTE These functions are never mangled as they are not tested against compiler-rt
9 // and mangling ___chkstk would break the `jmp ___chkstk` instruction in __alloca
11 #[cfg(all(windows, target_env = "gnu", not(feature = "mangled-names")))]
14 pub unsafe fn ___chkstk_ms() {
32 ret" ::: "memory" : "volatile");
33 intrinsics
::unreachable();
36 // FIXME: __alloca should be an alias to __chkstk
37 #[cfg(all(windows, target_env = "gnu", not(feature = "mangled-names")))]
40 pub unsafe fn __alloca() {
41 asm
!("jmp ___chkstk // Jump to ___chkstk since fallthrough may be unreliable"
42 ::: "memory" : "volatile");
43 intrinsics
::unreachable();
46 #[cfg(all(windows, target_env = "gnu", not(feature = "mangled-names")))]
49 pub unsafe fn ___chkstk() {
53 lea 8(%esp),%ecx // esp before calling this routine -> ecx
65 lea 4(%esp),%eax // load pointer to the return address into eax
66 mov %ecx,%esp // install the new top of stack pointer into esp
67 mov -4(%eax),%ecx // restore ecx
68 push (%eax) // push return address onto the stack
69 sub %esp,%eax // restore the original value in eax
70 ret" ::: "memory" : "volatile");
71 intrinsics
::unreachable();