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.

168 lines
5.8 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // File: Icecap.h
  4. // Copyright (C) 1997-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This header file is part of IceCAP 4.0.0382. It is
  8. // MICROSOFT CONFIDENTIAL, and should not be distributed except under NDA.
  9. //
  10. //-----------------------------------------------------------------------------
  11. // ICECAP.H
  12. // interface to the Datalocality APIs
  13. #ifndef __ICECAP_H__
  14. #define __ICECAP_H__
  15. #ifndef DONTUSEICECAPLIB
  16. #pragma comment(lib, "IceCAP.lib")
  17. #endif // USEICECAPLIB
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. // Defines for Levels and Id's
  22. #define PROFILE_GLOBALLEVEL 1
  23. #define PROFILE_PROCESSLEVEL 2
  24. #define PROFILE_THREADLEVEL 3
  25. #define PROFILE_CURRENTID ((unsigned long)0xFFFFFFFF)
  26. // Start/Stop Api's
  27. int _declspec(dllimport) _stdcall StopProfile(int nLevel, unsigned long dwId);
  28. int _declspec(dllimport) _stdcall StartProfile(int nLevel, unsigned long dwId);
  29. // Suspend/Resume Api's
  30. int _declspec(dllimport) _stdcall SuspendProfile(int nLevel, unsigned long dwId);
  31. int _declspec(dllimport) _stdcall ResumeProfile(int nLevel, unsigned long dwId);
  32. // Mark Api's
  33. int _declspec(dllimport) _stdcall MarkProfile(long lMarker);
  34. // xxxProfile return codes
  35. #define PROFILE_OK 0 // xxxProfile call successful
  36. #define PROFILE_ERROR_NOT_YET_IMPLEMENTED 1 // api or level,id combination not supported yet
  37. #define PROFILE_ERROR_MODE_NEVER 2 // mode was never when called
  38. #define PROFILE_ERROR_LEVEL_NOEXIST 3 // level doesn't exist
  39. #define PROFILE_ERROR_ID_NOEXIST 4 // id doesn't exist
  40. // MarkProfile return codes
  41. #define MARK_OK 0 // Mark was taken successfully
  42. #define MARK_ERROR_MODE_NEVER 1 // Profiling was never when MarkProfile called
  43. #define MARK_ERROR_PRO_OFF 2 // old define until tests fixed
  44. #define MARK_ERROR_MODE_OFF 2 // Profiling was off when MarkProfile called
  45. #define MARK_ERROR_MARKER_RESERVED 3 // Mark value passed is a reserved value
  46. // Icecap 3.x Compatibility defines
  47. #define StartCAP() StartProfile(PROFILE_THREADLEVEL, PROFILE_CURRENTID)
  48. #define StopCAP() StopProfile(PROFILE_THREADLEVEL, PROFILE_CURRENTID)
  49. #define SuspendCAP() SuspendProfile(PROFILE_THREADLEVEL, PROFILE_CURRENTID)
  50. #define ResumeCAP() ResumeProfile(PROFILE_THREADLEVEL, PROFILE_CURRENTID)
  51. #define StartCAPAll() StartProfile(PROFILE_PROCESSLEVEL, PROFILE_CURRENTID)
  52. #define StopCAPAll() StopProfile(PROFILE_PROCESSLEVEL, PROFILE_CURRENTID)
  53. #define SuspendCAPAll() SuspendProfile(PROFILE_PROCESSLEVEL, PROFILE_CURRENTID)
  54. #define ResumeCAPAll() ResumeProfile(PROFILE_PROCESSLEVEL, PROFILE_CURRENTID)
  55. #define MarkCAP(mark) MarkProfile(mark)
  56. // DataLocality 1.x Compatibility defines
  57. #define StartDLP() StartCAP()
  58. #define StopDLP() StopCAP()
  59. #define MarkDLP(mark) MarkCAP(mark)
  60. //
  61. // USER DEFINED COUNTER HELPERS AND TYPES
  62. //
  63. // COUNTER_FUNCTION_PROLOGE and EPILOGE
  64. //
  65. // These functions are supplied to protect the state of registers
  66. // that the IceCAP collection probes rely on. We did everything we
  67. // could to eliminate instructions during collection. Your mission,
  68. // if you choose to accept it, is the same.
  69. //
  70. #define COUNTER_FUNCTION_PROLOGE _asm push ecx _asm push ebx _asm push ebp
  71. #define COUNTER_FUNCTION_EPILOGE _asm pop ebp _asm pop ebx _asm pop ecx _asm ret
  72. #ifndef USER_COUNTER_INFO_DEFINED
  73. #define USER_COUNTER_INFO_DEFINED
  74. // CONSTS AND ENUMS
  75. //
  76. // UserCounterType
  77. //
  78. // These enumerations describe how the counter works.
  79. //
  80. // MonotonicallyIncreasing -- This describes a counter that will increment
  81. // by one each time some 'event' occurs. An
  82. // example would be a counter that tracks the
  83. // number of memory allocations. Each allocation
  84. // increments the number by one.
  85. //
  86. // MonotonicallyDecreasint -- This describes a counter that will decrement
  87. // by one each time some 'event' occurs. An
  88. // example would be a counter that tracks a limited
  89. // resource. Each use of the resource decrements
  90. // the number by one.
  91. //
  92. // RandomIncreasing -- This describes a counter that will increase for
  93. // each 'event' that occurs, but by an undetermined
  94. // amount. An example would be the total memory
  95. // allocated. Each allocation would add it's size
  96. // to the counter, but each allocation being potentially
  97. // different, causes the counter to go up by a random
  98. // amount each time.
  99. //
  100. // RandomDecreasing -- This describes a coutner that will decrease for
  101. // each 'event' that occurs, but by an undetermined
  102. // amount. An example would be a limited resource
  103. // that can be used in bunches. Each use fo the
  104. // the resource would cause the number to descrease
  105. // by a random amount.
  106. //
  107. // Random -- This number can either go up, or go down. An
  108. // example would be the total amount of available
  109. // memory, which can either go up (as memory is
  110. // free'd), or go down (as memory is allocated).
  111. //
  112. enum UserCounterType
  113. {
  114. MonotonicallyIncreasing,
  115. MonotonicallyDecreasing,
  116. RandomIncreasing,
  117. RandomDecreasing,
  118. Random
  119. };
  120. // TYPEDEFS
  121. //
  122. typedef signed __int64 COUNTER, *PCOUNTER;
  123. ///////////////////////////////////////////////////////////////
  124. // USERCOUNTERINFO
  125. //
  126. // This structure descibes a user defined counter so that
  127. // IceCAP can use it during profiling runs.
  128. //
  129. // History: 9-21-98 BarryNo Created
  130. //
  131. ///////////////////////////////////////////////////////////////
  132. typedef struct _USERCOUNTERINFO
  133. {
  134. char szCounterFuncName[32]; // Name of the function
  135. enum UserCounterType ct; // Describes the type of number we will be collecting
  136. char szName[32]; // Name of user counter
  137. } USERCOUNTERINFO, *PUSERCOUNTERINFO;
  138. #endif // USER_COUNTER_INFO_DEFINED
  139. #ifdef __cplusplus
  140. }
  141. #endif
  142. #endif // __ICECAP_H__