Skip to content

Commit ddb8012

Browse files
committed
Merge pull request google#602 from mtbrandy/threadcount_aix
Implement GetThreadCount for AIX.
2 parents 0162ff7 + bf7e9e8 commit ddb8012

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

googletest/src/gtest-port.cc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
# include <sys/procfs.h>
5959
#endif // GTEST_OS_QNX
6060

61+
#if GTEST_OS_AIX
62+
# include <procinfo.h>
63+
# include <sys/types.h>
64+
#endif // GTEST_OS_AIX
65+
6166
#include "gtest/gtest-spi.h"
6267
#include "gtest/gtest-message.h"
6368
#include "gtest/internal/gtest-internal.h"
@@ -146,6 +151,19 @@ size_t GetThreadCount() {
146151
}
147152
}
148153

154+
#elif GTEST_OS_AIX
155+
156+
size_t GetThreadCount() {
157+
struct procentry64 entry;
158+
pid_t pid = getpid();
159+
int status = getprocs64(&entry, sizeof(entry), NULL, 0, &pid, 1);
160+
if (status == 1) {
161+
return entry.pi_thcount;
162+
} else {
163+
return 0;
164+
}
165+
}
166+
149167
#else
150168

151169
size_t GetThreadCount() {

0 commit comments

Comments
 (0)