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';
    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);
	eval 'sub __va_copy {
	    my($dst, $src) = @_;
    	    eval q((($dst) = ($src)));
	}' unless defined(&__va_copy);
    } else {
	eval 'sub va_start {
	    my($ap, $last) = @_;
    	    eval q(( &__builtin_next_arg($last), ($ap) = *( &va_list *) &__builtin_saveregs(), ($ap). &pad = 0));
	}' unless defined(&va_start);
    }
    eval 'sub __REAL_TYPE_CLASS () {8;}' unless defined(&__REAL_TYPE_CLASS);
    eval 'sub __va_arg_offset {
        my($ap, $type) = @_;
	    eval q((( &__builtin_classify_type(*($type *)0) ==  &__REAL_TYPE_CLASS  && ($ap). &offset <= (6* 8) ? -(6* 8) : 0) -  &__va_size($type)));
    }' unless defined(&__va_arg_offset);
    eval 'sub va_arg {
        my($ap, $type) = @_;
	    eval q((*($type *)(($ap). &offset +=  &__va_size($type), ($ap). &base + ($ap). &offset +  &__va_arg_offset($ap, $type))));
    }' unless defined(&va_arg);
    eval 'sub va_end {
        my($ap) = @_;
	    eval q();
    }' unless defined(&va_end);
}
1;
