File tree Expand file tree Collapse file tree 1 file changed +8
-18
lines changed Expand file tree Collapse file tree 1 file changed +8
-18
lines changed Original file line number Diff line number Diff line change 1
1
#include " core/util/include/util.hpp"
2
2
3
3
#include < cstdlib>
4
- #ifdef _WIN32
5
- #include < cstdint>
6
- #include < iostream>
7
- #include < memory>
8
- #include < vector>
9
- #endif
10
4
11
5
#include < filesystem>
12
6
#include < string>
@@ -17,17 +11,13 @@ std::string ppc::util::GetAbsolutePath(const std::string &relative_path) {
17
11
}
18
12
19
13
int 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
+ }
26
21
}
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 ;
33
23
}
You can’t perform that action at this time.
0 commit comments