[PATCH] Enable sanitizers' libc dependencies on FreeBSD

Alexey Samsonov samsonov at google.com
Thu Mar 6 01:49:09 PST 2014



================
Comment at: lib/sanitizer_common/sanitizer_linux_libcdep.cc:405
@@ -356,2 +404,3 @@
 #ifndef SANITIZER_GO
 #if defined(__x86_64__) || defined(__i386__)
+# if SANITIZER_FREEBSD
----------------
Please factor out GetTls function for all platforms, and hide #ifdef clatter inside it. Then you call GetTls(tls_addr, tls_size) in GetThreadStackAndTls unconditionally.

================
Comment at: lib/sanitizer_common/sanitizer_linux_libcdep.cc:306
@@ -296,3 +305,3 @@
 
-#if defined(__x86_64__) || defined(__i386__)
+#if (defined(__x86_64__) || defined(__i386__)) && !SANITIZER_FREEBSD
 // sizeof(struct thread) from glibc.
----------------
I think this is Linux/glibc-specific stuff and we may hide it under "&& SANITIZER_LINUX" instead (at least ThreadDescriptorSize)

================
Comment at: lib/sanitizer_common/sanitizer_linux_libcdep.cc:352
@@ -342,3 +351,3 @@
 
 uptr ThreadSelf() {
   uptr descr_addr;
----------------
I'd prefer to have code like this:
  uptr ThreadSelf() {
  #if SANITIZER_LINUX
  # if defined(__i386__)
    // 32-bit Linux
  # elif defined(__x86_64__)
    // 64-bit Linux
  # else
  #  error "Unsupported arch"
  # endif 
  #elif SANITIZER_FREEBSD
    //...
  #else
  # error "Unknown OS"
  #endif
  }


http://llvm-reviews.chandlerc.com/D2938



More information about the llvm-commits mailing list