File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#include " core/util/include/util.hpp"
22
33#include < cstdlib>
4- #ifdef _WIN32
5- #include < cstdint>
6- #include < iostream>
7- #include < memory>
8- #include < vector>
9- #endif
10-
114#include < filesystem>
125#include < string>
136
@@ -17,17 +10,13 @@ std::string ppc::util::GetAbsolutePath(const std::string &relative_path) {
1710}
1811
1912int ppc::util::GetPPCNumThreads () {
20- #ifdef _WIN32
21- size_t len;
22- char omp_env[100 ];
23- errno_t err = getenv_s (&len, omp_env, sizeof (omp_env), " PPC_NUM_THREADS" );
24- if (err != 0 || len == 0 ) {
25- omp_env[0 ] = ' \0 ' ;
13+ const char *env = std::getenv (" PPC_NUM_THREADS" ); // NOLINT(concurrency-mt-unsafe)
14+ if ((env != nullptr ) && (*env != 0 )) {
15+ char *endptr = nullptr ;
16+ long val = std::strtol (env, &endptr, 10 );
17+ if (endptr != env && val > 0 ) {
18+ return static_cast <int >(val);
19+ }
2620 }
27- int num_threads = std::atoi (omp_env);
28- #else
29- const char *omp_env = std::getenv (" PPC_NUM_THREADS" ); // NOLINT(concurrency-mt-unsafe)
30- int num_threads = (omp_env != nullptr ) ? std::atoi (omp_env) : 1 ;
31- #endif
32- return num_threads;
21+ return 1 ;
3322}
You can’t perform that action at this time.
0 commit comments