/******************************************************************************
 *
 * Copyright 2017, Lattice Semiconductor, Inc. All rights reserved.
 * No part of this work may be reproduced, modified, distributed, transmitted,
 * transcribed, or translated into any language or computer format, in any form
 * or by any means without written permission of Lattice Semiconductor Inc.,
 * 111 SW 5th Ave, Suite 700, Portland, OR 97204.
 *
 *****************************************************************************/
/**
 * @file sii_datatypes.h
 *
 * @brief Common data types
 *
 *****************************************************************************/

#ifndef SII_DATATYPES_H
#define SII_DATATYPES_H

#ifdef __cplusplus
extern "C" {
#endif

/***** #include statements ***************************************************/
#include "x_debug.h"
#include "typedef.h"

/***** public macro definitions **********************************************/
#define SII_INST2OBJ(inst)                   ((void *)inst)
#define SII_OBJ2INST(pObj)                   ((sii_inst_t)pObj)
#define SII_INST_NULL                        ((sii_inst_t)0)

/***** public type definitions ***********************************************/
/**
 * @brief Instance type
 */
typedef void *sii_inst_t;

/**
 * @brief C++ -like Boolean type
 */
#ifdef __cplusplus
typedef bool bool_t;
#define TRUE true
#define FALSE false
#else
#define bool_t BOOL

#endif /* __cplusplus */

/***** standard functions ****************************************************/
extern INT32 x_vsprintf (CHAR* ps_str, const CHAR*  ps_format, VA_LIST va_list);
#define SII_VSPRINTF(dstr, size, fstr, arg) x_vsprintf(dstr, fstr, arg)
#define SII_MEMCPY(pdes, psrc, size)		memcpy(pdes, psrc, size)
#define SII_MEMSET(pdes, value, size)		memset(pdes, value, size)
#define SII_STRLEN(str)				strlen(str)
#define SII_SPRINTF(str, size, frm, arg)		sprintf(str, frm, arg)
#define SII_STRCPY(dst, src, size)	strlcpy(dst, src, size)
#define SII_STRCAT(dst, src, size)	strlcat(dst, src, size)
#define SII_STRCMP(dst, src)		strcmp(dst,src)
#ifdef __cplusplus
}
#endif

#endif /* SII_DATATYPES_H */
