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.

148 lines
2.6 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. tracelib.h
  5. Abstract:
  6. Private headers for user-mode trace library
  7. Author:
  8. 15-Aug-2000 JeePang
  9. Revision History:
  10. --*/
  11. #ifndef _TRACELIB_H_
  12. #define _TRACELIB_H_
  13. #define WmipNtStatusToDosError(Status) ((ULONG)((Status == STATUS_SUCCESS)?ERROR_SUCCESS:RtlNtStatusToDosError(Status)))
  14. __inline Assign64(
  15. IN LONGLONG qwSrc,
  16. OUT PLARGE_INTEGER pqwDest
  17. )
  18. {
  19. PLARGE_INTEGER pqwSrc = (PLARGE_INTEGER) &qwSrc;
  20. pqwDest->LowPart = pqwSrc->LowPart;
  21. pqwDest->HighPart = pqwSrc->HighPart;
  22. }
  23. __inline Move64(
  24. IN PLARGE_INTEGER pSrc,
  25. OUT PLARGE_INTEGER pDest
  26. )
  27. {
  28. pDest->LowPart = pSrc->LowPart;
  29. pDest->HighPart = pSrc->HighPart;
  30. }
  31. #if defined(_IA64_)
  32. #include <ia64reg.h>
  33. #endif
  34. //
  35. // NTDLL cannot call GetSystemTimeAsFileTime
  36. //
  37. __inline __int64 WmipGetSystemTime()
  38. {
  39. LARGE_INTEGER SystemTime;
  40. //
  41. // Read system time from shared region.
  42. //
  43. do {
  44. SystemTime.HighPart = USER_SHARED_DATA->SystemTime.High1Time;
  45. SystemTime.LowPart = USER_SHARED_DATA->SystemTime.LowPart;
  46. } while (SystemTime.HighPart != USER_SHARED_DATA->SystemTime.High2Time);
  47. return SystemTime.QuadPart;
  48. }
  49. //
  50. // GetCycleCounts
  51. //
  52. // Since we do not want to make a kernel mode transition to get the
  53. // thread CPU Times, we settle for just getting the CPU Cycle counts.
  54. // We use the following macros from BradW to get the CPU cycle count.
  55. // This method may be inaccurate if the clocks are not synchronized
  56. // between processors.
  57. //
  58. #if defined(_X86_)
  59. __inline
  60. LONGLONG
  61. WmipGetCycleCount(
  62. )
  63. {
  64. __asm{
  65. RDTSC
  66. }
  67. }
  68. #elif defined(_AMD64_)
  69. #define WmipGetCycleCount() ReadTimeStampCounter()
  70. #elif defined(_IA64_)
  71. #define WmipGetCycleCount() __getReg(CV_IA64_ApITC)
  72. #else
  73. #error "perf: a target architecture must be defined."
  74. #endif
  75. __inline
  76. ULONG
  77. WmipSetDosError(
  78. IN ULONG DosError
  79. )
  80. {
  81. if (DosError != ERROR_SUCCESS) {
  82. SetLastError(DosError);
  83. }
  84. return DosError;
  85. }
  86. PVOID
  87. WmipMemReserve(
  88. IN SIZE_T Size
  89. );
  90. PVOID
  91. WmipMemCommit(
  92. IN PVOID Buffer,
  93. IN SIZE_T Size
  94. );
  95. ULONG
  96. WmipMemFree(
  97. IN PVOID Buffer
  98. );
  99. HANDLE
  100. WmipCreateFile(
  101. LPCWSTR lpFileName,
  102. DWORD dwDesiredAccess,
  103. DWORD dwShareMode,
  104. DWORD dwCreationDisposition,
  105. DWORD dwCreateFlags
  106. );
  107. NTSTATUS
  108. WmipGetCpuSpeed(
  109. OUT DWORD* CpuNum,
  110. OUT DWORD* CpuSpeed
  111. );
  112. BOOL
  113. WmipSynchReadFile(
  114. HANDLE LogFile,
  115. LPVOID Buffer,
  116. DWORD NumberOfBytesToRead,
  117. LPDWORD NumberOfBytesRead,
  118. LPOVERLAPPED Overlapped
  119. );
  120. #endif // _TRACELIB_H_