require '_h2ph_pre.ph';

no warnings qw(redefine misc);

if(defined(&__aarch64__)) {
    eval 'sub _MCOUNT_DECL () { &void  &mcount;}' unless defined(&_MCOUNT_DECL);
    eval 'sub MCOUNT_ASM_NAME () {"_mcount";}' unless defined(&MCOUNT_ASM_NAME);
    eval 'sub MCOUNT_ASM_NAME_ALIAS () {"__mcount";}' unless defined(&MCOUNT_ASM_NAME_ALIAS);
    eval 'sub PLTSYM () {1;}' unless defined(&PLTSYM);
    eval 'sub MCOUNT () { &__asm(".text");  &__asm(".align	6");  &__asm(".type	"  &MCOUNT_ASM_NAME ",@function");  &__asm(".global	"  &MCOUNT_ASM_NAME);  &__asm(".global	"  &MCOUNT_ASM_NAME_ALIAS);  &__asm( &MCOUNT_ASM_NAME ":");  &__asm( &MCOUNT_ASM_NAME_ALIAS ":");  &__asm("stp	x29, x30, [sp, #-80]!");  &__asm("stp	x0, x1, [sp, #16]");  &__asm("stp	x2, x3, [sp, #32]");  &__asm("stp	x4, x5, [sp, #48]");  &__asm("stp	x6, x7, [sp, #64]");  &__asm("ldr	x0, [x29, #8]");  &__asm("mov	x1, x30");  &__asm("bl	"  &___STRING( &_C_LABEL( &mcount)));  &__asm("ldp	x0, x1, [sp, #16]");  &__asm("ldp	x2, x3, [sp, #32]");  &__asm("ldp	x4, x5, [sp, #48]");  &__asm("ldp	x6, x7, [sp, #64]");  &__asm("ldp	x29, x30, [sp], #80");  &__asm("ret");  &__asm(".size	"  &MCOUNT_ASM_NAME ", .-"  &MCOUNT_ASM_NAME);;}' unless defined(&MCOUNT);
    if(defined(&_KERNEL)) {
	eval 'sub MCOUNT_ENTER () { &__asm  &__volatile ("mrs %x0, daif; msr daifset, #3": "=r"( &s):: "memory");}' unless defined(&MCOUNT_ENTER);
	eval 'sub MCOUNT_EXIT () { &__asm  &__volatile ("msr daif, %x0":: "r"( &s): "memory");}' unless defined(&MCOUNT_EXIT);
    }
}
 elsif(defined(&__arm__)) {
    require 'arm/profile.ph';
}
1;
