- Implemented InterlockedBitTestAndReset, InterlockedBitTestAndSet, InterlockedExchan...
[reactos.git] / reactos / ntoskrnl / ob / sdcache.c
index f06b3f9..b1464c4 100644 (file)
@@ -4,7 +4,7 @@
  * PROJECT:         ReactOS kernel
  * FILE:            ntoskrnl/ob/sdcache.c
  * PURPOSE:         No purpose listed.
- * 
+ *
  * PROGRAMMERS:     David Welch (welch@cwcom.net)
  */
 
@@ -28,51 +28,49 @@ typedef struct _SD_CACHE_ENTRY
 
 /* GLOBALS ******************************************************************/
 
-PLIST_ENTRY ObpSdCache;
-KSPIN_LOCK ObpSdCacheSpinLock;
-KIRQL ObpSdCacheIrql;
-
-
 #define SD_CACHE_ENTRIES 0x100
 
+LIST_ENTRY ObpSdCache[SD_CACHE_ENTRIES];
+FAST_MUTEX ObpSdCacheMutex;
+
 /* FUNCTIONS ****************************************************************/
 
 NTSTATUS
+NTAPI
 ObpInitSdCache(VOID)
 {
   ULONG i;
 
-  ObpSdCache = ExAllocatePool(NonPagedPool,
-                             SD_CACHE_ENTRIES * sizeof(LIST_ENTRY));
-  if (ObpSdCache == NULL)
-    {
-      return STATUS_INSUFFICIENT_RESOURCES;
-    }
-
-  for (i = 0; i < SD_CACHE_ENTRIES; i++)
+  for (i = 0; i < (sizeof(ObpSdCache) / sizeof(ObpSdCache[0])); i++)
     {
       InitializeListHead(&ObpSdCache[i]);
     }
 
-  KeInitializeSpinLock(&ObpSdCacheSpinLock);
+  ExInitializeFastMutex(&ObpSdCacheMutex);
 
   return STATUS_SUCCESS;
 }
 
 
-static VOID
+static __inline VOID
 ObpSdCacheLock(VOID)
 {
-  KeAcquireSpinLock(&ObpSdCacheSpinLock,
-                   &ObpSdCacheIrql);
+  /* can't acquire a fast mutex in the early boot process... */
+  if(KeGetCurrentThread() != NULL)
+  {
+    ExAcquireFastMutex(&ObpSdCacheMutex);
+  }
 }
 
 
-static VOID
+static __inline VOID
 ObpSdCacheUnlock(VOID)
 {
-  KeReleaseSpinLock(&ObpSdCacheSpinLock,
-                   ObpSdCacheIrql);
+  /* can't acquire a fast mutex in the early boot process... */
+  if(KeGetCurrentThread() != NULL)
+  {
+    ExReleaseFastMutex(&ObpSdCacheMutex);
+  }
 }
 
 
@@ -210,6 +208,7 @@ ObpCompareSecurityDescriptors(IN PSECURITY_DESCRIPTOR Sd1,
 
 
 NTSTATUS
+NTAPI
 ObpAddSecurityDescriptor(IN PSECURITY_DESCRIPTOR SourceSD,
                         OUT PSECURITY_DESCRIPTOR *DestinationSD)
 {
@@ -280,6 +279,7 @@ ObpAddSecurityDescriptor(IN PSECURITY_DESCRIPTOR SourceSD,
 
 
 NTSTATUS
+NTAPI
 ObpRemoveSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor)
 {
   PSD_CACHE_ENTRY CacheEntry;
@@ -308,6 +308,7 @@ ObpRemoveSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor)
 
 
 VOID
+NTAPI
 ObpReferenceCachedSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor)
 {
   PSD_CACHE_ENTRY CacheEntry;
@@ -328,6 +329,7 @@ ObpReferenceCachedSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor)
 
 
 VOID
+NTAPI
 ObpDereferenceCachedSecurityDescriptor(IN PSECURITY_DESCRIPTOR SecurityDescriptor)
 {
   DPRINT("ObpDereferenceCachedSecurityDescriptor() called\n");