File tree Expand file tree Collapse file tree 1 file changed +8
-19
lines changed Expand file tree Collapse file tree 1 file changed +8
-19
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
-
11
4
#include < filesystem>
12
5
#include < string>
13
6
@@ -17,17 +10,13 @@ std::string ppc::util::GetAbsolutePath(const std::string &relative_path) {
17
10
}
18
11
19
12
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 ' ;
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
+ }
26
20
}
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 ;
33
22
}
You can’t perform that action at this time.
0 commit comments