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.

166 lines
3.2 KiB

  1. /*
  2. Copyright (c) 2000 Microsoft Corporation
  3. File name:
  4. sched.c
  5. Author:
  6. adrmarin Fri Jul 19 17:41:07 2002
  7. */
  8. #include "nt.h"
  9. #include "ntrtl.h"
  10. #include "nturtl.h"
  11. #include <windows.h>
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include <math.h>
  16. unsigned int
  17. foo4 (
  18. IN unsigned int Value,
  19. IN int Shift
  20. )
  21. {
  22. return RotateRight32(RotateLeft32(Value, Shift), Shift);
  23. }
  24. unsigned __int64
  25. foo5 (
  26. IN unsigned __int64 Value,
  27. IN int Shift
  28. )
  29. {
  30. return RotateRight64(RotateLeft64(Value, Shift), Shift);
  31. }
  32. unsigned int
  33. foo6 (
  34. IN unsigned int Value,
  35. IN int Shift
  36. )
  37. {
  38. return RotateLeft32(Value, Shift);
  39. }
  40. unsigned __int64
  41. foo7 (
  42. IN unsigned __int64 Value,
  43. IN int Shift
  44. )
  45. {
  46. return RotateRight64(Value, Shift);
  47. }
  48. ULARGE_INTEGER TickCount;
  49. #if 0
  50. //
  51. // This is an example of the current NtGetTickCount64 algorithm with a
  52. // tick count multiplier of 5,0.
  53. //
  54. FORCEINLINE
  55. ULONGLONG
  56. GetTickCount64 (
  57. VOID
  58. )
  59. {
  60. return ((UInt32x32To64(TickCount.LowPart, 0x5000000) >> 24)
  61. + UInt32x32To64(TickCount.HighPart << 8, 0x5000000));
  62. }
  63. #else
  64. //
  65. // This is an example of the the correct NtGetTickCount64 algorithm
  66. // with a tick count multiplier of 5,0.
  67. //
  68. FORCEINLINE
  69. ULONGLONG
  70. GetTickCount64 (
  71. VOID
  72. )
  73. {
  74. return ((UInt32x32To64(TickCount.LowPart, 0x5000000) >> 24)
  75. + (UInt32x32To64(TickCount.HighPart, 0x5000000) << 8));
  76. }
  77. #endif
  78. int
  79. __cdecl
  80. main (
  81. int argc,
  82. char ** argv
  83. )
  84. {
  85. LARGE_INTEGER SystemTime;
  86. TIME_FIELDS TimeFields;
  87. SystemTime.LowPart = 0xe2578350;
  88. SystemTime.HighPart = 0x01c4b107;
  89. RtlTimeToTimeFields(&SystemTime, &TimeFields);
  90. printf("year = %d\nmonth = %d\nday = %d\nhour = %d\nminute = %d\nsecond = %d\n",
  91. TimeFields.Year,
  92. TimeFields.Month,
  93. TimeFields.Day,
  94. TimeFields.Hour,
  95. TimeFields.Minute,
  96. TimeFields.Second);
  97. SystemTime.LowPart = 0x805e3a5c;
  98. SystemTime.HighPart = 0x01c25d95;
  99. RtlTimeToTimeFields(&SystemTime, &TimeFields);
  100. printf("year = %d\nmonth = %d\nday = %d\nhour = %d\nminute = %d\nsecond = %d\n",
  101. TimeFields.Year,
  102. TimeFields.Month,
  103. TimeFields.Day,
  104. TimeFields.Hour,
  105. TimeFields.Minute,
  106. TimeFields.Second);
  107. /*
  108. ULARGE_INTEGER Iteration;
  109. ULARGE_INTEGER Milliseconds;
  110. Iteration.QuadPart = 0xffffffffffffffffUI64 / 10000000000;
  111. Milliseconds.QuadPart = 0;
  112. TickCount.QuadPart = 0;
  113. do {
  114. if (GetTickCount64() != Milliseconds.QuadPart) {
  115. printf("mismatch at tick count = %08lx%08lx, milliseconds = %08lx%08lx\n",
  116. TickCount.HighPart,
  117. TickCount.LowPart,
  118. Milliseconds.HighPart,
  119. Milliseconds.LowPart);
  120. }
  121. Iteration.QuadPart -= 1;
  122. Milliseconds.QuadPart += (5 * 10000000000UI64);
  123. TickCount.QuadPart += 10000000000;
  124. } while (Iteration.QuadPart != 0);
  125. */
  126. return 0;
  127. }