require '_h2ph_pre.ph';

unless(defined(&_BITS_LIBC_LOCK_H)) {
    eval 'sub _BITS_LIBC_LOCK_H () {1;}' unless defined(&_BITS_LIBC_LOCK_H);
    require 'pthread.ph';
    if(defined (defined(&_LIBC) ? &_LIBC : 0)  && !defined (defined(&NOT_IN_libc) ? &NOT_IN_libc : 0)) {
	require 'linuxthreads/internals.ph';
    }
    if(defined( &_LIBC) || defined( &_IO_MTSAFE_IO)) {
	if(defined(&__USE_UNIX98)) {
	} else {
	}
    } else {
    }
    eval 'sub __libc_lock_define {
        local($CLASS,$NAME) = @_;
	    eval q($CLASS  &__libc_lock_t $NAME;);
    }' unless defined(&__libc_lock_define);
    eval 'sub __libc_rwlock_define {
        local($CLASS,$NAME) = @_;
	    eval q($CLASS  &__libc_rwlock_t $NAME;);
    }' unless defined(&__libc_rwlock_define);
    eval 'sub __libc_lock_define_recursive {
        local($CLASS,$NAME) = @_;
	    eval q($CLASS  &__libc_lock_recursive_t $NAME;);
    }' unless defined(&__libc_lock_define_recursive);
    eval 'sub __rtld_lock_define_recursive {
        local($CLASS,$NAME) = @_;
	    eval q($CLASS  &__rtld_lock_recursive_t $NAME;);
    }' unless defined(&__rtld_lock_define_recursive);
    if((defined(&__LT_SPINLOCK_INIT) ? &__LT_SPINLOCK_INIT : 0) == 0) {
	eval 'sub __libc_lock_define_initialized {
	    local($CLASS,$NAME) = @_;
    	    eval q($CLASS  &__libc_lock_t $NAME;);
	}' unless defined(&__libc_lock_define_initialized);
    } else {
	eval 'sub __libc_lock_define_initialized {
	    local($CLASS,$NAME) = @_;
    	    eval q($CLASS  &__libc_lock_t $NAME =  &PTHREAD_MUTEX_INITIALIZER;);
	}' unless defined(&__libc_lock_define_initialized);
    }
    eval 'sub __libc_rwlock_define_initialized {
        local($CLASS,$NAME) = @_;
	    eval q($CLASS  &__libc_rwlock_t $NAME =  &PTHREAD_RWLOCK_INITIALIZER;);
    }' unless defined(&__libc_rwlock_define_initialized);
    eval 'sub __libc_lock_define_initialized_recursive {
        local($CLASS,$NAME) = @_;
	    eval q($CLASS  &__libc_lock_recursive_t $NAME =  &_LIBC_LOCK_RECURSIVE_INITIALIZER;);
    }' unless defined(&__libc_lock_define_initialized_recursive);
    eval 'sub _LIBC_LOCK_RECURSIVE_INITIALIZER () {{ &PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP};}' unless defined(&_LIBC_LOCK_RECURSIVE_INITIALIZER);
    eval 'sub __rtld_lock_define_initialized_recursive {
        local($CLASS,$NAME) = @_;
	    eval q($CLASS  &__rtld_lock_recursive_t $NAME =  &_RTLD_LOCK_RECURSIVE_INITIALIZER;);
    }' unless defined(&__rtld_lock_define_initialized_recursive);
    eval 'sub _RTLD_LOCK_RECURSIVE_INITIALIZER () {{ &PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP};}' unless defined(&_RTLD_LOCK_RECURSIVE_INITIALIZER);
    if(defined (defined(&_LIBC) ? &_LIBC : 0)  && defined (defined(&IS_IN_libpthread) ? &IS_IN_libpthread : 0)) {
	eval 'sub __libc_maybe_call {
	    local($FUNC, $ARGS, $ELSE) = @_;
    	    eval q($FUNC $ARGS);
	}' unless defined(&__libc_maybe_call);
    } else {
	if(defined (defined(&__PIC__) ? &__PIC__ : 0) || (defined (defined(&_LIBC) ? &_LIBC : 0)  && defined (defined(&SHARED) ? &SHARED : 0))) {
	    eval 'sub __libc_maybe_call {
	        local($FUNC, $ARGS, $ELSE) = @_;
    		eval q(( &__extension__ ({  &__typeof ($FUNC) * &_fn = ($FUNC);  &_fn !=  &NULL ? (* &_fn) $ARGS : $ELSE; })));
	    }' unless defined(&__libc_maybe_call);
	} else {
	    eval 'sub __libc_maybe_call {
	        local($FUNC, $ARGS, $ELSE) = @_;
    		eval q(($FUNC !=  &NULL ? $FUNC $ARGS : $ELSE));
	    }' unless defined(&__libc_maybe_call);
	}
    }
    if(defined (defined(&_LIBC) ? &_LIBC : 0)  && !defined (defined(&NOT_IN_libc) ? &NOT_IN_libc : 0)  && defined (defined(&SHARED) ? &SHARED : 0)) {
	eval 'sub __libc_maybe_call2 {
	    local($FUNC, $ARGS, $ELSE) = @_;
    	    eval q(({ &__builtin_expect ( ($__libc_pthread_functions->{ptr_})$FUNC !=  &NULL, 0) ?  ($__libc_pthread_functions->{ptr_})$FUNC $ARGS : $ELSE; }));
	}' unless defined(&__libc_maybe_call2);
    } else {
	eval 'sub __libc_maybe_call2 {
	    local($FUNC, $ARGS, $ELSE) = @_;
    	    eval q( &__libc_maybe_call ( &__$FUNC, $ARGS, $ELSE));
	}' unless defined(&__libc_maybe_call2);
    }
    if(defined (defined(&_LIBC) ? &_LIBC : 0)  && !defined (defined(&NOT_IN_libc) ? &NOT_IN_libc : 0)  && defined (defined(&SHARED) ? &SHARED : 0)) {
	eval 'sub __libc_lock_init {
	    local($NAME) = @_;
    	    eval q(({ ($NAME). &__m_count = 0; ($NAME). &__m_owner =  &NULL; ($NAME). &__m_kind =  &PTHREAD_MUTEX_TIMED_NP; ($NAME). ($__m_lock->{__status}) = 0; ($NAME). ($__m_lock->{__spinlock}) =  &__LT_SPINLOCK_INIT; 0; }));
	}' unless defined(&__libc_lock_init);
    } else {
	eval 'sub __libc_lock_init {
	    local($NAME) = @_;
    	    eval q(( &__libc_maybe_call2 ( &pthread_mutex_init, (($NAME),  &NULL), 0)));
	}' unless defined(&__libc_lock_init);
    }
    eval 'sub __libc_rwlock_init {
        local($NAME) = @_;
	    eval q(( &__libc_maybe_call ( &__pthread_rwlock_init, (($NAME),  &NULL), 0)););
    }' unless defined(&__libc_rwlock_init);
    if(defined (defined(&_LIBC) ? &_LIBC : 0)  && !defined (defined(&NOT_IN_libc) ? &NOT_IN_libc : 0)  && defined (defined(&SHARED) ? &SHARED : 0)) {
	eval 'sub __libc_lock_init_recursive {
	    local($NAME) = @_;
    	    eval q(({ ($NAME). ($mutex->{__m_count}) = 0; ($NAME). ($mutex->{__m_owner}) =  &NULL; ($NAME). ($mutex->{__m_kind}) =  &PTHREAD_MUTEX_RECURSIVE_NP; ($NAME). ($mutex->{__m_lock}->{__status}) = 0; ($NAME). ($mutex->{__m_lock}->{__spinlock}) =  &__LT_SPINLOCK_INIT; 0; }));
	}' unless defined(&__libc_lock_init_recursive);
    } else {
	eval 'sub __libc_lock_init_recursive {
	    local($NAME) = @_;
    	    eval q( &do {  &if ( &__pthread_mutex_init !=  &NULL) {  &pthread_mutexattr_t  &__attr;  &__pthread_mutexattr_init (& &__attr);  &__pthread_mutexattr_settype (& &__attr,  &PTHREAD_MUTEX_RECURSIVE_NP);  &__pthread_mutex_init (($NAME). &mutex, & &__attr);  &__pthread_mutexattr_destroy (& &__attr); } }  &while (0););
	}' unless defined(&__libc_lock_init_recursive);
    }
    eval 'sub __rtld_lock_init_recursive {
        local($NAME) = @_;
	    eval q( &__libc_lock_init_recursive ($NAME));
    }' unless defined(&__rtld_lock_init_recursive);
    eval 'sub __libc_lock_fini {
        local($NAME) = @_;
	    eval q(( &__libc_maybe_call2 ( &pthread_mutex_destroy, (($NAME)), 0)););
    }' unless defined(&__libc_lock_fini);
    eval 'sub __libc_rwlock_fini {
        local($NAME) = @_;
	    eval q(( &__libc_maybe_call ( &__pthread_rwlock_destroy, (($NAME)), 0)););
    }' unless defined(&__libc_rwlock_fini);
    eval 'sub __libc_lock_fini_recursive {
        local($NAME) = @_;
	    eval q( &__libc_lock_fini (($NAME). &mutex));
    }' unless defined(&__libc_lock_fini_recursive);
    eval 'sub __rtld_lock_fini_recursive {
        local($NAME) = @_;
	    eval q( &__libc_lock_fini_recursive ($NAME));
    }' unless defined(&__rtld_lock_fini_recursive);
    eval 'sub __libc_lock_lock {
        local($NAME) = @_;
	    eval q(( &__libc_maybe_call2 ( &pthread_mutex_lock, (($NAME)), 0)););
    }' unless defined(&__libc_lock_lock);
    eval 'sub __libc_rwlock_rdlock {
        local($NAME) = @_;
	    eval q(( &__libc_maybe_call ( &__pthread_rwlock_rdlock, (($NAME)), 0)););
    }' unless defined(&__libc_rwlock_rdlock);
    eval 'sub __libc_rwlock_wrlock {
        local($NAME) = @_;
	    eval q(( &__libc_maybe_call ( &__pthread_rwlock_wrlock, (($NAME)), 0)););
    }' unless defined(&__libc_rwlock_wrlock);
    eval 'sub __libc_lock_lock_recursive {
        local($NAME) = @_;
	    eval q( &__libc_lock_lock (($NAME). &mutex));
    }' unless defined(&__libc_lock_lock_recursive);
    eval 'sub __rtld_lock_lock_recursive {
        local($NAME) = @_;
	    eval q( &__libc_lock_lock_recursive ($NAME));
    }' unless defined(&__rtld_lock_lock_recursive);
    eval 'sub __libc_lock_trylock {
        local($NAME) = @_;
	    eval q(( &__libc_maybe_call2 ( &pthread_mutex_trylock, (($NAME)), 0)));
    }' unless defined(&__libc_lock_trylock);
    eval 'sub __libc_rwlock_tryrdlock {
        local($NAME) = @_;
	    eval q(( &__libc_maybe_call ( &__pthread_rwlock_tryrdlock, (($NAME)), 0)));
    }' unless defined(&__libc_rwlock_tryrdlock);
    eval 'sub __libc_rwlock_trywrlock {
        local($NAME) = @_;
	    eval q(( &__libc_maybe_call ( &__pthread_rwlock_trywrlock, (($NAME)), 0)));
    }' unless defined(&__libc_rwlock_trywrlock);
    eval 'sub __libc_lock_trylock_recursive {
        local($NAME) = @_;
	    eval q( &__libc_lock_trylock (($NAME). &mutex));
    }' unless defined(&__libc_lock_trylock_recursive);
    eval 'sub __rtld_lock_trylock_recursive {
        local($NAME) = @_;
	    eval q( &__libc_lock_trylock_recursive ($NAME));
    }' unless defined(&__rtld_lock_trylock_recursive);
    eval 'sub __libc_lock_unlock {
        local($NAME) = @_;
	    eval q(( &__libc_maybe_call2 ( &pthread_mutex_unlock, (($NAME)), 0)););
    }' unless defined(&__libc_lock_unlock);
    eval 'sub __libc_rwlock_unlock {
        local($NAME) = @_;
	    eval q(( &__libc_maybe_call ( &__pthread_rwlock_unlock, (($NAME)), 0)););
    }' unless defined(&__libc_rwlock_unlock);
    eval 'sub __libc_lock_unlock_recursive {
        local($NAME) = @_;
	    eval q( &__libc_lock_unlock (($NAME). &mutex));
    }' unless defined(&__libc_lock_unlock_recursive);
    eval 'sub __rtld_lock_unlock_recursive {
        local($NAME) = @_;
	    eval q( &__libc_lock_unlock_recursive ($NAME));
    }' unless defined(&__rtld_lock_unlock_recursive);
    if((defined(&PTHREAD_ONCE_INIT) ? &PTHREAD_ONCE_INIT : 0) == 0) {
	eval 'sub __libc_once_define {
	    local($CLASS, $NAME) = @_;
    	    eval q($CLASS  &pthread_once_t $NAME);
	}' unless defined(&__libc_once_define);
    } else {
	eval 'sub __libc_once_define {
	    local($CLASS, $NAME) = @_;
    	    eval q($CLASS  &pthread_once_t $NAME =  &PTHREAD_ONCE_INIT);
	}' unless defined(&__libc_once_define);
    }
    eval 'sub __libc_once {
        local($ONCE_CONTROL, $INIT_FUNCTION) = @_;
	    eval q( &do {  &if ( &__pthread_once !=  &NULL)  &__pthread_once (($ONCE_CONTROL), ($INIT_FUNCTION));  &else  &if (($ONCE_CONTROL) ==  &PTHREAD_ONCE_INIT) { $INIT_FUNCTION (); ($ONCE_CONTROL) = 2; } }  &while (0));
    }' unless defined(&__libc_once);
    eval 'sub __libc_cleanup_region_start {
        local($DOIT, $FCT, $ARG) = @_;
	    eval q({ \'struct _pthread_cleanup_buffer\'  &_buffer; \'int\'  &_avail = ($DOIT)  &&  &_pthread_cleanup_push_defer !=  &NULL;  &if ( &_avail) {  &_pthread_cleanup_push_defer (& &_buffer, ($FCT), ($ARG)); });
    }' unless defined(&__libc_cleanup_region_start);
    eval 'sub __libc_cleanup_region_end {
        local($DOIT) = @_;
	    eval q( &if ( &_avail) {  &_pthread_cleanup_pop_restore (& &_buffer, ($DOIT)); } });
    }' unless defined(&__libc_cleanup_region_end);
    eval 'sub __libc_cleanup_end {
        local($DOIT) = @_;
	    eval q( &if ( &_avail) {  &_pthread_cleanup_pop_restore (& &_buffer, ($DOIT)); });
    }' unless defined(&__libc_cleanup_end);
    eval 'sub __libc_key_create {
        local($KEY, $DESTRUCTOR) = @_;
	    eval q(( &__libc_maybe_call ( &__pthread_key_create, ($KEY, $DESTRUCTOR), 1)));
    }' unless defined(&__libc_key_create);
    eval 'sub __libc_getspecific {
        local($KEY) = @_;
	    eval q(( &__libc_maybe_call ( &__pthread_getspecific, ($KEY),  &NULL)));
    }' unless defined(&__libc_getspecific);
    eval 'sub __libc_setspecific {
        local($KEY, $VALUE) = @_;
	    eval q(( &__libc_maybe_call ( &__pthread_setspecific, ($KEY, $VALUE), 0)));
    }' unless defined(&__libc_setspecific);
    eval 'sub __libc_atfork {
        local($PREPARE, $PARENT, $CHILD) = @_;
	    eval q(( &__libc_maybe_call ( &__pthread_atfork, ($PREPARE, $PARENT, $CHILD), 0)));
    }' unless defined(&__libc_atfork);
    if(defined(&__USE_UNIX98)) {
    }
    unless(defined(&__NO_WEAK_PTHREAD_ALIASES)) {
	if(defined(&weak_extern)) {
	    if((defined(&_LIBC) ? &_LIBC : 0)) {
		require 'bp-sym.ph';
	    } else {
		eval 'sub BP_SYM () {  &sym;}' unless defined(&BP_SYM);
	    }
	} else {
	}
    }
    eval 'sub __libc_mutex_unlock () { &__pthread_mutex_unlock;}' unless defined(&__libc_mutex_unlock);
}
1;
