Leaked source code of windows server 2003
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.

105 lines
3.4 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. #ifndef __DPF_INCLUDED__
  18. #define __DPF_INCLUDED__
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #ifdef WINNT
  23. #undef DEBUG
  24. #ifdef DBG
  25. #define DEBUG
  26. #endif
  27. #endif
  28. extern void cdecl DXdprintf( UINT lvl, LPSTR szFormat, ...);
  29. extern void cdecl D3DInfoPrintf( UINT lvl, LPSTR szFormat, ...);
  30. extern void cdecl D3DWarnPrintf( UINT lvl, LPSTR szFormat, ...);
  31. extern void cdecl D3DErrorPrintf( LPSTR szFormat, ...);
  32. extern void DPFInit( void );
  33. #ifdef DEBUG
  34. #define DPF_DECLARE(szName) char * __pszDpfName=#szName":"
  35. #define DPFINIT() DPFInit()
  36. #define DPF DXdprintf
  37. #define DPF_ERR(a) DXdprintf( 0, DPF_MODNAME ": " a );
  38. extern HWND hWndListBox;
  39. #if defined( _WIN32 ) && !defined(WINNT)
  40. #define DEBUG_BREAK() _try { _asm { int 3 } } _except (EXCEPTION_EXECUTE_HANDLER) {;}
  41. #else
  42. #define DEBUG_BREAK() DebugBreak()
  43. #endif
  44. #define USE_DDASSERT
  45. // New for D3D
  46. #define D3D_ERR D3DErrorPrintf
  47. #define D3D_WARN D3DWarnPrintf
  48. #define D3D_INFO D3DInfoPrintf
  49. #else
  50. #pragma warning(disable:4002)
  51. #define DPF_DECLARE(szName)
  52. #define DPFINIT()
  53. #define DPF()
  54. #define DPF_ERR(a)
  55. #define DEBUG_BREAK()
  56. #define D3D_ERR(a)
  57. #define D3D_WARN()
  58. #define D3D_INFO()
  59. #endif
  60. #if defined(DEBUG) && defined(USE_DDASSERT)
  61. extern void _DDAssert(LPCSTR szFile, int nLine, LPCSTR szCondition);
  62. #define DDASSERT(condition) if (!(condition)) _DDAssert(__FILE__, __LINE__, #condition)
  63. #else /* DEBUG && USE_DDASSERT */
  64. #define DDASSERT(condition)
  65. #endif /* DEBUG && USE_DDASSERT */
  66. #ifdef _WIN32
  67. #ifdef DEBUG
  68. __inline DWORD clockrate() {LARGE_INTEGER li; QueryPerformanceFrequency(&li); return li.LowPart;}
  69. __inline DWORD perf_clock() {LARGE_INTEGER li; QueryPerformanceCounter(&li); return li.LowPart;}
  70. #define TIMEVAR(t) DWORD t ## T; DWORD t ## N
  71. #define TIMEZERO(t) t ## T = 0, t ## N = 0
  72. #define TIMESTART(t) t ## T -= perf_clock(), t ## N ++
  73. #define TIMESTOP(t) t ## T += perf_clock()
  74. #define TIMEFMT(t) ((DWORD)(t) / clockrate()), (((DWORD)(t) * 1000 / clockrate())%1000)
  75. #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))
  76. #else
  77. #define TIMEVAR(t)
  78. #define TIMEZERO(t)
  79. #define TIMESTART(t)
  80. #define TIMESTOP(t)
  81. #define TIMEFMT(t)
  82. #define TIMEOUT(t)
  83. #endif
  84. #endif
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif