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.

116 lines
3.1 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // File: cmtiming.h
  4. //
  5. // Module: CMDIAL32.DLL and CMMGR32.EXE
  6. //
  7. // Synopsis: Header file for timing functions.
  8. //
  9. // Copyright (c) 1998 Microsoft Corporation
  10. //
  11. // Author: nickball Created 04/28/98
  12. //
  13. //+----------------------------------------------------------------------------
  14. #ifndef _CM_TIMING_INC
  15. #define _CM_TIMING_INC
  16. //
  17. // Add the following to the sources file of the target module to activate timing macros.
  18. //
  19. // C_DEFINES = -DCM_TIMING_ON
  20. //
  21. // NOTE: Never check in a sources file with this flag defined
  22. //
  23. #ifdef CM_TIMING_ON // For timing test only
  24. #define CM_SET_TIMING_INTERVAL(x) SetTimingInterval(x)
  25. //
  26. // Defintions
  27. //
  28. #define MAX_TIMING_INTERVALS 50
  29. #define CM_TIMING_TABLE_NAME "CM TIMING TABLE"
  30. //
  31. // Custom types for table
  32. //
  33. typedef struct Cm_Timing_Interval
  34. {
  35. TCHAR szName[MAX_PATH]; // Name of timing interval
  36. DWORD dwTicks; // TickCount
  37. } CM_TIMING_INTERVAL, *LPCM_TIMING_INTERVAL;
  38. typedef struct Cm_Timing_Table
  39. {
  40. int iNext; // Next available entry
  41. CM_TIMING_INTERVAL Intervals[MAX_TIMING_INTERVALS]; // a list of intervals
  42. } CM_TIMING_TABLE, * LPCM_TIMING_TABLE;
  43. //+----------------------------------------------------------------------------
  44. //
  45. // Function: SetTimingInterval
  46. //
  47. // Synopsis: A simple wrapper to encapsulate the process of updating the
  48. // timing table with an interval entry.
  49. //
  50. // Arguments: char *szIntervalName - The optional name of the entry, the entry number is used if NULL
  51. //
  52. // Returns: void - Nothing
  53. //
  54. // History: nickball 4/7/98 Created
  55. //
  56. //+----------------------------------------------------------------------------
  57. inline void SetTimingInterval(char *szIntervalName)
  58. {
  59. HANDLE hMap = OpenFileMapping(FILE_MAP_READ | FILE_MAP_WRITE, FALSE, CM_TIMING_TABLE_NAME);
  60. if (hMap)
  61. {
  62. //
  63. // File mapping opened successfully, map a view of it.
  64. //
  65. LPCM_TIMING_TABLE pTable = (LPCM_TIMING_TABLE) MapViewOfFile(hMap,
  66. FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, 0);
  67. if (pTable)
  68. {
  69. if (pTable->iNext < MAX_TIMING_INTERVALS)
  70. {
  71. //
  72. // Update the next available entry
  73. //
  74. if (szIntervalName)
  75. {
  76. lstrcpy(pTable->Intervals[pTable->iNext].szName, szIntervalName);
  77. }
  78. else
  79. {
  80. wsprintf(pTable->Intervals[pTable->iNext].szName, "(%d)", pTable->iNext);
  81. }
  82. pTable->Intervals[pTable->iNext].dwTicks = GetTickCount();
  83. pTable->iNext++;
  84. }
  85. UnmapViewOfFile(pTable);
  86. }
  87. CloseHandle(hMap);
  88. }
  89. }
  90. #else // CM_TIMING_ON
  91. #define CM_SET_TIMING_INTERVAL(x)
  92. #endif
  93. #endif // _CM_TIMING_INC