aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2016-12-02 19:20:26 +0000
committerDimitry Andric <dim@FreeBSD.org>2016-12-02 19:20:26 +0000
commit0230fcf22fe7d19f03d981c9c2c59a3db0b72ea5 (patch)
treede712af51ea0faf0101401728b0211581ba7a429
parent7ade6c809a90fb332410de9feadd3f43f65e9c85 (diff)
downloadsrc-0230fcf22fe7d19f03d981c9c2c59a3db0b72ea5.tar.gz
src-0230fcf22fe7d19f03d981c9c2c59a3db0b72ea5.zip
Notes
Notes: svn path=/vendor/compiler-rt/dist/; revision=309431 svn path=/vendor/compiler-rt/compiler-rt-release_391-r289601/; revision=310164; tag=vendor/compiler-rt/compiler-rt-release_391-r289601
-rw-r--r--test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc19
1 files changed, 17 insertions, 2 deletions
diff --git a/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc b/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc
index 193b33d7976d..ff1ddc432d4e 100644
--- a/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc
+++ b/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc
@@ -17,6 +17,21 @@ typedef uint64_t semval_t;
typedef unsigned semval_t;
#endif
+// glibc 2.21 has introduced some changes in the way the semaphore value is
+// handled for 32-bit platforms, but since these changes are not ABI-breaking
+// they are not versioned. On newer platforms such as ARM, there is only one
+// version of the symbol, so it's enough to check the glibc version. However,
+// for old platforms such as i386, glibc contains two or even three versions of
+// the sem_init symbol, and the sanitizers always pick the oldest one.
+// Therefore, it is not enough to rely on the __GLIBC_PREREQ macro - we should
+// instead check the platform as well to make sure we only expect the new
+// behavior on platforms where the older symbols do not exist.
+#if defined(__arm__) && __GLIBC_PREREQ(2, 21)
+#define GET_SEM_VALUE(V) ((V) >> 1)
+#else
+#define GET_SEM_VALUE(V) (V)
+#endif
+
void my_sem_init(bool priv, int value, semval_t *a, unsigned char *b) {
sem_t sem;
memset(&sem, 0xAB, sizeof(sem));
@@ -34,10 +49,10 @@ int main() {
unsigned char b;
my_sem_init(false, 42, &a, &b);
- assert(a == 42);
+ assert(GET_SEM_VALUE(a) == 42);
assert(b != 0xAB);
my_sem_init(true, 43, &a, &b);
- assert(a == 43);
+ assert(GET_SEM_VALUE(a) == 43);
assert(b != 0xAB);
}