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.

95 lines
2.9 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 DPFINIT() DPFInit()
  35. #define DPF dprintf
  36. #define DPF_ERR(a) dprintf( 0, DPF_MODNAME ": " a );
  37. extern HWND hWndListBox;
  38. #if defined( _WIN32 ) && !defined(WINNT)
  39. #define DEBUG_BREAK() _try { _asm { int 3 } } _except (EXCEPTION_EXECUTE_HANDLER) {;}
  40. #else
  41. #define DEBUG_BREAK() DebugBreak()
  42. #endif
  43. #define USE_DDASSERT
  44. #else
  45. #pragma warning(disable:4002)
  46. #define DPFINIT()
  47. #define DPF()
  48. #define DPF_ERR(a)
  49. #define DEBUG_BREAK()
  50. #endif
  51. #if defined(DEBUG) && defined(USE_DDASSERT)
  52. extern void _DDAssert(LPCSTR szFile, int nLine, LPCSTR szCondition);
  53. #define DDASSERT(condition) if (!(condition)) _DDAssert(__FILE__, __LINE__, #condition)
  54. #else /* DEBUG && USE_DDASSERT */
  55. #define DDASSERT(condition)
  56. #endif /* DEBUG && USE_DDASSERT */
  57. #ifdef _WIN32
  58. #ifdef DEBUG
  59. __inline DWORD clockrate() {LARGE_INTEGER li; QueryPerformanceFrequency(&li); return li.LowPart;}
  60. __inline DWORD clock() {LARGE_INTEGER li; QueryPerformanceCounter(&li); return li.LowPart;}
  61. #define TIMEVAR(t) DWORD t ## T; DWORD t ## N
  62. #define TIMEZERO(t) t ## T = 0, t ## N = 0
  63. #define TIMESTART(t) t ## T -= clock(), t ## N ++
  64. #define TIMESTOP(t) t ## T += clock()
  65. #define TIMEFMT(t) ((DWORD)(t) / clockrate()), (((DWORD)(t) * 1000 / clockrate())%1000)
  66. #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))
  67. #else
  68. #define TIMEVAR(t)
  69. #define TIMEZERO(t)
  70. #define TIMESTART(t)
  71. #define TIMESTOP(t)
  72. #define TIMEFMT(t)
  73. #define TIMEOUT(t)
  74. #endif
  75. #endif
  76. #ifdef __cplusplus
  77. }
  78. #endif
  79. #endif
  80. #endif //use new dpf