summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Picus <diana.picus@linaro.org>2016-09-21 08:56:14 +0000
committerDiana Picus <diana.picus@linaro.org>2016-09-21 08:56:14 +0000
commitcf00ba7f74a93a10bc679cddd4195690f1d0153e (patch)
tree641b6d47715ec31a569c4ab3c985ee7b7c5e292f
parent7ddd5998e5e5f628bd8b34aa464194c9d59530bd (diff)
downloadcompiler-rt-cf00ba7f74a93a10bc679cddd4195690f1d0153e.tar.gz
[sanitizers] Update sanitizers test to better match glibc internals
One of the tests relying on sem_t's layout gets the wrong value for versions of glibc newer than 2.21 on platforms that don't have 64-bit atomics (e.g. ARM). This commit fixes the test to work with: * versions of glibc >= 2.21 on platforms with 64-bit atomics: unchanged * versions of glibc >= 2.21 on platforms without 64-bit atomics: the semaphore value is shifted by SEM_VALUE_SHIFT (which is set to 1 in glibc's internal headers) * versions of glibc < 2.21: unchanged See the glibc 2.23 sources: * sysdeps/nptl/internaltypes.h (struct new_sem for glibc >= 2.21 and struct old_sem for glibc < 2.21) * nptl/sem_getvalue.c This was uncovered on one of the new buildbots that we are trying to move to production. Differential Revision: https://reviews.llvm.org/D24766 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@282061 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc10
1 files changed, 8 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 193b33d79..50a40c419 100644
--- a/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc
+++ b/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc
@@ -13,8 +13,14 @@
defined(__s390x__) || defined(__sparc64__) || defined(__alpha__) || \
defined(__ia64__) || defined(__m68k__)) && __GLIBC_PREREQ(2, 21)
typedef uint64_t semval_t;
+#define GET_SEM_VALUE(V) (V)
#else
typedef unsigned semval_t;
+#if __GLIBC_PREREQ(2, 21)
+#define GET_SEM_VALUE(V) ((V) >> 1)
+#else
+#define GET_SEM_VALUE(V) (V)
+#endif
#endif
void my_sem_init(bool priv, int value, semval_t *a, unsigned char *b) {
@@ -34,10 +40,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);
}