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.

84 lines
2.0 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. umkm.h
  5. Abstract:
  6. Macros to simplify usermode & kernelmode shared code.
  7. Author:
  8. Scott Field (sfield) 19-Sep-99
  9. --*/
  10. #ifndef __UMKM_H__
  11. #define __UMKM_H__
  12. #ifndef KMODE_RNG
  13. #define __LOCK_TYPE CRITICAL_SECTION
  14. #define INIT_LOCK(x) InitializeCriticalSection(x)
  15. //#define INIT_LOCK(x) InitializeCriticalSectionAndSpinCount(x, 0x333)
  16. #define DELETE_LOCK(x) DeleteCriticalSection(x)
  17. #define ENTER_LOCK(x) EnterCriticalSection(x)
  18. #define LEAVE_LOCK(x) LeaveCriticalSection(x)
  19. #define ALLOC(cb) HeapAlloc(GetProcessHeap(), 0, cb)
  20. #define ALLOC_NP(cb) ALLOC(cb)
  21. #define FREE(pv) HeapFree(GetProcessHeap(), 0, pv)
  22. #define REGCLOSEKEY(x) RegCloseKey( x )
  23. #ifdef WIN95_RNG
  24. PVOID
  25. InterlockedCompareExchangePointerWin95(
  26. PVOID *Destination,
  27. PVOID Exchange,
  28. PVOID Comperand
  29. );
  30. #define INTERLOCKEDCOMPAREEXCHANGEPOINTER(x,y,z) InterlockedCompareExchangePointerWin95(x,y,z)
  31. #else
  32. #define INTERLOCKEDCOMPAREEXCHANGEPOINTER(x,y,z) InterlockedCompareExchangePointer(x,y,z)
  33. #endif // WIN95_RNG
  34. #else
  35. //#define __LOCK_TYPE KSPIN_LOCK
  36. #define __LOCK_TYPE ERESOURCE
  37. #define RNG_TAG 'cesK'
  38. //#define INIT_LOCK(x) KeInitializeSpinLock( x )
  39. //#define DELETE_LOCK(x)
  40. //#define ENTER_LOCK(x) ExAcquireSpinLock( x, &OldIrql )
  41. //#define LEAVE_LOCK(x) ExReleaseSpinLock( x, OldIrql )
  42. #define ALLOC(cb) ExAllocatePoolWithTag(PagedPool, cb, RNG_TAG)
  43. #define ALLOC_NP(cb) ExAllocatePoolWithTag(NonPagedPool, cb, RNG_TAG)
  44. #define FREE(pv) ExFreePool(pv)
  45. #define INIT_LOCK(x) ExInitializeResourceLite( x )
  46. #define DELETE_LOCK(x) ExDeleteResourceLite( x )
  47. #define ENTER_LOCK(x) KeEnterCriticalRegion(); ExAcquireResourceExclusiveLite( x, TRUE )
  48. #define LEAVE_LOCK(x) ExReleaseResourceLite( x ); KeLeaveCriticalRegion()
  49. #define REGCLOSEKEY(x) ZwClose( x )
  50. #define INTERLOCKEDCOMPAREEXCHANGEPOINTER(x,y,z) InterlockedCompareExchangePointer(x,y,z)
  51. #endif
  52. #endif // __UMKM_H__