hxassert.h

来自「Amarok是一款在LINUX或其他类UNIX操作系统中运行的音频播放器软件。 」· C头文件 代码 · 共 728 行 · 第 1/2 页

H
728
字号
/* * * This software is released under the provisions of the GPL version 2. * see file "COPYING".  If that file is not available, the full statement  * of the license can be found at * * http://www.fsf.org/licensing/licenses/gpl.txt * * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. * *//////////////////////////////////////////////////////////////////////////////// HXASSERT.H//// Debugging support header.//// HX_ASSERT()	- asserts an expression is TRUE. Compiles to no-ops in//				retail builds. Provides message box or other UI when //				expression fails.//// HX_ASSERT_VALID_PTR() - asserts that a pointer is valid. Performs more//				rigid verification specifically appropriate for pointers.//// HX_VERIFY()	- verifies an expression is TRUE. Expression or code DOES NOT //				compile away in retail builds, but UI of failure is removed.//				In debug builds provides message box or other UI when //				expression fails.//// HX_TRACE()	- Similar to DEBUGPRINTF() but no buffer is required. //				Compiles to no-ops in retail builds.//#ifndef _HXASSERT_H_#define _HXASSERT_H_#include "hlxclib/assert.h"#ifndef ASSERT#if defined (DEBUG) || defined (_DEBUG)#if defined (_OSF1) && defined (_NATIVE_COMPILER)#	define ASSERT(x)	assert(((long)(x)) != 0L)#else#       define ASSERT(x)        assert(x)#endif#else#	define ASSERT(x)	/* x */#endif /* DEBUG */#endif /* ndef ASSERT */#include "hlxclib/limits.h"#include "hxtypes.h"#include "hxresult.h"           // for HX_RESULT#include "hlxclib/stdio.h"      // for sprintf#ifdef _SUN#include <stddef.h>     // for size_t#endif#ifdef __cplusplusextern "C" {#endif#if defined (_SOLARIS) || defined (_IRIX) || defined (_DECALPHA)#ifndef __inline#define __inline inline#endif#endif#if defined (_OSF1) && defined (_NATIVE_COMPILER)#if defined __cplusplus#define __inline inline#else#define __inline static#endif /* __cplusplus */#endif#ifdef _HPUX #if defined __cplusplus#define __inline inline#else#define __inline #endif /* __cplusplus */#endif#if defined _AIX#if defined __cplusplus#define __inline inline#else#define __inline #endif /* __cplusplus */#endif /* _AIX */#ifdef _UNIX#include <signal.h> /* For kill() */#include <unistd.h> /* For getpid() */#include <stdio.h>void HXUnixDebugBreak();#endif/////////////////////////////////////////////////////////////////////////////// Diagnostic support// For _MAX_PATH#if defined ( _MACINTOSH )#include "platform/mac/maclibrary.h"#elif defined (_UNIX)#include <stdlib.h>#if !defined(_VXWORKS)#include <sys/param.h>#endif#define _MAX_PATH       MAXPATHLEN#elif defined (_WINDOWS)#include <stdlib.h>#endif#ifdef _SYMBIAN# include <unistd.h># define _MAX_PATH MAXPATHLEN#endif#ifdef _OPENWAVE#ifndef _MAX_PATH#define _MAX_PATH 256#endif#endif#if defined (DEBUG) || defined (_DEBUG)#ifdef _MACINTOSH#  define MAX_TRACE_OUTPUT  255#else# ifdef _UNIX#  define MAX_TRACE_OUTPUT  255# elif _WIN16#  define MAX_TRACE_OUTPUT  255# elif _SYMBIAN#  define MAX_TRACE_OUTPUT  255# else#  define MAX_TRACE_OUTPUT  (_MAX_PATH*2 + 20)# endif#endif/////////////////////////////////////////////////////////////////////////////////	HXDebugOptionEnabled: //		Determine if the given debug option is enabled.//		A lookup is done to the registry key, and if it's present//		and set to '1', TRUE is returned otherwise FALSE//		Similar to HXWantTraceMessages, except not specific to one option.#ifdef _WIN16// The STDMETHODCALLTYPE includes the _export keyword, even though this is// a static, not dll, library.  Seems to work on win32 ok, but not a win16// .exe.  rpapp would see this as duplicate symbol, until the _export was// removed, and all the libraries that rpapp linked with rebuilt.  There// may be a define for STDMETHODCALLTYPE without the _export that should be// used here. XXXTW.  april 98.HXBOOL far _cdecl HXDebugOptionEnabled(const char* szOption);#elseHXBOOL STDMETHODCALLTYPE HXDebugOptionEnabled(const char* szOption);#endif/////////////////////////////////////////////////////////////////////////////////	HXWantTraceMessages: //		Helper function used to determine if the system has asked for trace //		messages.//HXBOOL STDMETHODCALLTYPE HXWantTraceMessages();/////////////////////////////////////////////////////////////////////////////////	HXOutputDebugString: //		Helper function used by DEBUGOUTSTR(). This is better than //		OutputDebugString, because it will check to see if output//		tracing is turned off in the registry. This prevents the massive//		slew of output messages.//void STDMETHODCALLTYPE HXOutputDebugString(const char* pString);///////////////////////////////////////////////////////////////////////////////// HXTrace: Helper function used by HX_TRACE()//void STDMETHODVCALLTYPE HXTrace(const char* pszFormat, ...);///////////////////////////////////////////////////////////////////////////////// HXAssertFailedLine: Helper function used by HX_ASSERT()//#ifdef _WIN16// The STDMETHODCALLTYPE includes the _export keyword, even though this is// a static, not dll, library.  Seems to work on win32 ok, but not a win16// .exe.  rpapp would see this as duplicate symbol, until the _export was// removed, and all the libraries that rpapp linked with rebuilt.  There// may be a define for STDMETHODCALLTYPE without the _export that should be// used here. XXXTW.  april 98.HXBOOL far _cdecl HXAssertFailedLine(const char* pszExpression, const char* pszFileName, int nLine);#elseHXBOOL STDMETHODCALLTYPE HXAssertFailedLine(const char* pszExpression, const char* pszFileName, int nLine);#endif///////////////////////////////////////////////////////////////////////////////// HXAssertValidPointer, HXIsValidAddress: Helper functions used by// HX_ASSERT_VALID_PTR()//void STDMETHODCALLTYPE HXAssertValidPointer(const void* pVoid, const char* pszFileName, int nLine);#ifdef __cplusplus#ifdef _WIN16    // see note above on the problem with STDMETHODCALLTYPE on win16    HXBOOL far _cdecl        HXIsValidAddress(const void* lp, ULONG32 nBytes = 1, HXBOOL bReadWrite = TRUE);#else    HXBOOL STDMETHODCALLTYPE HXIsValidAddress(const void* lp, ULONG32 nBytes = 1, HXBOOL bReadWrite = TRUE);#endif#else#ifdef _WIN16    // see note above on the problem with STDMETHODCALLTYPE on win16    HXBOOL far _cdecl        HXIsValidAddress(const void* lp, ULONG32 nBytes, HXBOOL bReadWrite);#else    HXBOOL STDMETHODCALLTYPE HXIsValidAddress(const void* lp, ULONG32 nBytes, HXBOOL bReadWrite);#endif#endif#ifdef _WIN16HXBOOL far _cdecl        HXIsValidString(const char* lpsz, int nLength);#elseHXBOOL STDMETHODCALLTYPE HXIsValidString(const char* lpsz, int nLength);#endif///////////////////////////////////////////////////////////////////////////////// HXDebugBreak: used to break into debugger at critical times//#ifndef HXDebugBreak// by default, debug break is asm int 3, or a call to DebugBreak, or nothing#if defined(_WINDOWS)#if !defined(_M_IX86)#include "windows.h"#define HXDebugBreak() DebugBreak()#else#define HXDebugBreak() _asm { int 3 }#endif // _M_ALPHA#elif defined( _MACINTOSH )#define HXDebugBreak() Debugger()#elif defined(_OPENWAVE)#if defined(_OPENWAVE_SIMULATOR) // windows app...#define HXDebugBreak() _asm { int 3 }#elsevoid HXDebugBreak();#endif#elif defined(_SYMBIAN)#if defined(__WINS__)#define HXDebugBreak() _asm { int 3 }#elsevoid HXDebugBreak();#endif //_SYMBIAN#elif  defined(_UNIX)void HXDebugBreak();#elif defined(_VXWORKS)#include <taskLib.h>#define HXDebugBreak() (taskSuspend(taskIdSelf()))#endif // end of#if defined(_WIN32) || defined(_WINDOWS)#endif // end of#ifndef HXDebugBreak#ifdef _UNIX#include "signal.h"#include "stdlib.h"#define HX_ENABLE_JIT_DEBUGGING()               \do {						\    signal (SIGSEGV, (void (*)(int))HXDebugBreak);		\    signal (SIGBUS,  (void (*)(int))HXDebugBreak);		\    signal (SIGFPE,  (void (*)(int))HXDebugBreak);		\    if (!getenv("PROCESS_NAME"))                \    {                                           \    char *progname = new char[strlen(argv[0]) + 30]; \    sprintf(progname, "PROCESS_NAME=%s", argv[0]); /* Flawfinder: ignore */ \    putenv(progname);                           \    } \} while (0);#else#define HX_ENABLE_JIT_DEBUGGING()#endif///////////////////////////////////////////////////////////////////////////////// HXAbort: used to shut down the application at critical times//#ifndef HXAbort#if (defined(_WIN32) || defined(_WINDOWS)) && !defined(WIN32_PLATFORM_PSPC)# define HXAbort() 	abort()#elif defined(WIN32_PLATFORM_PSPC)# define HXAbort()   exit(1)#elif defined(_SYMBIAN)# define HXAbort() exit(1)#elif defined(_OPENWAVE)// XXXSAB is this right??# define HXAbort() exit(1)#elif defined ( _MACINTOSH )# define HXAbort() DebugStr("\pHXAbort: Please exit this program.")#elif defined ( _UNIX )# define HXAbort() printf("\npnabort: Please exit this program.\n")#endif // end of#if defined(_WIN32) || defined(_WINDOWS)#endif // end of#ifndef HXAbort///////////////////////////////////////////////////////////////////////////////// HX_TRACE: see above.//#define HX_TRACE			::HXTrace///////////////////////////////////////////////////////////////////////////////// HX_ASSERT: see above.//#define HX_ASSERT(f) \	do \	{ \	if (!(f) && HXAssertFailedLine(#f, __FILE__, __LINE__)) \		HXDebugBreak(); \	} while (0) \#define REQUIRE_REPORT(targ,file,line)	HXAssertFailedLine(targ,file,line)/////////////////////////////////////////////////////////////////////////////////	Macros Defined for logging messges in the player. //  //  STARTLOGSINK: Query for an IHXErrorSink////  LOGINFO: Report the error to the error sink////  STOPLOGSINK: Shutdown and Release the error sink.	       ///////////////////////////////////////////////////////////////////////////////#ifndef _GOLD#ifndef _INTERFACE#define _INTERFACE struct#endiftypedef _INTERFACE IHXErrorMessages IHXErrorMessages;    const char*	    FileAndLine(const char* pFile, UINT32 ulLine);    HX_RESULT	    HXLogf(IHXErrorMessages *pErr, UINT8 sev, HX_RESULT err, UINT32 usr, const char* pURL, const char* pUsrStr, ...);    HX_RESULT	    HXLog(IHXErrorMessages *pErr, UINT8 sev, HX_RESULT err, UINT32 usr, const char* pStr, const char* pURL);#define THIS_LINE() FileAndLine(__FILE__, __LINE__)

⌨️ 快捷键说明

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