/*! \file Macro.h
*	\brief User Scol machine Macro conversion API
*/

/*! @defgroup group1 Macro conversion API
 *  User Scol machine Macro conversion API
 *  @{
 */

/*! \brief Convert scol machine value to int
*   \param int : scol machine value
*   \return int : system int value
*/
#define MTOI(val) ((val)>>1)

/** \brief Convert scol machine value to system handle
* \param int : scol machine value
* \return int : system handle
*/
#define MTOP(val) ((val)>>1)

/*! \brief Convert int to scol machine value
*   \param int : system int value
*   \return int : scol machine value
*/
#define ITOM(val) ((val)<<1)

/*! \brief Convert system handle to scol machine value
*   \param int : system int value
*   \return int : scol machine value
*/
#define PTOM(val) (((val)<<1)+1)

#ifndef SCOL_FLOAT_DEFINITION
/*! \brief Convert scol machine value to float
*   \param int : scol machine value
*   \return float : system float value
*/
_inline float MTOF(int val) {	return *(float*)&(val);	}

/*! \brief Convert float to scol machine value
*   \param float : system float value
*   \return int : scol machine value
*/
_inline int   FTOM(float val) {	return ((*(int*)&(val)) & 0xfffffffe);	}
#define SCOL_FLOAT_DEFINITION
#endif

/*! \brief Invert 2 stack positions in scol machine\n
*    need a int tmp_res local variable to work
*   \param Mmachine : the scol machine structure pointer
*	\param int : first position in stack
*   \param int : second position in stack
*/
#define INVERT(m, a, b) {tmp_res=MMget(m,a);MMset(m,a,MMget(m,b));MMset(m,b,tmp_res);}

/*! \brief Move the scol machine stack of n positions
*   \param Mmachine : the scol machine structure pointer
*	\param int : number of pull in stack
*/
#define SEDROP(m, n) ((m)->pp += (n))

/** @} */

#define STR_SIZE(size) (2+((size)>>2))
#define SIZE(t) ((sizeof(t)+3)>>2)
#define CHECK(m) {if (tmp_res=m) return tmp_res;}