[PATCH] D45725: [sanitizer] Minor refactor of ThreadDescriptorSize

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 18 08:34:50 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rCRT330268: [sanitizer] Minor refactor of ThreadDescriptorSize (authored by cryptoad, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D45725?vs=142786&id=142947#toc

Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D45725

Files:
  lib/sanitizer_common/sanitizer_linux_libcdep.cc


Index: lib/sanitizer_common/sanitizer_linux_libcdep.cc
===================================================================
--- lib/sanitizer_common/sanitizer_linux_libcdep.cc
+++ lib/sanitizer_common/sanitizer_linux_libcdep.cc
@@ -219,10 +219,10 @@
      defined(__arm__)) &&                                                      \
     SANITIZER_LINUX && !SANITIZER_ANDROID
 // sizeof(struct pthread) from glibc.
-static atomic_uintptr_t kThreadDescriptorSize;
+static atomic_uintptr_t thread_descriptor_size;
 
 uptr ThreadDescriptorSize() {
-  uptr val = atomic_load(&kThreadDescriptorSize, memory_order_relaxed);
+  uptr val = atomic_load_relaxed(&thread_descriptor_size);
   if (val)
     return val;
 #if defined(__x86_64__) || defined(__i386__) || defined(__arm__)
@@ -261,31 +261,22 @@
       else
         val = FIRST_32_SECOND_64(1216, 2304);
     }
-    if (val)
-      atomic_store(&kThreadDescriptorSize, val, memory_order_relaxed);
-    return val;
   }
 #endif
 #elif defined(__mips__)
   // TODO(sagarthakur): add more values as per different glibc versions.
   val = FIRST_32_SECOND_64(1152, 1776);
-  if (val)
-    atomic_store(&kThreadDescriptorSize, val, memory_order_relaxed);
-  return val;
 #elif defined(__aarch64__)
   // The sizeof (struct pthread) is the same from GLIBC 2.17 to 2.22.
   val = 1776;
-  atomic_store(&kThreadDescriptorSize, val, memory_order_relaxed);
-  return val;
 #elif defined(__powerpc64__)
   val = 1776; // from glibc.ppc64le 2.20-8.fc21
-  atomic_store(&kThreadDescriptorSize, val, memory_order_relaxed);
-  return val;
 #elif defined(__s390__)
   val = FIRST_32_SECOND_64(1152, 1776); // valid for glibc 2.22
-  atomic_store(&kThreadDescriptorSize, val, memory_order_relaxed);
 #endif
-  return 0;
+  if (val)
+    atomic_store_relaxed(&thread_descriptor_size, val);
+  return val;
 }
 
 // The offset at which pointer to self is located in the thread descriptor.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45725.142947.patch
Type: text/x-patch
Size: 1916 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180418/2c8b81cb/attachment.bin>


More information about the llvm-commits mailing list