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.

109 lines
1.9 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. #if defined(_IA64_)
  15. #include <ia64reg.h>
  16. #endif
  17. //
  18. // NTDLL cannot call GetSystemTimeAsFileTime
  19. //
  20. __inline __int64 WmipGetSystemTime()
  21. {
  22. LARGE_INTEGER SystemTime;
  23. //
  24. // Read system time from shared region.
  25. //
  26. do {
  27. SystemTime.HighPart = USER_SHARED_DATA->SystemTime.High1Time;
  28. SystemTime.LowPart = USER_SHARED_DATA->SystemTime.LowPart;
  29. } while (SystemTime.HighPart != USER_SHARED_DATA->SystemTime.High2Time);
  30. return SystemTime.QuadPart;
  31. }
  32. //
  33. // GetCycleCounts
  34. //
  35. // Since we do not want to make a kernel mode transition to get the
  36. // thread CPU Times, we settle for just getting the CPU Cycle counts.
  37. // We use the following macros from BradW to get the CPU cycle count.
  38. // This method may be inaccurate if the clocks are not synchronized
  39. // between processors.
  40. //
  41. #if defined(_X86_)
  42. __inline
  43. LONGLONG
  44. WmipGetCycleCount(
  45. )
  46. {
  47. __asm{
  48. RDTSC
  49. }
  50. }
  51. #elif defined(_AMD64_)
  52. #define WmipGetCycleCount() ReadTimeStampCounter()
  53. #elif defined(_IA64_)
  54. #define WmipGetCycleCount() __getReg(CV_IA64_ApITC)
  55. #else
  56. #error "perf: a target architecture must be defined."
  57. #endif
  58. PVOID
  59. WmipMemReserve(
  60. IN SIZE_T Size
  61. );
  62. PVOID
  63. WmipMemCommit(
  64. IN PVOID Buffer,
  65. IN SIZE_T Size
  66. );
  67. ULONG
  68. WmipMemFree(
  69. IN PVOID Buffer
  70. );
  71. HANDLE
  72. WmipCreateFile(
  73. LPCWSTR lpFileName,
  74. DWORD dwDesiredAccess,
  75. DWORD dwShareMode,
  76. DWORD dwCreationDisposition,
  77. DWORD dwCreateFlags
  78. );
  79. NTSTATUS
  80. WmipGetCpuSpeed(
  81. OUT DWORD* CpuNum,
  82. OUT DWORD* CpuSpeed
  83. );
  84. #endif // _TRACELIB_H_