diff options
author | vladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925> | 2011-06-20 21:43:18 +0000 |
---|---|---|
committer | vladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925> | 2011-06-20 21:43:18 +0000 |
commit | 386da2037dc7b1d063ac43bf146889b1edcafe7e (patch) | |
tree | 3751feb2e92b653ef02a00d1fa2c6b5d907d0723 /src/gtest-port.cc | |
parent | f3cf0a2316b68cbdc64a00eb61fc8ff955259282 (diff) | |
download | googletest-386da2037dc7b1d063ac43bf146889b1edcafe7e.tar.gz googletest-386da2037dc7b1d063ac43bf146889b1edcafe7e.tar.bz2 googletest-386da2037dc7b1d063ac43bf146889b1edcafe7e.zip |
QNX compatibility patch (by Haruka Iwao).
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 b860d481..32069146 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() { |