[sanitizer] define SANITIZER_X32 and use it in ThreadDescriptorSize; partially based...
authorKostya Serebryany <kcc@google.com>
Wed, 21 May 2014 08:01:44 +0000 (08:01 +0000)
committerKostya Serebryany <kcc@google.com>
Wed, 21 May 2014 08:01:44 +0000 (08:01 +0000)
llvm-svn: 209279

compiler-rt/lib/sanitizer_common/sanitizer_linux_libcdep.cc
compiler-rt/lib/sanitizer_common/sanitizer_platform.h

index 40eabfd..6093593 100644 (file)
@@ -312,7 +312,9 @@ uptr ThreadDescriptorSize() {
     int minor = internal_simple_strtoll(buf + 8, &end, 10);
     if (end != buf + 8 && (*end == '\0' || *end == '.')) {
       /* sizeof(struct thread) values from various glibc versions.  */
-      if (minor <= 3)
+      if (SANITIZER_X32)
+        val = 1728;  // Assume only one particular version for x32.
+      else if (minor <= 3)
         val = FIRST_32_SECOND_64(1104, 1696);
       else if (minor == 4)
         val = FIRST_32_SECOND_64(1120, 1728);
index a36b05d..d9a7868 100644 (file)
 # define FIRST_32_SECOND_64(a, b) (a)
 #endif
 
+#if defined(__x86_64__) && !defined(_LP64)
+# define SANITIZER_X32 1
+#else
+# define SANITIZER_X32 0
+#endif
+
 // By default we allow to use SizeClassAllocator64 on 64-bit platform.
 // But in some cases (e.g. AArch64's 39-bit address space) SizeClassAllocator64
 // does not work well and we need to fallback to SizeClassAllocator32.