|
48 | 48 | #define PLSSVM_HAS_POSIX_INCLUDES |
49 | 49 | #endif |
50 | 50 |
|
51 | | -#if __has_include(<winsock.h>) |
52 | | - #include <Lmcons.h> // UNLEN |
53 | | - #include <windows.h> // GetUserNameA, DWORD |
54 | | - #include <winsock2.h> // gethostname |
55 | | - #define PLSSVM_HAS_WINDOWS_INCLUDES |
56 | | -#endif |
57 | | - |
58 | 51 | #if defined(PLSSVM_STDPAR_BACKEND_HAS_GNU_TBB) |
59 | 52 | #include "boost/version.hpp" // BOOST_VERSION |
60 | 53 | #endif |
@@ -94,17 +87,8 @@ namespace { |
94 | 87 | * @return the hostname of the current machine (`[[nodiscard]]`) |
95 | 88 | */ |
96 | 89 | [[nodiscard]] std::string get_hostname() { |
97 | | - // maximum number of characters is given as a constant under Linux |
98 | 90 | #if defined(PLSSVM_HAS_POSIX_INCLUDES) |
99 | 91 | const auto host_name_max = static_cast<std::size_t>(sysconf(_SC_HOST_NAME_MAX)); |
100 | | -#endif |
101 | | - |
102 | | - // maximum number of characters is given in the documentation (256) |
103 | | -#if defined(PLSSVM_HAS_WINDOWS_INCLUDES) |
104 | | - const std::size_t host_name_max = 256; |
105 | | -#endif |
106 | | - |
107 | | -#if defined(PLSSVM_HAS_POSIX_INCLUDES) || defined(PLSSVM_HAS_WINDOWS_INCLUDES) |
108 | 92 | std::string hostname(host_name_max, '\0'); |
109 | 93 | if (gethostname(hostname.data(), host_name_max) != 0) { |
110 | 94 | hostname = "not available"; |
@@ -137,18 +121,6 @@ namespace { |
137 | 121 | username = "not available"; |
138 | 122 | } |
139 | 123 | return username; |
140 | | -#elif defined(PLSSVM_HAS_WINDOWS_INCLUDES) |
141 | | - auto size = static_cast<DWORD>(UNLEN + 1); |
142 | | - std::string username(size, '\0'); |
143 | | - if (!GetUserNameA(username.data(), &size)) { |
144 | | - username = "not available"; |
145 | | - } |
146 | | - // resize to actual string length (truncate trailing '\0's) |
147 | | - username.resize(size - 1); |
148 | | - if (username.empty()) { |
149 | | - username = "not available"; |
150 | | - } |
151 | | - return username; |
152 | 124 | #else |
153 | 125 | return "not available"; |
154 | 126 | #endif |
@@ -538,4 +510,3 @@ performance_tracker &global_performance_tracker() { |
538 | 510 | } // namespace plssvm::detail::tracking |
539 | 511 |
|
540 | 512 | #undef PLSSVM_HAS_POSIX_INCLUDES |
541 | | -#undef PLSSVM_HAS_WINDOWS_INCLUDES |
0 commit comments