diff options
Diffstat (limited to 'src/gtest-port.cc')
-rw-r--r-- | src/gtest-port.cc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/gtest-port.cc b/src/gtest-port.cc index b860d48..3206914 100644 --- a/src/gtest-port.cc +++ b/src/gtest-port.cc @@ -51,6 +51,11 @@ # include <mach/vm_map.h> #endif // GTEST_OS_MAC +#if GTEST_OS_QNX +# include <devctl.h> +# include <sys/procfs.h> +#endif // GTEST_OS_QNX + #include "gtest/gtest-spi.h" #include "gtest/gtest-message.h" #include "gtest/internal/gtest-internal.h" @@ -98,6 +103,26 @@ size_t GetThreadCount() { } } +#elif GTEST_OS_QNX + +// Returns the number of threads running in the process, or 0 to indicate that +// we cannot detect it. +size_t GetThreadCount() { + const int fd = open("/proc/self/as", O_RDONLY); + if (fd < 0) { + return 0; + } + procfs_info process_info; + const int status = + devctl(fd, DCMD_PROC_INFO, &process_info, sizeof(process_info), NULL); + close(fd); + if (status == EOK) { + return static_cast<size_t>(process_info.num_threads); + } else { + return 0; + } +} + #else size_t GetThreadCount() { |