⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mt_osapi.h

📁 展讯平台的mtue源代码, 全面,精简,仅供学习, 商用后果自负
💻 H
字号:
/*****************************************************************************
** File Name:                                                                *
** Author:                                                                   *
** Date:           2007/07/07                                                *
** Copyright:      2007 MTONE, Inc. All Rights Reserved.                     *
** Description:                                                              *
******************************************************************************
**                         Important Edit History                            *
** --------------------------------------------------------------------------*
** DATE           NAME             DESCRIPTION                               *
** 2007/07/07                      Create                                    *
*****************************************************************************/

#ifndef _MT_OSAPI_H_
#define _MT_OSAPI_H_

#ifdef __cplusplus
    extern   "C"
    {
#endif

#include "os_api.h"

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

#define MT_DEBUG
//#define MT_TRACE_SLEEP // sleep for debug; DISABLED in RELEASE version

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

#define MT_OSAPI_MKEEPER_MAX 128

// int mt_memcmp( const void *buf1, const void *buf2, size_t count );

#define MT_MEMSET( _DST_PTR, _VALUE, _SIZE ) \
		do \
		{ \
			SCI_ASSERT( (_DST_PTR) ); \
			if( (_SIZE) > 0 ) { memset( (_DST_PTR), (_VALUE), (_SIZE) ); } \
		} while( 0 );

#define MT_MEMCPY( _DST_PTR, _SRC_PTR, _SIZE ) \
		do \
		{ \
			SCI_ASSERT( (_DST_PTR) ); \
			SCI_ASSERT( (_SRC_PTR) ); \
			if( (_SIZE) > 0 ) { memcpy( (_DST_PTR), (_SRC_PTR), (_SIZE) ); } \
		} while( 0 );

#define MT_MEMMOV( _DST_PTR, _SRC_PTR, _SIZE ) \
		do \
		{ \
			SCI_ASSERT( (_DST_PTR) ); \
			SCI_ASSERT( (_SRC_PTR) ); \
			if( (_SIZE) > 0 ) { memmove( (_DST_PTR), (_SRC_PTR), (_SIZE) ); } \
		} while( 0 );

#define MT_MEMCMP( _DST_PTR, _SRC_PTR, _SIZE ) \
		( \
			SCI_ASSERT( (_DST_PTR) ), \
			SCI_ASSERT( (_SRC_PTR) ), \
			( (_SIZE) > 0 ) ? ( memcmp( (_DST_PTR), (_SRC_PTR), (_SIZE) ) ) : ( 0 ) \
		)

// #define MT_MEMCMP mt_memcmp

// #undef SCI_MEMSET
// #undef SCI_MEMCPY

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

void mt_tracei( const char *format, ... );
void mt_tracex( const char *format, ... );

#ifdef MT_TRACE_SLEEP
	#define mt_trace mt_tracex
#else
	#define mt_trace mt_tracei
#endif

void mt_trace_f( const char *format, ... );

#ifdef MT_DEBUG
	#define MT_TRACE				mt_trace
#else
	#ifdef _WIN32
		#define MT_TRACE			1 ? (void)0 : mt_trace // (void)
	#else
		#define MT_TRACE(...)		do{} while(0)
	#endif
#endif

#define MT_TRACE_F mt_trace_f
#define MT_TRACE_HIGH SCI_TraceHigh

void MT_TRACE_TO_FILE(char *buffer, uint32 length, const char *filename);
////////////////////////////////////////////////////////////////

void *mt_malloc( size_t size, const char *file, uint32 line, uint8 flags ); // flags >0 - reuse
void  mt_free( void *memblock, const char *file, uint32 line );
void  mt_mstat( void );

#ifdef MT_DEBUG
	#define MT_ALLOC( _SIZE )		mt_malloc( (_SIZE), __FILE__, __LINE__, 0 )
	#define MT_FREE(_MEM_PTR)		mt_free((_MEM_PTR), __FILE__, __LINE__)
	#define MT_MSTAT				mt_mstat
#else
	#define MT_ALLOC				SCI_ALLOC
	#define MT_FREE					SCI_FREE
	#define MT_MSTAT				1 ? (void)0 : mt_mstat // (void)
#endif

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

#ifdef __cplusplus
    }
#endif

#endif // _MT_OSAPI_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -