require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_MACHINE_STDARG_H_)) {
    eval 'sub _MACHINE_STDARG_H_ () {1;}' unless defined(&_MACHINE_STDARG_H_);
    require 'sys/cdefs.ph';
    require 'machine/_types.ph';
    if(defined(&__lint__)) {
	eval 'sub __builtin_classify_type {
	    my($t) = @_;
    	    eval q((0));
	}' unless defined(&__builtin_classify_type);
    }
    eval 'sub __va_size {
        my($type) = @_;
	    eval q(((($sizeof{$type} + $sizeof{\'long\'} - 1) / $sizeof{\'long\'}) * $sizeof{\'long\'}));
    }' unless defined(&__va_size);
    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_8byte {
        my($ap, $type) = @_;
	    eval q( &__statement({ \'union union\' { \'char\'  $__d[ &sizeof]; \'int\'  $__i[2]; }  &__va_u;  ($__va_u->{__i[0]}) = (( &void *))[0];  ($__va_u->{__i[1]}) = (( &void *)($ap))[1]; ($ap) += 8; *($type *)( &va_list) ($__va_u->{__d}); }));
    }' unless defined(&__va_8byte);
    eval 'sub __va_arg {
        my($ap, $type) = @_;
	    eval q((*($type *)(($ap) +=  &__va_size($type), ($ap) - ($sizeof{$type} < $sizeof{\'long\'}  && $sizeof{$type} !=  &__va_size($type) ? $sizeof{$type} :  &__va_size($type)))));
    }' unless defined(&__va_arg);
    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) >=  &__RECORD_TYPE_CLASS ? * &__va_arg($ap, $type *) :  &__va_size($type) == 8?  &__va_8byte($ap, $type) :  &__va_arg($ap, $type)));
    }' unless defined(&va_arg);
    if((defined(&__ISO_C_VISIBLE) ? &__ISO_C_VISIBLE : undef) >= 1999) {
	eval 'sub __va_copy {
	    my($dest, $src) = @_;
    	    eval q((($dest) = ($src)));
	}' unless defined(&__va_copy);
    }
    eval 'sub va_end {
        my($ap) = @_;
	    eval q();
    }' unless defined(&va_end);
}
1;
