|
21 | 21 | #include <string> |
22 | 22 | #include <vector> |
23 | 23 |
|
24 | | -#ifdef _WIN32 |
25 | | -#include <windows.h> |
26 | | -inline int ur_getpid(void) { return static_cast<int>(GetCurrentProcessId()); } |
27 | | -#else |
28 | | - |
29 | | -#include <unistd.h> |
30 | | -inline int ur_getpid(void) { return static_cast<int>(getpid()); } |
31 | | -#endif |
| 24 | +int ur_getpid(void); |
32 | 25 |
|
33 | 26 | /* for compatibility with non-clang compilers */ |
34 | 27 | #if defined(__has_feature) |
@@ -61,7 +54,6 @@ inline int ur_getpid(void) { return static_cast<int>(getpid()); } |
61 | 54 | #if defined(_WIN32) |
62 | 55 | #define MAKE_LIBRARY_NAME(NAME, VERSION) NAME ".dll" |
63 | 56 | #else |
64 | | -#define HMODULE void * |
65 | 57 | #if defined(__APPLE__) |
66 | 58 | #define MAKE_LIBRARY_NAME(NAME, VERSION) "lib" NAME "." VERSION ".dylib" |
67 | 59 | #else |
@@ -93,29 +85,7 @@ inline std::string create_library_path(const char *name, const char *path) { |
93 | 85 | #endif |
94 | 86 |
|
95 | 87 | /////////////////////////////////////////////////////////////////////////////// |
96 | | -inline std::optional<std::string> ur_getenv(const char *name) { |
97 | | -#if defined(_WIN32) |
98 | | - constexpr int buffer_size = 1024; |
99 | | - char buffer[buffer_size]; |
100 | | - auto rc = GetEnvironmentVariableA(name, buffer, buffer_size); |
101 | | - if (0 != rc && rc < buffer_size) { |
102 | | - return std::string(buffer); |
103 | | - } else if (rc >= buffer_size) { |
104 | | - std::stringstream ex_ss; |
105 | | - ex_ss << "Environment variable " << name << " value too long!" |
106 | | - << " Maximum length is " << buffer_size - 1 << " characters."; |
107 | | - throw std::invalid_argument(ex_ss.str()); |
108 | | - } |
109 | | - return std::nullopt; |
110 | | -#else |
111 | | - const char *tmp_env = getenv(name); |
112 | | - if (tmp_env != nullptr) { |
113 | | - return std::string(tmp_env); |
114 | | - } else { |
115 | | - return std::nullopt; |
116 | | - } |
117 | | -#endif |
118 | | -} |
| 88 | +std::optional<std::string> ur_getenv(const char *name); |
119 | 89 |
|
120 | 90 | inline bool getenv_tobool(const char *name) { |
121 | 91 | auto env = ur_getenv(name); |
|
0 commit comments