require '_h2ph_pre.ph';

no warnings qw(redefine misc);

unless(defined(&_SYS_COMMON_LOCK_H_)) {
    eval 'sub _SYS_COMMON_LOCK_H_ () {1;}' unless defined(&_SYS_COMMON_LOCK_H_);
    eval 'sub __SIMPLELOCK_LOCKED_P {
        my($__ptr) = @_;
	    eval q({ *$__ptr !=  &__SIMPLELOCK_UNLOCKED; });
    }' unless defined(&__SIMPLELOCK_LOCKED_P);
    eval 'sub __SIMPLELOCK_UNLOCKED_P {
        my($__ptr) = @_;
	    eval q({ *$__ptr ==  &__SIMPLELOCK_UNLOCKED; });
    }' unless defined(&__SIMPLELOCK_UNLOCKED_P);
# some #ifdef were dropped here -- fill in the blanks
    eval 'sub __cpu_simple_lock_clear {
        my($__ptr) = @_;
	    eval q({ });
    }' unless defined(&__cpu_simple_lock_clear);
# some #ifdef were dropped here -- fill in the blanks
    eval 'sub __cpu_simple_lock_set {
        my($__ptr) = @_;
	    eval q({ });
    }' unless defined(&__cpu_simple_lock_set);
# some #ifdef were dropped here -- fill in the blanks
    eval 'sub __cpu_simple_lock_init {
        my($__ptr) = @_;
	    eval q({ });
    }' unless defined(&__cpu_simple_lock_init);
    eval 'sub __cpu_simple_lock {
        my($__ptr) = @_;
	    eval q({  &while ( &__atomic_exchange_n($__ptr,  &__SIMPLELOCK_LOCKED,  &__ATOMIC_ACQUIRE) ==  &__SIMPLELOCK_LOCKED) { } });
    }' unless defined(&__cpu_simple_lock);
    eval 'sub __cpu_simple_lock_try {
        my($__ptr) = @_;
	    eval q({  &__atomic_exchange_n($__ptr,  &__SIMPLELOCK_LOCKED,  &__ATOMIC_ACQUIRE) ==  &__SIMPLELOCK_UNLOCKED; });
    }' unless defined(&__cpu_simple_lock_try);
    eval 'sub __cpu_simple_unlock {
        my($__ptr) = @_;
	    eval q({  &__atomic_store_n($__ptr,  &__SIMPLELOCK_UNLOCKED,  &__ATOMIC_RELEASE); });
    }' unless defined(&__cpu_simple_unlock);
}
1;
