Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.3 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dpf.h
  6. * Content: header file for debug printf
  7. *@@BEGIN_MSINTERNAL
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 06-apr-95 craige initial implementation
  12. * 06-feb-96 colinmc added simple assertion mechanism for DirectDraw
  13. * 15-apr-96 kipo added msinternal
  14. *@@END_MSINTERNAL
  15. *
  16. ***************************************************************************/
  17. #ifdef NEW_DPF
  18. #include "newdpf.h"
  19. #else
  20. #ifndef __DPF_INCLUDED__
  21. #define __DPF_INCLUDED__
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. #ifdef WINNT
  26. #undef DEBUG
  27. #ifdef DBG
  28. #define DEBUG
  29. #endif
  30. #endif
  31. extern void cdecl DXdprintf( UINT lvl, LPSTR szFormat, ...);
  32. extern void cdecl D3DInfoPrintf( UINT lvl, LPSTR szFormat, ...);
  33. extern void cdecl D3DWarnPrintf( UINT lvl, LPSTR szFormat, ...);
  34. extern void cdecl D3DErrorPrintf( LPSTR szFormat, ...);
  35. extern void DPFInit( void );
  36. #ifdef DEBUG
  37. #define DPF_DECLARE(szName) char * __pszDpfName=#szName":"
  38. #define DPFINIT() DPFInit()
  39. #define DPF DXdprintf
  40. #define DPF_ERR(a) DXdprintf( 0, DPF_MODNAME ": " a );
  41. extern HWND hWndListBox;
  42. #if defined( _WIN32 ) && !defined(WINNT)
  43. #define DEBUG_BREAK() _try { _asm { int 3 } } _except (EXCEPTION_EXECUTE_HANDLER) {;}
  44. #else
  45. #define DEBUG_BREAK() DebugBreak()
  46. #endif
  47. #define USE_DDASSERT
  48. // New for D3D
  49. #define D3D_ERR D3DErrorPrintf
  50. #define D3D_WARN D3DWarnPrintf
  51. #define D3D_INFO D3DInfoPrintf
  52. #else
  53. #pragma warning(disable:4002)
  54. #define DPF_DECLARE(szName)
  55. #define DPFINIT()
  56. #define DPF()
  57. #define DPF_ERR(a)
  58. #define DEBUG_BREAK()
  59. #define D3D_ERR(a)
  60. #define D3D_WARN()
  61. #define D3D_INFO()
  62. #endif
  63. #if defined(DEBUG) && defined(USE_DDASSERT)
  64. extern void _DDAssert(LPCSTR szFile, int nLine, LPCSTR szCondition);
  65. #define DDASSERT(condition) if (!(condition)) _DDAssert(__FILE__, __LINE__, #condition)
  66. #else /* DEBUG && USE_DDASSERT */
  67. #define DDASSERT(condition)
  68. #endif /* DEBUG && USE_DDASSERT */
  69. #ifdef _WIN32
  70. #ifdef DEBUG
  71. __inline DWORD clockrate() {LARGE_INTEGER li; QueryPerformanceFrequency(&li); return li.LowPart;}
  72. __inline DWORD perf_clock() {LARGE_INTEGER li; QueryPerformanceCounter(&li); return li.LowPart;}
  73. #define TIMEVAR(t) DWORD t ## T; DWORD t ## N
  74. #define TIMEZERO(t) t ## T = 0, t ## N = 0
  75. #define TIMESTART(t) t ## T -= perf_clock(), t ## N ++
  76. #define TIMESTOP(t) t ## T += perf_clock()
  77. #define TIMEFMT(t) ((DWORD)(t) / clockrate()), (((DWORD)(t) * 1000 / clockrate())%1000)
  78. #define TIMEOUT(t) if (t ## N) DPF(1, #t ": %ld calls, %ld.%03ld sec (%ld.%03ld)", t ## N, TIMEFMT(t ## T), TIMEFMT(t ## T / t ## N))
  79. #else
  80. #define TIMEVAR(t)
  81. #define TIMEZERO(t)
  82. #define TIMESTART(t)
  83. #define TIMESTOP(t)
  84. #define TIMEFMT(t)
  85. #define TIMEOUT(t)
  86. #endif
  87. #endif
  88. #ifdef __cplusplus
  89. }
  90. #endif
  91. #endif
  92. #endif //use new dpf