📄 hxassert.h
字号:
/* ***** BEGIN LICENSE BLOCK ***** * Source last modified: $Id: hxassert.h,v 1.15.8.3 2004/07/09 01:46:15 hubbe Exp $ * * Portions Copyright (c) 1995-2004 RealNetworks, Inc. All Rights Reserved. * * The contents of this file, and the files included with this file, * are subject to the current version of the RealNetworks Public * Source License (the "RPSL") available at * http://www.helixcommunity.org/content/rpsl unless you have licensed * the file under the current version of the RealNetworks Community * Source License (the "RCSL") available at * http://www.helixcommunity.org/content/rcsl, in which case the RCSL * will apply. You may also obtain the license terms directly from * RealNetworks. You may not use this file except in compliance with * the RPSL or, if you have a valid RCSL with RealNetworks applicable * to this file, the RCSL. Please see the applicable RPSL or RCSL for * the rights, obligations and limitations governing use of the * contents of the file. * * Alternatively, the contents of this file may be used under the * terms of the GNU General Public License Version 2 or later (the * "GPL") in which case the provisions of the GPL are applicable * instead of those above. If you wish to allow use of your version of * this file only under the terms of the GPL, and not to allow others * to use your version of this file under the terms of either the RPSL * or RCSL, indicate your decision by deleting the provisions above * and replace them with the notice and other provisions required by * the GPL. If you do not delete the provisions above, a recipient may * use your version of this file under the terms of any one of the * RPSL, the RCSL or the GPL. * * This file is part of the Helix DNA Technology. RealNetworks is the * developer of the Original Code and owns the copyrights in the * portions it created. * * This file, and the files included with this file, is distributed * and made available on an 'AS IS' basis, WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESS OR IMPLIED, AND REALNETWORKS HEREBY DISCLAIMS * ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET * ENJOYMENT OR NON-INFRINGEMENT. * * Technology Compatibility Kit Test Suite(s) Location: * http://www.helixcommunity.org/content/tck * * Contributor(s): * * ***** END LICENSE BLOCK ***** *//////////////////////////////////////////////////////////////////////////////// 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.BOOL far _cdecl HXDebugOptionEnabled(const char* szOption);#elseBOOL STDMETHODCALLTYPE HXDebugOptionEnabled(const char* szOption);#endif///////////////////////////////////////////////////////////////////////////////// HXWantTraceMessages: // Helper function used to determine if the system has asked for trace // messages.//BOOL 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.BOOL far _cdecl HXAssertFailedLine(const char* pszExpression, const char* pszFileName, int nLine);#elseBOOL 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 BOOL far _cdecl HXIsValidAddress(const void* lp, ULONG32 nBytes = 1, BOOL bReadWrite = TRUE);#else BOOL STDMETHODCALLTYPE HXIsValidAddress(const void* lp, ULONG32 nBytes = 1, BOOL bReadWrite = TRUE);#endif#else#ifdef _WIN16 // see note above on the problem with STDMETHODCALLTYPE on win16 BOOL far _cdecl HXIsValidAddress(const void* lp, ULONG32 nBytes, BOOL bReadWrite);#else BOOL STDMETHODCALLTYPE HXIsValidAddress(const void* lp, ULONG32 nBytes, BOOL bReadWrite);#endif#endif#ifdef _WIN16BOOL far _cdecl HXIsValidString(const char* lpsz, int nLength);#elseBOOL 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
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -