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.

97 lines
2.6 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 dprintf( UINT lvl, 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 dprintf
  37. #define DPF_ERR(a) dprintf( 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. #else
  46. #pragma warning(disable:4002)
  47. #define DPF_DECLARE(szName)
  48. #define DPFINIT()
  49. #define DPF()
  50. #define DPF_ERR(a)
  51. #define DEBUG_BREAK()
  52. #endif
  53. #if defined(DEBUG) && defined(USE_DDASSERT)
  54. extern void _DDAssert(LPCSTR szFile, int nLine, LPCSTR szCondition);
  55. #define DDASSERT(condition) if (!(condition)) _DDAssert(__FILE__, __LINE__, #condition)
  56. #else /* DEBUG && USE_DDASSERT */
  57. #define DDASSERT(condition)
  58. #endif /* DEBUG && USE_DDASSERT */
  59. #ifdef _WIN32
  60. #ifdef DEBUG
  61. __inline DWORD clockrate() {LARGE_INTEGER li; QueryPerformanceFrequency(&li); return li.LowPart;}
  62. __inline DWORD clock() {LARGE_INTEGER li; QueryPerformanceCounter(&li); return li.LowPart;}
  63. #define TIMEVAR(t) DWORD t ## T; DWORD t ## N
  64. #define TIMEZERO(t) t ## T = 0, t ## N = 0
  65. #define TIMESTART(t) t ## T -= clock(), t ## N ++
  66. #define TIMESTOP(t) t ## T += clock()
  67. #define TIMEFMT(t) ((DWORD)(t) / clockrate()), (((DWORD)(t) * 1000 / clockrate())%1000)
  68. #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))
  69. #else
  70. #define TIMEVAR(t)
  71. #define TIMEZERO(t)
  72. #define TIMESTART(t)
  73. #define TIMESTOP(t)
  74. #define TIMEFMT(t)
  75. #define TIMEOUT(t)
  76. #endif
  77. #endif
  78. #ifdef __cplusplus
  79. }
  80. #endif
  81. #endif
  82. #endif //use new dpf