]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Introduced bm_test_and_clear().
authorBart Van Assche <bvanassche@acm.org>
Sun, 30 Mar 2008 17:56:43 +0000 (17:56 +0000)
committerBart Van Assche <bvanassche@acm.org>
Sun, 30 Mar 2008 17:56:43 +0000 (17:56 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@7824

exp-drd/drd_bitmap.c
exp-drd/drd_thread.c
exp-drd/pub_drd_bitmap.h

index 81424baf6c5c87792f1c5df50e90b89b5d4a2fa9..03ed89bc6085a68d952e215b1d8fe1159e928d91 100644 (file)
@@ -477,6 +477,20 @@ void bm_clear_store(const struct bitmap* const bm,
   }
 }
 
+/** Clear bitmap bm starting at address a1 and up to but not including address
+ *  a2. Return True if and only if any of the addresses was set before
+ *  clearing.
+ */
+Bool bm_test_and_clear(const struct bitmap* const bm,
+                       const Addr a1, const Addr a2)
+{
+  Bool result;
+
+  result = bm_has_any_access(bm, a1, a2) != 0;
+  bm_clear(bm, a1, a2);
+  return result;
+}
+
 Bool bm_has_conflict_with(const struct bitmap* const bm,
                           const Addr a1, const Addr a2,
                           const BmAccessTypeT access_type)
index 55bf0fd11401b58538fe4effba5b3d50b2e6e09e..b8eb755ad0436e77e7cce4172eb0955716ad855a 100644 (file)
@@ -670,10 +670,13 @@ void thread_stop_using_mem(const Addr a1, const Addr a2)
     for (p = s_threadinfo[i].first; p; p = p->next)
     {
       if (other_user == DRD_INVALID_THREADID
-          && i != s_drd_running_tid
-          && bm_has_any_access(p->bm, a1, a2))
+          && i != s_drd_running_tid)
       {
-        other_user = i;
+        if (UNLIKELY(bm_test_and_clear(p->bm, a1, a2)))
+        {
+          other_user = i;
+        }
+        continue;
       }
       bm_clear(p->bm, a1, a2);
     }
index ede095e4ce975e99ab3e9b262d5358f98d3a6108..72470ace0a0c72d2ac66b660a5c5807e5ebba955 100644 (file)
@@ -84,6 +84,8 @@ void bm_clear_load(const struct bitmap* const bm,
                    const Addr a1, const Addr a2);
 void bm_clear_store(const struct bitmap* const bm,
                     const Addr a1, const Addr a2);
+Bool bm_test_and_clear(const struct bitmap* const bm,
+                       const Addr a1, const Addr a2);
 Bool bm_has_conflict_with(const struct bitmap* const bm,
                           const Addr a1, const Addr a2,
                           const BmAccessTypeT access_type);