#include "V.h"
#include "sys_pthreads.h"

#if defined(USE_pthreads) && (USE_pthreads > 0)

FCT	V_ptlock()
{	int r=0;
:f	Fenter("V_ptlock");
	if (V_locking && use_pthreads) {;
#if defined(USE_pthreads) && (USE_pthreads > 0)
:3		if (Vlvl>2) {fputs("Get global pthreads lock ...\n",Vout); fflush(Vout);}
		pthread_lock_global_np();
:3		if (Vlvl>2) {fputs("Got global pthreads lock.\n",Vout); fflush(Vout);}
#endif /*USE_pthreads*/
		;
:5	} else {
:5		if (Vlvl>2) {fputs("Not using pthreads.\n",Vout); fflush(Vout);}
	}
:f	Fexit;
	return r;
}

FCT	V_ptunlock()
{	int r=0;
:f	Fenter("V_ptunlock");
	if (V_locking && use_pthreads) {;
#if defined(USE_pthreads) && (USE_pthreads > 0)
:3		if (Vlvl>2) {fputs("Free global pthreads lock ...\n",Vout); fflush(Vout);}
		pthread_unlock_global_np();
:3		if (Vlvl>2) {fputs("Freed global pthreads lock.\n",Vout); fflush(Vout);}
#endif /*USE_pthreads*/
		;
:5	} else {
:5		if (Vlvl>2) {fputs("Not using pthreads.\n",Vout); fflush(Vout);}
	}
:f	Fexit;
	return r;
}

#else
	int has_pthreads = 0;
#endif	/* USE_pthreads */
