require '_h2ph_pre.ph';

no warnings qw(redefine misc);

eval 'sub _MCOUNT_DECL () { &void  &_mcount;}' unless defined(&_MCOUNT_DECL);
eval 'sub MCOUNT_ASM_NAME () {"__mcount";}' unless defined(&MCOUNT_ASM_NAME);
eval 'sub PLTSYM () {1;}' unless defined(&PLTSYM);
if(!defined(&__ARM_EABI__)) {
    eval 'sub MCOUNT () { &__asm(".text");  &__asm(".align	0");  &__asm(".arm");  &__asm(".type	"  &MCOUNT_ASM_NAME ",%function");  &__asm(".global	"  &MCOUNT_ASM_NAME);  &__asm( &MCOUNT_ASM_NAME ":");  &__asm("push	{r0-r3, ip, lr}");  &__asm("teq	r0, r0");  &__asm("teq	pc, r15");  &__asm("moveq	r0, ip");  &__asm("bicne	r0, ip, #0xfc000003");  &__asm("moveq	r1, lr");  &__asm("bicne	r1, lr, #0xfc000003");  &__asm("bl	"  &___STRING( &_C_LABEL( &_mcount))  &PLTSYM);  &__asm("pop	{r0-r3, lr}");  &__asm("pop	{pc}");  &__asm(".size	"  &MCOUNT_ASM_NAME ", .-"  &MCOUNT_ASM_NAME);;}' unless defined(&MCOUNT);
}
 elsif(defined(&__ARM_DWARF_EH__)) {
    eval 'sub MCOUNT () { &__asm(".text");  &__asm(".align	0");  &__asm(".arm");  &__asm(".type	"  &MCOUNT_ASM_NAME ",%function");  &__asm(".global	"  &MCOUNT_ASM_NAME);  &__asm( &MCOUNT_ASM_NAME ":");  &__asm(".cfi_startproc");  &__asm("push	{r0-r3, ip, lr}");  &__asm(".cfi_def_cfa_offset 24");  &__asm(".cfi_offset 14, -4");  &__asm(".cfi_offset 12, -8");  &__asm(".cfi_offset 3, -12");  &__asm(".cfi_offset 2, -16");  &__asm(".cfi_offset 1, -20");  &__asm(".cfi_offset 0, -24");  &__asm("mov	r0, ip");  &__asm("mov	r1, lr");  &__asm("bl	"  &___STRING( &_C_LABEL( &_mcount))  &PLTSYM);  &__asm("pop	{r0-r3, lr}");  &__asm("pop	{pc}");  &__asm(".cfi_endproc");  &__asm(".size	"  &MCOUNT_ASM_NAME ", .-"  &MCOUNT_ASM_NAME);;}' unless defined(&MCOUNT);
} else {
    eval 'sub MCOUNT () { &__asm(".text");  &__asm(".align	0");  &__asm(".arm");  &__asm(".type	"  &MCOUNT_ASM_NAME ",%function");  &__asm(".global	"  &MCOUNT_ASM_NAME);  &__asm( &MCOUNT_ASM_NAME ":");  &__asm(".fnstart");  &__asm(".cfi_startproc");  &__asm("push	{r0-r3, ip, lr}");  &__asm(".save {r0-r3, lr}");  &__asm(".cfi_def_cfa_offset 24");  &__asm(".cfi_offset 14, -4");  &__asm(".cfi_offset 12, -8");  &__asm(".cfi_offset 3, -12");  &__asm(".cfi_offset 2, -16");  &__asm(".cfi_offset 1, -20");  &__asm(".cfi_offset 0, -24");  &__asm("mov	r0, ip");  &__asm("mov	r1, lr");  &__asm("bl	"  &___STRING( &_C_LABEL( &_mcount))  &PLTSYM);  &__asm("pop	{r0-r3, lr}");  &__asm("pop	{pc}");  &__asm(".cfi_endproc");  &__asm(".fnend");  &__asm(".size	"  &MCOUNT_ASM_NAME ", .-"  &MCOUNT_ASM_NAME);;}' unless defined(&MCOUNT);
}
if(defined(&_KERNEL)) {
    require 'arm/cpufunc.ph';
    eval 'sub MCOUNT_ENTER () { &s =  &__set_cpsr_c(0x80, 0x80);;}' unless defined(&MCOUNT_ENTER);
    eval 'sub MCOUNT_EXIT () { &__set_cpsr_c(0xffffffff,  &s);;}' unless defined(&MCOUNT_EXIT);
}
1;
