require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SPARC64_ATOMIC_H_)) {
    eval 'sub _SPARC64_ATOMIC_H_ () {1;}' unless defined(&_SPARC64_ATOMIC_H_);
    if(defined( &_KERNEL)) {
	eval 'sub sparc64_cas {
	    my($uip,$expect,$new) = @_;
    	    eval q({  &__asm  &__volatile(\\"cas [%2], %3, %0\\" : \\"+r\\" ($new), \\"=m\\" (*$uip) : \\"r\\" ($uip), \\"r\\" ($expect), \\"m\\" (*$uip)); ($new); });
	}' unless defined(&sparc64_cas);
	eval 'sub sparc64_casx {
	    my($uip,$expect,$new) = @_;
    	    eval q({  &__asm  &__volatile(\\"casx [%2], %3, %0\\" : \\"+r\\" ($new), \\"=m\\" (*$uip) : \\"r\\" ($uip), \\"r\\" ($expect), \\"m\\" (*$uip)); ($new); });
	}' unless defined(&sparc64_casx);
	eval 'sub atomic_setbits_int {
	    my($uip,$v) = @_;
    	    eval q({  &volatile my $e,  &r;  &r = *$uip;  &do {  $e =  &r;  &r =  &sparc64_cas($uip,  $e,  $e | $v); }  &while ( &r !=  $e); });
	}' unless defined(&atomic_setbits_int);
	eval 'sub atomic_clearbits_int {
	    my($uip,$v) = @_;
    	    eval q({  &volatile my $e,  &r;  &r = *$uip;  &do {  $e =  &r;  &r =  &sparc64_cas($uip,  $e,  $e & ~$v); }  &while ( &r !=  $e); });
	}' unless defined(&atomic_clearbits_int);
    }
}
1;
