#ifndef _DFIXER_LIB_H_
#define _DFIXER_LIB_H_

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <sys/syscall.h>
#include <unistd.h>

#include <map>
#include <set>

#define TID syscall(SYS_gettid)

#define Lock	pthread_mutex_t
#define acq		pthread_mutex_lock
#define rel		pthread_mutex_unlock
#define tryAcq	pthread_mutex_trylock


using namespace std;

typedef unsigned int uint;
typedef pair<uint, uint> Pair;



////////////////////////////////////////////////////////////////////////////////

/**	set preAcquisition condition */
extern void setPreAcqTaken(Lock * lock);

/**	get preAcquisition condition */
extern bool preAcqTaken(Lock* lock);

/**	clear preAcquisition condition */
extern void clearPreAcq(Lock* lock);


////////////////////////////////////////////////////////////////////////////////

/**	set v_hw condition */
extern void setHWCondOn(Lock* hLock, Lock* wLock);


/**	get v_hw condition */
extern bool getHWCond(Lock* hLock, Lock* wLock);

/**	clear v_hw condition */
extern void setHWCondOff(Lock* hLock, Lock* wLock);

////////////////////////////////////////////////////////////////////////////////

/**	preAcquisition */
extern bool preAcq_pthread_mutex_lock (Lock* hLock, Lock* wLock);

#endif
