require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SPARC64_STDARG_H_)) {
    eval 'sub _SPARC64_STDARG_H_ () {1;}' unless defined(&_SPARC64_STDARG_H_);
    require 'sys/cdefs.ph';
    require 'machine/_types.ph';
    if(defined(&__lint__)) {
	eval 'sub __builtin_saveregs {
	    my($t) = @_;
    	    eval q((0));
	}' unless defined(&__builtin_saveregs);
	eval 'sub __builtin_classify_type {
	    my($t) = @_;
    	    eval q((0));
	}' unless defined(&__builtin_classify_type);
	eval 'sub __builtin_next_arg {
	    my($t) = @_;
    	    eval q((($t) ? 0: 0));
	}' unless defined(&__builtin_next_arg);
    }
    if(defined(&lint)) {
	eval 'sub va_start {
	    my($ap,$lastarg) = @_;
    	    eval q((($ap) = ($ap)));
	}' unless defined(&va_start);
    } else {
	eval 'sub va_start {
	    my($ap, $last) = @_;
    	    eval q(( &__builtin_next_arg($last), ($ap) = ( &va_list) &__builtin_saveregs()));
	}' unless defined(&va_start);
    }
    eval 'sub va_end {
        my($ap) = @_;
	    eval q();
    }' unless defined(&va_end);
    eval 'sub __va_arg8 {
        my($ap, $type) = @_;
	    eval q((*($type *)( &void *)(($ap) += 8, ($ap) - 8)));
    }' unless defined(&__va_arg8);
    eval 'sub __va_arg16 {
        my($ap, $type) = @_;
	    eval q((*($type *)( &void *)(($ap) = ( &va_list)((($ap) + 31) & -16), ($ap) - 16)));
    }' unless defined(&__va_arg16);
    eval 'sub __va_int {
        my($ap, $type) = @_;
	    eval q((*($type *)( &void *)(($ap) += 8, ($ap) - $sizeof{$type})));
    }' unless defined(&__va_int);
    eval 'sub __REAL_TYPE_CLASS () {8;}' unless defined(&__REAL_TYPE_CLASS);
    eval 'sub __RECORD_TYPE_CLASS () {12;}' unless defined(&__RECORD_TYPE_CLASS);
    eval 'sub va_arg {
        my($ap, $type) = @_;
	    eval q(( &__builtin_classify_type(*($type *)0) ==  &__REAL_TYPE_CLASS ? ( &__alignof__($type) == 16?  &__va_arg16($ap, $type) :  &__va_arg8($ap, $type)) : ( &__builtin_classify_type(*($type *)0) <  &__RECORD_TYPE_CLASS ?  &__va_int($ap, $type) : ($sizeof{$type} <= 8?  &__va_arg8($ap, $type) : ($sizeof{$type} <= 16?  &__va_arg16($ap, $type) : * &__va_arg8($ap, $type *))))));
    }' unless defined(&va_arg);
}
1;
