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.

91 lines
2.9 KiB

  1. /*
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. intrlckd.h
  5. Abstract:
  6. This module defines the routines that should have been in the EX package.
  7. This manipulates inter-locked operations on flags and such.
  8. Author:
  9. Jameel Hyder (microsoft!jameelh)
  10. Revision History:
  11. 5 Sep 1992 Initial Version
  12. Notes: Tab stop: 4
  13. --*/
  14. #ifndef _INTRLCKD_
  15. #define _INTRLCKD_
  16. extern
  17. VOID FASTCALL
  18. AfpInterlockedSetDword(
  19. IN PDWORD pSrc,
  20. IN DWORD Mask,
  21. IN PAFP_SPIN_LOCK pSpinLock
  22. );
  23. extern
  24. VOID FASTCALL
  25. AfpInterlockedClearDword(
  26. IN PDWORD pSrc,
  27. IN DWORD Mask,
  28. IN PAFP_SPIN_LOCK pSpinLock
  29. );
  30. extern
  31. VOID FASTCALL
  32. AfpInterlockedSetNClearDword(
  33. IN PDWORD pSrc,
  34. IN DWORD SetMask,
  35. IN DWORD ClrMask,
  36. IN PAFP_SPIN_LOCK pSpinLock
  37. );
  38. // Macros for Interlocked/ExInterlocked calls
  39. //
  40. // For future reference, here is the difference between all the different
  41. // kernel mode interlocked routines:
  42. //
  43. // InterlockedIncrement/Decrement - fastest on all platforms, inlined
  44. // where appropriate to avoid call overhead. No spinlock required, usable
  45. // on paged data. Operation is atomic ONLY with respect to other Interlocked
  46. // calls.
  47. //
  48. // ExInterlockedIncrement/Decrement - not as efficient, requires a function
  49. // call and a spinlock. Operation is atomic ONLY with respect to other
  50. // ExInterlockedIncrement/Decrement calls. There is no reason to use this
  51. // instead of InterlockedIncrement/Decrement. Does not actually acquire the
  52. // spinlock. Required for backwards compatibility.
  53. //
  54. // ExInterlockedAddUlong - most inefficient, requires a function call and a
  55. // spinlock. Spinlock is actually acquired, so the operation is atomic with
  56. // respect to anything that acquires the same spinlock.
  57. //
  58. #define INTERLOCKED_INCREMENT_LONG(p) InterlockedIncrement(p)
  59. #define INTERLOCKED_DECREMENT_LONG(p) InterlockedDecrement(p)
  60. #define INTERLOCKED_ADD_STATISTICS(p, v, l) ExInterlockedAddLargeStatistic(p, v)
  61. #define INTERLOCKED_INCREMENT_LONG_DPC(p,l) InterlockedIncrement(p)
  62. #define INTERLOCKED_DECREMENT_LONG_DPC(p,l) InterlockedDecrement(p)
  63. #ifdef NT40
  64. #define INTERLOCKED_ADD_ULONG(p, v, l) ExInterlockedExchangeAdd(p, v)
  65. #else
  66. #define INTERLOCKED_ADD_ULONG(p, v, l) ExInterlockedAddUlong(p, v, &(l)->SpinLock)
  67. #endif
  68. #define INTERLOCKED_ADD_ULONG_DPC(p, v, l) ExInterlockedAddUlong(p, v, l)
  69. #define INTERLOCKED_ADD_LARGE_INTGR(p, v, l) ExInterlockedAddLargeInteger(p, v, &(l)->SpinLock)
  70. #define INTERLOCKED_ADD_LARGE_INTGR_DPC(p, v, l) ExInterlockedAddLargeInteger(p, v, &(l)->SpinLock)
  71. #endif // _INTRLCKD_