[llvm-branch-commits] [compiler-rt-branch] r288513 - [ARM|RT] Merging r24766 into 3.9.1

Renato Golin via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Dec 2 09:33:10 PST 2016


Author: rengolin
Date: Fri Dec  2 11:33:09 2016
New Revision: 288513

URL: http://llvm.org/viewvc/llvm-project?rev=288513&view=rev
Log:
[ARM|RT] Merging r24766 into 3.9.1

Fixes a bug encountered in RC2 validation.

Modified:
    compiler-rt/branches/release_39/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc

Modified: compiler-rt/branches/release_39/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/branches/release_39/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc?rev=288513&r1=288512&r2=288513&view=diff
==============================================================================
--- compiler-rt/branches/release_39/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc (original)
+++ compiler-rt/branches/release_39/test/sanitizer_common/TestCases/Linux/sem_init_glibc.cc Fri Dec  2 11:33:09 2016
@@ -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);
 }




More information about the llvm-branch-commits mailing list