/******************************************************************************
 *
 * 2017 (c) Lattice Semiconductor Corporation
 *
 * This program is free software; you can redistribute it and/or
 * modify it only under the terms of version 2 of the GNU General Public License
 * as published by the Free Software Foundation, and not any later version.
 *
 * This program is distributed "AS IS" WITHOUT ANY WARRANTY of any kind,
 * whether express or implied, including without limitation the implied warranty
 * of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE or NON-INFRINGEMENT.
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * You may contact Lattice Semiconductor Corporation at
 * 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 <string.h>
#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 */
