mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-25 15:21:54 +00:00
Implement GetThreadCount on Linux.
This commit is contained in:
parent
431b556951
commit
44e23c39f1
@ -8258,6 +8258,7 @@ void FilePath::Normalize() {
|
|||||||
# include <sys/stat.h>
|
# include <sys/stat.h>
|
||||||
#else
|
#else
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
|
# include <dirent.h>
|
||||||
#endif // GTEST_OS_WINDOWS_MOBILE
|
#endif // GTEST_OS_WINDOWS_MOBILE
|
||||||
|
|
||||||
#if GTEST_OS_MAC
|
#if GTEST_OS_MAC
|
||||||
@ -8333,6 +8334,22 @@ size_t GetThreadCount() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#elif GTEST_OS_LINUX
|
||||||
|
|
||||||
|
// Returns the number of threads running in the process, or 0 to indicate that
|
||||||
|
// we cannot detect it.
|
||||||
|
size_t GetThreadCount() {
|
||||||
|
size_t thread_count = 0;
|
||||||
|
if (DIR *dir = opendir("/proc/self/task")) {
|
||||||
|
while (dirent *entry = readdir(dir)) {
|
||||||
|
if (entry->d_name[0] != '.')
|
||||||
|
++thread_count;
|
||||||
|
}
|
||||||
|
closedir(dir);
|
||||||
|
}
|
||||||
|
return thread_count;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
size_t GetThreadCount() {
|
size_t GetThreadCount() {
|
||||||
|
Loading…
Reference in New Issue
Block a user