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
104
115#include < filesystem>
126#include < string>
@@ -17,17 +11,13 @@ std::string ppc::util::GetAbsolutePath(const std::string &relative_path) {
1711}
1812
1913int 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 ' ;
14+ const char *env = std::getenv (" PPC_NUM_THREADS" ); // NOLINT(concurrency-mt-unsafe)
15+ if ((env != nullptr ) && (*env != 0 )) {
16+ char *endptr = nullptr ;
17+ long val = std::strtol (env, &endptr, 10 );
18+ if (endptr != env && val > 0 ) {
19+ return static_cast <int >(val);
20+ }
2621 }
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;
22+ return 1 ;
3323}
You can’t perform that action at this time.
0 commit comments