components/llvm/patches/020-solaris-utils-googletest.patch
author Stefan Teleman <stefan.teleman@oracle.com>
Thu, 28 Jul 2016 16:25:34 -0700
changeset 6512 92717ce71105
permissions -rw-r--r--
24326140 upgrade LLVM to 3.8.1 24326159 upgrade clang to 3.8.1 22902339 memory corruption caused by undefined behavior in LLVM IR Module 22777179 implement [ -mtune= -march= -mcpu= ] in clang SPARC 22778085 LLVM is using %icc when it should be using %xcc 22778089 the SPARCV9 IS implementation is incomplete 22778098 LLVM should emit proc identifiers in SPARC assembler (capabilities) 22778650 clang should support OpenMP because it can 22859423 llvm CodeGen on Intel emits a bogus .ctors section 22902355 clang CodeGen is affected by 22902339 23701635 clang produces amd64 opcodes, but calls 32-bit assembler by default 23593143 lli JIT bitcode parsing creates a main function with wrong argc/argv 21759660 clang packages should include the scan-view and scan-build utilities 23854357 clang should check for GNU ld 17867434 clang crashed in LEXER 24306550 clang crashes in llvm::Twine::toStringRef 24311726 clang's Perl and Python utilities should not use #!/usr/bin/env 24312028 llvm::Twine needs copy constructors and assignment operators 24312221 classes must be CopyConstructible, CopyAssignable, MoveConstructible ... 24314621 LLVM should build using the new CMake based build system 24314638 LLVM CommandLine subsystem is busted 24314687 static initialization of optimization passes doesn't work as intended 21870069 clang makes incorrect assumptions about anonymous namespace instantiation order 22643565 llvm's Google test harness needs some attention 24314745 clang should support PIE executables in Solaris

# 22643565 - llvm's Google test harness needs some attention
# 3.9.X for upstream.
--- utils/unittest/googletest/include/gtest/internal/gtest-port.h	2015-04-10 22:11:45.000000000 -0400
+++ utils/unittest/googletest/include/gtest/internal/gtest-port.h	2016-05-08 23:19:20.582431969 -0400
@@ -238,7 +238,7 @@
 # endif  // ANDROID
 #elif defined __MVS__
 # define GTEST_OS_ZOS 1
-#elif defined(__sun) && defined(__SVR4)
+#elif defined(__sun) || defined(__sun__)
 # define GTEST_OS_SOLARIS 1
 #elif defined(_AIX)
 # define GTEST_OS_AIX 1
--- utils/unittest/googletest/src/gtest-port.cc	2013-11-18 19:57:56.000000000 -0500
+++ utils/unittest/googletest/src/gtest-port.cc	2016-05-08 23:19:20.582431969 -0400
@@ -51,6 +51,13 @@
 # include <mach/vm_map.h>
 #endif  // GTEST_OS_MAC
 
+#if GTEST_OS_SOLARIS
+# include <strings.h>
+# include <sys/types.h>
+# include <dirent.h>
+# include <unistd.h>
+#endif
+
 #include "gtest/gtest-spi.h"
 #include "gtest/gtest-message.h"
 #include "gtest/internal/gtest-internal.h"
@@ -77,7 +84,7 @@
 const int kStdErrFileno = STDERR_FILENO;
 #endif  // _MSC_VER
 
-#if GTEST_OS_MAC
+#if defined(GTEST_OS_MAC)
 
 // Returns the number of threads running in the process, or 0 to indicate that
 // we cannot detect it.
@@ -98,6 +105,36 @@
   }
 }
 
+#elif defined(GTEST_OS_SOLARIS)
+
+size_t GetThreadCount() {
+  size_t NumThreads = 1U;
+  char lwpdir[PATH_MAX+1];
+
+  (void) std::memset(lwpdir, 0, sizeof(lwpdir));
+  (void) std::sprintf(lwpdir, "/proc/%i/lwp/", static_cast<int>(getpid()));
+
+  struct dirent *DE;
+  DIR *D = ::opendir(lwpdir);
+  if (!D)
+    return NumThreads;
+
+  while ((DE = ::readdir(D)) != NULL) {
+    if (DE->d_name[0] == '.') {
+      if ((DE->d_name[1] == '\0') ||
+          ((DE->d_name[1] == '.') && (DE->d_name[2] == '\0')))
+        continue;
+    }
+
+    NumThreads =
+      static_cast<size_t>(std::max<int>(NumThreads, std::atoi(DE->d_name)));
+  }
+
+  ::rewinddir(D);
+  ::closedir(D);
+  return NumThreads;
+}
+
 #else
 
 size_t GetThreadCount() {