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.

189 lines
4.3 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. winbase_interlockedunsigned.h
  5. Abstract:
  6. Simple inline casting wrappers of the Interlocked functions to act on ULONG and ULONGLONG.
  7. Author:
  8. Jay Krell (JayKrell) April 2002
  9. Environment:
  10. Revision History:
  11. --*/
  12. #if !defined(MICROSOFT_WINDOWS_WINBASE_INTERLOCKED_UNSIGNED_H_INCLUDED) /* { */
  13. #define MICROSOFT_WINDOWS_WINBASE_INTERLOCKED_UNSIGNED_H_INCLUDED
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #if !defined(RC_INVOKED) /* { */
  18. #if !defined(MIDL_PASS) /* { */
  19. #if !defined(MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_UNSIGNED)
  20. #define MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_UNSIGNED (_WIN32_WINNT >= 0x0502 || !defined(_WINBASE_))
  21. #endif
  22. #if MICROSOFT_WINDOWS_WINBASE_H_DEFINE_INTERLOCKED_UNSIGNED /* { */
  23. FORCEINLINE
  24. ULONG
  25. InterlockedIncrementUlong(
  26. IN OUT ULONG volatile *Addend
  27. )
  28. {
  29. return (ULONG)InterlockedIncrement((LONG volatile *)Addend);
  30. }
  31. FORCEINLINE
  32. ULONG
  33. InterlockedDecrementUlong(
  34. IN OUT ULONG volatile *Addend
  35. )
  36. {
  37. return (ULONG)InterlockedDecrement((LONG volatile *)Addend);
  38. }
  39. FORCEINLINE
  40. ULONG
  41. InterlockedExchangeUlong(
  42. IN OUT ULONG volatile *Target,
  43. IN ULONG Value
  44. )
  45. {
  46. return (ULONG)InterlockedExchange((LONG volatile *)Target, (LONG)Value);
  47. }
  48. FORCEINLINE
  49. ULONG
  50. InterlockedExchangeAddUlong(
  51. IN OUT ULONG volatile *Addend,
  52. IN ULONG Value
  53. )
  54. {
  55. return (ULONG)InterlockedExchangeAdd((LONG volatile *)Addend, (LONG)Value);
  56. }
  57. FORCEINLINE
  58. ULONG
  59. InterlockedCompareExchangeUlong (
  60. IN OUT ULONG volatile *Destination,
  61. IN ULONG Exchange,
  62. IN ULONG Comperand
  63. )
  64. {
  65. return (ULONG)InterlockedCompareExchange((LONG volatile *)Destination, (LONG)Exchange, (LONG)Comperand);
  66. }
  67. #define InterlockedIncrementDword InterlockedIncrementUlong
  68. #define InterlockedDecrementDword InterlockedDecrementUlong
  69. #define InterlockedExchangeDword InterlockedExchangeUlong
  70. #define InterlockedExchangeAddDword InterlockedExchangeAddUlong
  71. #define InterlockedCompareExchangeDword InterlockedCompareExchangeUlong
  72. #if defined(_WIN64)
  73. FORCEINLINE
  74. ULONGLONG
  75. InterlockedIncrementUnsigned64(
  76. IN OUT ULONGLONG volatile *Addend
  77. )
  78. {
  79. return (ULONGLONG)InterlockedIncrement64((LONGLONG volatile *)Addend);
  80. }
  81. FORCEINLINE
  82. ULONGLONG
  83. InterlockedDecrementUnsigned64(
  84. IN OUT ULONGLONG volatile *Addend
  85. )
  86. {
  87. return (ULONGLONG)InterlockedDecrement64((LONGLONG volatile *)Addend);
  88. }
  89. FORCEINLINE
  90. ULONGLONG
  91. InterlockedExchangeUnsigned64(
  92. IN OUT ULONGLONG volatile *Target,
  93. IN ULONGLONG Value
  94. )
  95. {
  96. return (ULONGLONG)InterlockedExchange64((LONGLONG volatile *)Target, (LONGLONG)Value);
  97. }
  98. FORCEINLINE
  99. ULONGLONG
  100. InterlockedExchangeAddUnsigned64(
  101. IN OUT ULONGLONG volatile *Addend,
  102. IN ULONGLONG Value
  103. )
  104. {
  105. return (ULONGLONG)InterlockedExchangeAdd64((LONGLONG volatile *)Addend, (LONGLONG)Value);
  106. }
  107. #endif
  108. FORCEINLINE
  109. ULONGLONG
  110. InterlockedCompareExchangeUnsigned64 (
  111. IN OUT ULONGLONG volatile *Destination,
  112. IN ULONGLONG Exchange,
  113. IN ULONGLONG Comperand
  114. )
  115. {
  116. return (ULONGLONG)InterlockedCompareExchange64((LONGLONG volatile *)Destination, (LONGLONG)Exchange, (LONGLONG)Comperand);
  117. }
  118. #if defined(_WINBASE_)
  119. FORCEINLINE
  120. ULONGLONG
  121. InterlockedAndUnsigned64 (
  122. IN OUT ULONGLONG volatile *Destination,
  123. IN ULONGLONG Value
  124. )
  125. {
  126. return (ULONGLONG)InterlockedAnd64((LONGLONG volatile *)Destination, (LONGLONG)Value);
  127. }
  128. FORCEINLINE
  129. ULONGLONG
  130. InterlockedOrUnsigned64 (
  131. IN OUT ULONGLONG volatile *Destination,
  132. IN ULONGLONG Value
  133. )
  134. {
  135. return (ULONGLONG)InterlockedOr64((LONGLONG volatile *)Destination, (LONGLONG)Value);
  136. }
  137. FORCEINLINE
  138. ULONGLONG
  139. InterlockedXorUnsigned64 (
  140. IN OUT ULONGLONG volatile *Destination,
  141. IN ULONGLONG Value
  142. )
  143. {
  144. return (ULONGLONG)InterlockedXor64((LONGLONG volatile *)Destination, (LONGLONG)Value);
  145. }
  146. #endif /* _WINBASE_ */
  147. #endif /* } MICROSOFT_WINBASE_H_DEFINE_INTERLOCKED_UNSIGNED */
  148. #undef MICROSOFT_WINBASE_H_DEFINE_INTERLOCKED_UNSIGNED
  149. #define MICROSOFT_WINBASE_H_DEFINE_INTERLOCKED_UNSIGNED 0
  150. #endif /* } MIDL_PASS */
  151. #endif /* } RC_INVOKED */
  152. #endif /* } MICROSOFT_WINDOWS_WINBASE_INTERLOCKED_UNSIGNED_H_INCLUDED */