void CRYPTO_lock(int mode, int type, const char *file, int line)
	{
#ifdef LOCK_DEBUG
		{
		char *rw_text,*operation_text;

		if (mode & CRYPTO_LOCK)
			operation_text="lock  ";
		else if (mode & CRYPTO_UNLOCK)
			operation_text="unlock";
		else
			operation_text="ERROR ";

		if (mode & CRYPTO_READ)
			rw_text="r";
		else if (mode & CRYPTO_WRITE)
			rw_text="w";
		else
			rw_text="ERROR";

		fprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\n",
			CRYPTO_thread_id(), rw_text, operation_text,
			CRYPTO_get_lock_name(type), file, line);
		}
#endif
	if (type < 0)
		{
		struct CRYPTO_dynlock_value *pointer
			= CRYPTO_get_dynlock_value(type);

		if (pointer && dynlock_lock_callback)
			{
			dynlock_lock_callback(mode, pointer, file, line);
			}

		CRYPTO_destroy_dynlockid(type);
		}
	else
		if (locking_callback != NULL)
			locking_callback(mode,type,file,line);
	}