summaryrefslogtreecommitdiff
path: root/src/gtest-port.cc
diff options
context:
space:
mode:
authorvladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2011-06-20 21:43:18 +0000
committervladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2011-06-20 21:43:18 +0000
commit105b1431c37c159892cc0983dd0bc2411c6f0c96 (patch)
tree3751feb2e92b653ef02a00d1fa2c6b5d907d0723 /src/gtest-port.cc
parent4f9248a4270559cf286cb12937ba78b58bde053f (diff)
downloadgtest-105b1431c37c159892cc0983dd0bc2411c6f0c96.tar.gz
gtest-105b1431c37c159892cc0983dd0bc2411c6f0c96.tar.bz2
gtest-105b1431c37c159892cc0983dd0bc2411c6f0c96.tar.xz
QNX compatibility patch (by Haruka Iwao).
git-svn-id: http://googletest.googlecode.com/svn/trunk@586 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'src/gtest-port.cc')
-rw-r--r--src/gtest-port.cc25
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() {