|
From: <sv...@va...> - 2012-09-02 20:58:26
|
sewardj 2012-09-02 21:58:17 +0100 (Sun, 02 Sep 2012)
New Revision: 12945
Log:
Merge from trunk, revs 12897 and 12898. (Handle non-zero sem_*wait()
return values correctly, #305690)
Modified directories:
branches/VALGRIND_3_8_BRANCH/
branches/VALGRIND_3_8_BRANCH/coregrind/
branches/VALGRIND_3_8_BRANCH/coregrind/m_syswrap/
Modified files:
branches/VALGRIND_3_8_BRANCH/coregrind/m_syswrap/syswrap-generic.c
branches/VALGRIND_3_8_BRANCH/drd/drd_semaphore.c
Modified: branches/VALGRIND_3_8_BRANCH/
Modified: branches/VALGRIND_3_8_BRANCH/coregrind/
Modified: branches/VALGRIND_3_8_BRANCH/coregrind/m_syswrap/
Property changed: branches/VALGRIND_3_8_BRANCH/coregrind/m_syswrap (+0 -0)
___________________________________________________________________
Name: svn:mergeinfo
- /branches/TCHAIN/coregrind/m_syswrap:12477-12516
/trunk/coregrind/m_syswrap:12873,12881-12883,12885,12887,12891-12894
+ /branches/TCHAIN/coregrind/m_syswrap:12477-12516
/trunk/coregrind/m_syswrap:12873,12881-12883,12885,12887,12891-12894,12897-12898
Property changed: branches/VALGRIND_3_8_BRANCH/coregrind/m_syswrap/syswrap-generic.c (+0 -0)
___________________________________________________________________
Name: svn:mergeinfo
- /branches/TCHAIN/coregrind/m_syswrap/syswrap-generic.c:12477-12516
/trunk/coregrind/m_syswrap/syswrap-generic.c:12874,12878-12879,12881-12883,12885,12887,12891-12894
+ /branches/TCHAIN/coregrind/m_syswrap/syswrap-generic.c:12477-12516
/trunk/coregrind/m_syswrap/syswrap-generic.c:12874,12878-12879,12881-12883,12885,12887,12891-12894,12897-12898
Property changed: branches/VALGRIND_3_8_BRANCH/coregrind (+0 -0)
___________________________________________________________________
Name: svn:mergeinfo
- /branches/TCHAIN/coregrind:12477-12516
/trunk/coregrind:12873,12881,12885,12887,12891-12894
+ /branches/TCHAIN/coregrind:12477-12516
/trunk/coregrind:12873,12881,12885,12887,12891-12894,12897-12898
Property changed: branches/VALGRIND_3_8_BRANCH (+0 -0)
___________________________________________________________________
Name: svn:mergeinfo
- /branches/TCHAIN:12477-12516
/trunk:12873,12878-12879,12885,12887,12891-12894
+ /branches/TCHAIN:12477-12516
/trunk:12873,12878-12879,12885,12887,12891-12894,12897-12898
Modified: branches/VALGRIND_3_8_BRANCH/drd/drd_semaphore.c (+10 -7)
===================================================================
--- branches/VALGRIND_3_8_BRANCH/drd/drd_semaphore.c 2012-09-02 21:54:16 +01:00 (rev 12944)
+++ branches/VALGRIND_3_8_BRANCH/drd/drd_semaphore.c 2012-09-02 21:58:17 +01:00 (rev 12945)
@@ -339,8 +339,7 @@
/**
* Called after sem_wait() finished.
- * @note Do not rely on the value of 'waited' -- some glibc versions do
- * not set it correctly.
+ * @note Some C libraries do not set the 'waited' value correctly.
*/
void DRD_(semaphore_post_wait)(const DrdThreadId tid, const Addr semaphore,
const Bool waited)
@@ -348,16 +347,17 @@
struct semaphore_info* p;
Segment* sg;
+ tl_assert(waited == 0 || waited == 1);
p = semaphore_get(semaphore);
if (s_trace_semaphore)
- DRD_(trace_msg)("[%d] sem_wait 0x%lx value %u -> %u",
+ DRD_(trace_msg)("[%d] sem_wait 0x%lx value %u -> %u%s",
DRD_(thread_get_running_tid)(), semaphore,
- p ? p->value : 0, p ? p->value - 1 : 0);
+ p ? p->value : 0, p ? p->value - waited : 0,
+ waited ? "" : " (did not wait)");
- if (p)
- {
+ if (p) {
p->waiters--;
- p->value--;
+ p->value -= waited;
}
/*
@@ -378,6 +378,9 @@
return;
}
+ if (!waited)
+ return;
+
if (p->waits_to_skip > 0)
p->waits_to_skip--;
else
|