]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/lock: trivial code move
authorVMware, Inc <>
Mon, 21 Nov 2011 22:46:37 +0000 (14:46 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 21 Nov 2011 22:46:37 +0000 (14:46 -0800)
Move a function - no forward reference.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/lock/ul.c

index 1340480f5f00eadbbe8794d7f369bec5183e4017..0fb4032954d311cb957916dc5cb12e4f1ab32886 100644 (file)
@@ -48,6 +48,54 @@ typedef struct {
 static Atomic_Ptr hashTableMem;
 
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * MXUserInternalSingleton --
+ *
+ *      A "singleton" function for the MXUser internal recursive lock.
+ *
+ *      Internal MXUser recursive locks have no statistics gathering or
+ *      tracking abilities. They need to used with care and rarely.
+ *
+ * Results:
+ *      NULL    Failure
+ *      !NULL   A pointer to an initialized MXRecLock
+ *
+ * Side effects:
+ *      Manifold.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+MXRecLock *
+MXUserInternalSingleton(Atomic_Ptr *storage)  // IN:
+{
+   MXRecLock *lock = (MXRecLock *) Atomic_ReadPtr(storage);
+
+   if (UNLIKELY(lock == NULL)) {
+      MXRecLock *newLock = Util_SafeMalloc(sizeof(MXRecLock));
+
+      if (MXRecLockInit(newLock)) {
+         lock = (MXRecLock *) Atomic_ReadIfEqualWritePtr(storage, NULL,
+                                                         (void *) newLock);
+
+         if (lock) {
+            MXRecLockDestroy(newLock);
+            free(newLock);
+         } else {
+            lock = Atomic_ReadPtr(storage);
+         }
+      } else {
+         free(newLock);
+         lock = Atomic_ReadPtr(storage);  // maybe another thread succeeded
+      }
+   }
+
+   return lock;
+}
+
+
 /*
  *-----------------------------------------------------------------------------
  *
@@ -418,54 +466,6 @@ MXUser_TryAcquireFailureControl(Bool (*func)(const char *name))  // IN:
 #endif
 
 
-/*
- *-----------------------------------------------------------------------------
- *
- * MXUserInternalSingleton --
- *
- *      A "singleton" function for the MXUser internal recursive lock.
- *
- *      Internal MXUser recursive locks have no statistics gathering or
- *      tracking abilities. They need to used with care and rarely.
- *
- * Results:
- *      NULL    Failure
- *      !NULL   A pointer to an initialized MXRecLock
- *
- * Side effects:
- *      Manifold.
- *
- *-----------------------------------------------------------------------------
- */
-
-MXRecLock *
-MXUserInternalSingleton(Atomic_Ptr *storage)  // IN:
-{
-   MXRecLock *lock = (MXRecLock *) Atomic_ReadPtr(storage);
-
-   if (UNLIKELY(lock == NULL)) {
-      MXRecLock *newLock = Util_SafeMalloc(sizeof(MXRecLock));
-
-      if (MXRecLockInit(newLock)) {
-         lock = (MXRecLock *) Atomic_ReadIfEqualWritePtr(storage, NULL,
-                                                         (void *) newLock);
-
-         if (lock) {
-            MXRecLockDestroy(newLock);
-            free(newLock);
-         } else {
-            lock = Atomic_ReadPtr(storage);
-         }
-      } else {
-         free(newLock);
-         lock = Atomic_ReadPtr(storage);  // maybe another thread succeeded
-      }
-   }
-
-   return lock;
-}
-
-
 /*
  *-----------------------------------------------------------------------------
  *