mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 19:21:38 +00:00
[CRT]
- Make all x86assembly ML compatible - Remove memcpy, it was duplicated from memmove, copy the label instead - Guard some code against compilation on msvc, as these functions are intrinsics on MSVC and cannot be implemented - Fix some x64 assembly (don't modify stack below rsp) svn path=/branches/cmake-bringup/; revision=49421
This commit is contained in:
parent
0d7a1c46a0
commit
a3623f23de
49 changed files with 912 additions and 918 deletions
|
@ -7,8 +7,13 @@
|
|||
* PROGRAMER: KJK::Hyperion <noog@libero.it>
|
||||
*/
|
||||
|
||||
.globl __chkstk
|
||||
.globl __alloca_probe
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/asm.h>
|
||||
#define PAGE_SIZE 4096
|
||||
|
||||
PUBLIC __chkstk
|
||||
PUBLIC __alloca_probe
|
||||
.code
|
||||
|
||||
/*
|
||||
_chkstk() is called by all stack allocations of more than 4 KB. It grows the
|
||||
|
@ -18,49 +23,50 @@
|
|||
__chkstk:
|
||||
__alloca_probe:
|
||||
|
||||
/* EAX = size to be allocated */
|
||||
/* save the ECX register */
|
||||
pushl %ecx
|
||||
/* EAX = size to be allocated */
|
||||
/* save the ECX register */
|
||||
push ecx
|
||||
|
||||
/* ECX = top of the previous stack frame */
|
||||
leal 8(%esp), %ecx
|
||||
/* ECX = top of the previous stack frame */
|
||||
lea eax, [esp + 8]
|
||||
|
||||
/* probe the desired memory, page by page */
|
||||
cmpl $0x1000, %eax
|
||||
jge .l_MoreThanAPage
|
||||
jmp .l_LessThanAPage
|
||||
/* probe the desired memory, page by page */
|
||||
cmp eax, PAGE_SIZE
|
||||
jge .l_MoreThanAPage
|
||||
jmp .l_LessThanAPage
|
||||
|
||||
.l_MoreThanAPage:
|
||||
|
||||
/* raise the top of the stack by a page and probe */
|
||||
subl $0x1000, %ecx
|
||||
testl %eax, 0(%ecx)
|
||||
/* raise the top of the stack by a page and probe */
|
||||
sub ecx, PAGE_SIZE
|
||||
test [ecx], eax
|
||||
|
||||
/* loop if still more than a page must be probed */
|
||||
subl $0x1000, %eax
|
||||
cmpl $0x1000, %eax
|
||||
jge .l_MoreThanAPage
|
||||
/* loop if still more than a page must be probed */
|
||||
sub eax, PAGE_SIZE
|
||||
cmp eax, PAGE_SIZE
|
||||
jge .l_MoreThanAPage
|
||||
|
||||
.l_LessThanAPage:
|
||||
|
||||
/* raise the top of the stack by EAX bytes (size % 4096) and probe */
|
||||
subl %eax, %ecx
|
||||
testl %eax, 0(%ecx)
|
||||
/* raise the top of the stack by EAX bytes (size % 4096) and probe */
|
||||
sub ecx, eax
|
||||
test [ecx], eax
|
||||
|
||||
/* EAX = top of the stack */
|
||||
movl %esp, %eax
|
||||
/* EAX = top of the stack */
|
||||
mov eax, esp
|
||||
|
||||
/* allocate the memory */
|
||||
movl %ecx, %esp
|
||||
/* allocate the memory */
|
||||
mov esp, ecx
|
||||
|
||||
/* restore ECX */
|
||||
movl 0(%eax), %ecx
|
||||
/* restore ECX */
|
||||
mov ecx, [eax]
|
||||
|
||||
/* restore the return address */
|
||||
movl 4(%eax), %eax
|
||||
pushl %eax
|
||||
/* restore the return address */
|
||||
mov eax, [eax + 4]
|
||||
push eax
|
||||
|
||||
/* return */
|
||||
ret
|
||||
/* return */
|
||||
ret
|
||||
|
||||
/* EOF */
|
||||
END
|
||||
|
|
|
@ -8,24 +8,26 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <reactos/asm.h>
|
||||
#include <ndk/asm.h>
|
||||
.intel_syntax noprefix
|
||||
|
||||
#define DISPOSITION_DISMISS 0
|
||||
#define DISPOSITION_CONTINUE_SEARCH 1
|
||||
#define DISPOSITION_COLLIDED_UNWIND 3
|
||||
|
||||
EXTERN _RtlUnwind@16:PROC
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
.globl __global_unwind2
|
||||
.globl __local_unwind2
|
||||
.globl __abnormal_termination
|
||||
.globl __except_handler2
|
||||
.globl __except_handler3
|
||||
PUBLIC __global_unwind2
|
||||
PUBLIC __local_unwind2
|
||||
PUBLIC __abnormal_termination
|
||||
PUBLIC __except_handler2
|
||||
PUBLIC __except_handler3
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
.func unwind_handler
|
||||
.code
|
||||
_unwind_handler:
|
||||
|
||||
/* Check if we were unwinding and continue search if not */
|
||||
|
@ -56,9 +58,8 @@ _unwind_handler:
|
|||
|
||||
unwind_handler_return:
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _global_unwind2
|
||||
|
||||
__global_unwind2:
|
||||
|
||||
/* Create stack and save all registers */
|
||||
|
@ -85,9 +86,8 @@ glu_return:
|
|||
mov esp, ebp
|
||||
pop ebp
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _abnormal_termination
|
||||
|
||||
__abnormal_termination:
|
||||
|
||||
/* Assume false */
|
||||
|
@ -112,9 +112,8 @@ __abnormal_termination:
|
|||
/* Return */
|
||||
ab_return:
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _local_unwind2
|
||||
|
||||
__local_unwind2:
|
||||
|
||||
/* Save volatiles */
|
||||
|
@ -175,9 +174,8 @@ unwind_return:
|
|||
pop esi
|
||||
pop ebx
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _except_handler2
|
||||
|
||||
__except_handler2:
|
||||
|
||||
/* Setup stack and save volatiles */
|
||||
|
@ -256,7 +254,7 @@ except_loop2:
|
|||
mov [ebx+12], eax
|
||||
|
||||
/* Call except handler */
|
||||
call [edi+ecx*4+8]
|
||||
call dword ptr [edi+ecx*4+8]
|
||||
|
||||
except_continue2:
|
||||
/* Reload try level and except again */
|
||||
|
@ -297,9 +295,8 @@ except_return2:
|
|||
mov esp, ebp
|
||||
pop ebp
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
.func _except_handler3
|
||||
|
||||
__except_handler3:
|
||||
|
||||
/* Setup stack and save volatiles */
|
||||
|
@ -437,4 +434,5 @@ except_return3:
|
|||
mov esp, ebp
|
||||
pop ebp
|
||||
ret
|
||||
.endfunc
|
||||
|
||||
END
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue