Blame src/process/nt32/tt_fork_v1_i386.c

dd89bb
/********************************************************/
dd89bb
/*  ntapi: Native API core library                      */
dd89bb
/*  Copyright (C) 2013,2014,2015  Z. Gilboa             */
dd89bb
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
dd89bb
/********************************************************/
dd89bb
dd89bb
#include <psxtypes/psxtypes.h>
dd89bb
dd89bb
#if (__COMPILER__ == __MSVC__) && defined(__X86_MODEL)
dd89bb
dd89bb
intptr_t __fastcall __tt_fork_impl(
dd89bb
	__in	uintptr_t	saved_regs_stack_pointer,
dd89bb
	__in	uintptr_t	stack_adjustment);
dd89bb
dd89bb
int32_t __declspec(naked) __cdecl __tt_fork(void)
dd89bb
{
dd89bb
	__asm {
dd89bb
		push	ebp
dd89bb
		mov	ebp, esp
dd89bb
dd89bb
		push	ecx
dd89bb
		push	edx
dd89bb
		push	ebx
dd89bb
		push	esi
dd89bb
		push	edi
dd89bb
dd89bb
		mov	ecx, esp
dd89bb
		call	__tt_fork_impl
dd89bb
dd89bb
		pop	edi
dd89bb
		pop	esi
dd89bb
		pop	ebx
dd89bb
		pop	edx
dd89bb
		pop	ecx
dd89bb
dd89bb
		mov	esp, ebp
dd89bb
		pop	ebp
dd89bb
		ret
dd89bb
	};
dd89bb
}
dd89bb
dd89bb
void __declspec(naked) __fastcall __tt_fork_child_entry_point(uintptr_t esp_saved)
dd89bb
{
dd89bb
	__asm {
dd89bb
		xor	eax, eax
dd89bb
		mov	esp, ecx
dd89bb
dd89bb
		pop	edi
dd89bb
		pop	esi
dd89bb
		pop	ebx
dd89bb
		pop	edx
dd89bb
		pop	ecx
dd89bb
dd89bb
		pop	ebp
dd89bb
		ret
dd89bb
	};
dd89bb
}
dd89bb
dd89bb
void __declspec(naked) __fastcall __tt_fork_child_entry_point_adj(uintptr_t esp_saved)
dd89bb
{
dd89bb
	__asm {
dd89bb
		jmp	__tt_fork_child_entry_point
dd89bb
	};
dd89bb
}
dd89bb
dd89bb
#endif