require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_MACHINE_ASM_H_)) {
    eval 'sub _MACHINE_ASM_H_ () {1;}' unless defined(&_MACHINE_ASM_H_);
    if(defined(&__ELF__)) {
	eval 'sub _C_LABEL {
	    my($name) = @_;
    	    eval q($name);
	}' unless defined(&_C_LABEL);
    } else {
	if(defined(&__STDC__)) {
	    eval 'sub _C_LABEL {
	        my($name) = @_;
    		eval q( &_  $name);
	    }' unless defined(&_C_LABEL);
	} else {
	    eval 'sub _C_LABEL {
	        my($name) = @_;
    		eval q( &_ $name);
	    }' unless defined(&_C_LABEL);
	}
    }
    eval 'sub _ASM_LABEL {
        my($name) = @_;
	    eval q($name);
    }' unless defined(&_ASM_LABEL);
    if(defined(&__ELF__)) {
	eval 'sub WEAK_ALIAS {
	    my($alias,$sym) = @_;
    	    eval q(. &weak $alias; $alias = $sym);
	}' unless defined(&WEAK_ALIAS);
    }
    if(defined(&__ELF__)) {
	eval 'sub WARN_REFERENCES {
	    my($_sym,$_msg) = @_;
    	    eval q(. &section . ($gnu->{warning}).  $_sym ; . &ascii $_msg ; . &text);
	}' unless defined(&WARN_REFERENCES);
    }
    if(defined(&PIC)) {
	eval 'sub PIC_PROLOGUE {
	    my($dest,$tmp) = @_;
    	    eval q( &mov % &o7,$tmp; 3:  &call 4 &f;  &nop; 4:  &sethi % &hi( &_C_LABEL( &_GLOBAL_OFFSET_TABLE_)-(3 &b-.)),$dest;  &or $dest,% &lo( &_C_LABEL( &_GLOBAL_OFFSET_TABLE_)-(3 &b-.)),$dest;  &add $dest,% &o7,$dest;  &mov $tmp,% &o7);
	}' unless defined(&PIC_PROLOGUE);
	eval 'sub PICCY_SET {
	    my($var,$dest,$tmp) = @_;
    	    eval q( &mov % &o7,$tmp; 3:  &call 4 &f;  &nop; 4:  &add % &o7,($var-3 &b),$dest;  &mov $tmp,% &o7);
	}' unless defined(&PICCY_SET);
    } else {
	eval 'sub PIC_PROLOGUE {
	    my($dest,$tmp) = @_;
    	    eval q();
	}' unless defined(&PIC_PROLOGUE);
	eval 'sub PICCY_OFFSET {
	    my($var,$dest,$tmp) = @_;
    	    eval q();
	}' unless defined(&PICCY_OFFSET);
    }
    eval 'sub FTYPE {
        my($x) = @_;
	    eval q(. &type $x,@ &function);
    }' unless defined(&FTYPE);
    eval 'sub OTYPE {
        my($x) = @_;
	    eval q(. &type $x,@ &object);
    }' unless defined(&OTYPE);
    eval 'sub _ENTRY {
        my($name) = @_;
	    eval q(. &align 4; . &globl $name; . &proc 1;  &FTYPE($name); $name:);
    }' unless defined(&_ENTRY);
    if(defined(&GPROF)) {
	eval 'sub _PROF_PROLOGUE () {. &data; . &align 4; 1: .\'long 0\'; . &text;  &save % &sp,-96,% &sp;  &sethi % &hi(1 &b),% &o0;  &call  &mcount;  &or % &o0,% &lo(1 &b),% &o0;  &restore;}' unless defined(&_PROF_PROLOGUE);
    } else {
	eval 'sub _PROF_PROLOGUE () {1;}' unless defined(&_PROF_PROLOGUE);
    }
    eval 'sub ENTRY {
        my($name) = @_;
	    eval q( &_ENTRY( &_C_LABEL($name));  &_PROF_PROLOGUE);
    }' unless defined(&ENTRY);
    eval 'sub ASENTRY {
        my($name) = @_;
	    eval q( &_ENTRY( &_ASM_LABEL($name));  &_PROF_PROLOGUE);
    }' unless defined(&ASENTRY);
    eval 'sub FUNC {
        my($name) = @_;
	    eval q( &ASENTRY($name));
    }' unless defined(&FUNC);
    eval 'sub ASMSTR () {. &asciz;}' unless defined(&ASMSTR);
    eval 'sub RCSID {
        my($name) = @_;
	    eval q(. &asciz $name);
    }' unless defined(&RCSID);
}
1;
