components/llvm/patches/020-solaris-utils-googletest.patch
changeset 6512 92717ce71105
equal deleted inserted replaced
6511:d283aa33e131 6512:92717ce71105
       
     1 # 22643565 - llvm's Google test harness needs some attention
       
     2 # 3.9.X for upstream.
       
     3 --- utils/unittest/googletest/include/gtest/internal/gtest-port.h	2015-04-10 22:11:45.000000000 -0400
       
     4 +++ utils/unittest/googletest/include/gtest/internal/gtest-port.h	2016-05-08 23:19:20.582431969 -0400
       
     5 @@ -238,7 +238,7 @@
       
     6  # endif  // ANDROID
       
     7  #elif defined __MVS__
       
     8  # define GTEST_OS_ZOS 1
       
     9 -#elif defined(__sun) && defined(__SVR4)
       
    10 +#elif defined(__sun) || defined(__sun__)
       
    11  # define GTEST_OS_SOLARIS 1
       
    12  #elif defined(_AIX)
       
    13  # define GTEST_OS_AIX 1
       
    14 --- utils/unittest/googletest/src/gtest-port.cc	2013-11-18 19:57:56.000000000 -0500
       
    15 +++ utils/unittest/googletest/src/gtest-port.cc	2016-05-08 23:19:20.582431969 -0400
       
    16 @@ -51,6 +51,13 @@
       
    17  # include <mach/vm_map.h>
       
    18  #endif  // GTEST_OS_MAC
       
    19  
       
    20 +#if GTEST_OS_SOLARIS
       
    21 +# include <strings.h>
       
    22 +# include <sys/types.h>
       
    23 +# include <dirent.h>
       
    24 +# include <unistd.h>
       
    25 +#endif
       
    26 +
       
    27  #include "gtest/gtest-spi.h"
       
    28  #include "gtest/gtest-message.h"
       
    29  #include "gtest/internal/gtest-internal.h"
       
    30 @@ -77,7 +84,7 @@
       
    31  const int kStdErrFileno = STDERR_FILENO;
       
    32  #endif  // _MSC_VER
       
    33  
       
    34 -#if GTEST_OS_MAC
       
    35 +#if defined(GTEST_OS_MAC)
       
    36  
       
    37  // Returns the number of threads running in the process, or 0 to indicate that
       
    38  // we cannot detect it.
       
    39 @@ -98,6 +105,36 @@
       
    40    }
       
    41  }
       
    42  
       
    43 +#elif defined(GTEST_OS_SOLARIS)
       
    44 +
       
    45 +size_t GetThreadCount() {
       
    46 +  size_t NumThreads = 1U;
       
    47 +  char lwpdir[PATH_MAX+1];
       
    48 +
       
    49 +  (void) std::memset(lwpdir, 0, sizeof(lwpdir));
       
    50 +  (void) std::sprintf(lwpdir, "/proc/%i/lwp/", static_cast<int>(getpid()));
       
    51 +
       
    52 +  struct dirent *DE;
       
    53 +  DIR *D = ::opendir(lwpdir);
       
    54 +  if (!D)
       
    55 +    return NumThreads;
       
    56 +
       
    57 +  while ((DE = ::readdir(D)) != NULL) {
       
    58 +    if (DE->d_name[0] == '.') {
       
    59 +      if ((DE->d_name[1] == '\0') ||
       
    60 +          ((DE->d_name[1] == '.') && (DE->d_name[2] == '\0')))
       
    61 +        continue;
       
    62 +    }
       
    63 +
       
    64 +    NumThreads =
       
    65 +      static_cast<size_t>(std::max<int>(NumThreads, std::atoi(DE->d_name)));
       
    66 +  }
       
    67 +
       
    68 +  ::rewinddir(D);
       
    69 +  ::closedir(D);
       
    70 +  return NumThreads;
       
    71 +}
       
    72 +
       
    73  #else
       
    74  
       
    75  size_t GetThreadCount() {