]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/lock: concentrate the MXUSER_DEBUG code
authorVMware, Inc <>
Thu, 18 Nov 2010 22:13:16 +0000 (14:13 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 18 Nov 2010 22:13:16 +0000 (14:13 -0800)
Group the debug code together, all under the same ifdefs.

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

index bddeaea76b0e58034e43b4d859dad1f66ef0bfa7..77255a1f59cca3148ae5a5470c28d7978c34dbb7 100644 (file)
@@ -214,7 +214,7 @@ MXUserRecLock *MXUser_InitFromMXRec(const char *name,
 
 #endif
 
-#if defined(VMX86_DEBUG)
+#if defined(VMX86_DEBUG) && !defined(DISABLE_MXUSER_DEBUG)
 #define MXUSER_DEBUG  // debugging "everywhere" when requested
 #endif
 
index 25f60fb4be6b7a6c5ee44cc91cf59dd125eef2d1..6a02ffff6f1a46551591e7ab53221a1656025f2e 100644 (file)
@@ -69,7 +69,7 @@ static Atomic_Ptr hashTableMem;
  *-----------------------------------------------------------------------------
  */
 
-MXUserPerThread *
+static MXUserPerThread *
 MXUserGetPerThread(void *tid,      // IN: native thread ID
                    Bool mayAlloc)  // IN: alloc perThread if not present?
 {
@@ -109,6 +109,43 @@ MXUserGetPerThread(void *tid,      // IN: native thread ID
 }
 
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * MXUserListLocks
+ *
+ *      Allow a caller to list, via warnings, the list of locks the caller
+ *      has acquired. Ensure that no memory for lock tracking is allocated
+ *      if no locks have been taken.
+ *
+ * Results:
+ *      The list is printed
+ *
+ * Side effects:
+ *      None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+void
+MXUserListLocks(void)
+{
+   MXUserPerThread *perThread = MXUserGetPerThread(MXUserGetNativeTID(),
+                                                   FALSE);
+
+   if (perThread != NULL) {
+      uint32 i;
+
+      for (i = 0; i < perThread->locksHeld; i++) {
+         MXUserHeader *hdr = perThread->lockArray[i];
+
+         Warning("\tMXUser lock %s (@%p) rank 0x%x\n", hdr->name, hdr,
+                 hdr->rank);
+      }
+   }
+}
+
+
 /*
  *-----------------------------------------------------------------------------
  *
@@ -161,10 +198,6 @@ MXUserAcquisitionTracking(MXUserHeader *header,  // IN:
 
    ASSERT_NOT_IMPLEMENTED(perThread->locksHeld < MXUSER_MAX_LOCKS_PER_THREAD);
 
-#if defined(DISABLE_MXUSER_LOCK_RANKS)
-   checkRank = FALSE;
-#endif
-
    /* Rank checking anyone? */
    if (checkRank && (header->rank != RANK_UNRANKED)) {
       uint32 i;
@@ -500,42 +533,3 @@ MXUserInstallMxHooks(void (*theLockListFunc)(void),
             );
    }
 }
-
-
-/*
- *-----------------------------------------------------------------------------
- *
- * MXUserListLocks
- *
- *      Allow a caller to list, via warnings, the list of locks the caller
- *      has acquired. Ensure that no memory for lock tracking is allocated
- *      if no locks have been taken.
- *
- * Results:
- *      The list is printed
- *
- * Side effects:
- *      None
- *
- *-----------------------------------------------------------------------------
- */
-
-void
-MXUserListLocks(void)
-{
-#if defined(MXUSER_DEBUG)
-   MXUserPerThread *perThread = MXUserGetPerThread(MXUserGetNativeTID(),
-                                                   FALSE);
-
-   if (perThread != NULL) {
-      uint32 i;
-
-      for (i = 0; i < perThread->locksHeld; i++) {
-         MXUserHeader *hdr = perThread->lockArray[i];
-
-         Warning("\tMXUser lock %s (@%p) rank 0x%x\n", hdr->name, hdr,
-                 hdr->rank);
-      }
-   }
-#endif
-}
index 9e2d439c41757fe281423d5a6113530543c269b8..a20036ca430a52fb8dc35f8b5bfc1997c7d277ce 100644 (file)
 #ifndef _ULINTSHARED_H_
 #define _ULINTSHARED_H_
 
+
+#if defined(MXUSER_DEBUG)
 extern void MXUserListLocks(void);
+#else
+static INLINE void
+MXUserListLocks(void)
+{
+   return;
+}
+#endif
 
 extern void MXUserInstallMxHooks(void (*theLockListFunc)(void),
                                  MX_Rank (*theRankFunc)(void),
index a61979ef729ab47412efa013e0c0ea62aef62ac9..da201f9731aa7a21cf9819a7ebaed695ef27750f 100644 (file)
@@ -868,11 +868,7 @@ MXUser_IsCurThreadHoldingRWLock(MXUserRWLock *lock,  // IN:
       return myContext->state != RW_UNLOCKED;
 
    default:
-#if defined(MXUSER_DEBUG)
       Panic("%s: unknown query type %d\n", __FUNCTION__, queryType);
-#else   
-      return FALSE;
-#endif  
    }    
 }