/****************************************************************************************


		MCSMPAtomicCounter.h

		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	Emil
		Date:	3/27/98

		Revision History

		when		who			what & why
		==========	==========	======================================================
		10/18/99	Yann		SetAtomicCounterValue was returning an int32 on the Mac
		7/29/99		Eml			Atomic Counter fix
		6/10/99		Ian			Array API changes.
		04/23/99	Eml/scooper	stub MakeSMPProcess
		4/22/99		Eml			Reverted to old TLS mechanism. New one could not work on the Mac
		5/27/98		Eml			include MCOSConfig.h

*****************************************************************************************/

#ifndef __MCSMPAtomicCounter__
#define __MCSMPAtomicCounter__

#include "MCBasicDefines.h"
#include "MCBasicTypes.h"
#include "MCOSConfig.h"
#include "MCCompiler.h"


class TMCAtomicCounter;


#ifdef qSMP

#if MAC
	typedef TMCAtomicCounter* TMCAtomicCounterHolder;
	TMCAtomicCounter * NewAtomicCounter();
	void DeleteAtomicCounter(TMCAtomicCounter * counter);
	int32 GetAtomicCounterValue(TMCAtomicCounter *counter);
	void SetAtomicCounterValue(TMCAtomicCounter *&counter, int32 value);
#else
typedef int32 TMCAtomicCounterHolder;
	#define NewAtomicCounter() nil
	#define DeleteAtomicCounter(x)
	#define GetAtomicCounterValue(x) ((int32)(x))
	#define SetAtomicCounterValue(x, v) ((x)=(TMCAtomicCounterHolder)(v))
#endif

int32 IncrementAtomicCounter(TMCAtomicCounterHolder &counter);
int32 DecrementAtomicCounter(TMCAtomicCounterHolder &counter);

#else // if qSMP

#error "You must define qSMP !!!"

/*
#define NewAtomicCounter() nil
#define DeleteAtomicCounter(x)
#define GetAtomicCounterValue(x) ((int32)(x))
#define SetAtomicCounterValue(x, v) ((x)=(TMCAtomicCounter*)(v))
#define IncrementAtomicCounter(x) (++(*(int32*)&(x)))
#define DecrementAtomicCounter(x) (--(*(int32*)&(x)))
*/

#endif


#endif

