Skip to content

Commit 2b3611b

Browse files
committed
Remove Windows support for hostname and username query again due to extended compiler and linker errors in Windows internal headers.
1 parent 5e12c3b commit 2b3611b

2 files changed

Lines changed: 0 additions & 34 deletions

File tree

src/plssvm/detail/tracking/CMakeLists.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ target_sources(
1212
${PLSSVM_BASE_LIBRARY_NAME} PRIVATE $<BUILD_INTERFACE: ${CMAKE_CURRENT_SOURCE_DIR}/performance_tracker.cpp; ${CMAKE_CURRENT_SOURCE_DIR}/events.cpp; >
1313
)
1414

15-
# need to link against special library under Windows
16-
if (WIN32)
17-
target_link_libraries(${PLSSVM_BASE_LIBRARY_NAME} PRIVATE Ws2_32)
18-
endif ()
19-
2015
# add target definitions
2116
target_compile_definitions(${PLSSVM_BASE_LIBRARY_NAME} PUBLIC PLSSVM_PERFORMANCE_TRACKER_ENABLED)
2217

src/plssvm/detail/tracking/performance_tracker.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,6 @@
4848
#define PLSSVM_HAS_POSIX_INCLUDES
4949
#endif
5050

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-
5851
#if defined(PLSSVM_STDPAR_BACKEND_HAS_GNU_TBB)
5952
#include "boost/version.hpp" // BOOST_VERSION
6053
#endif
@@ -94,17 +87,8 @@ namespace {
9487
* @return the hostname of the current machine (`[[nodiscard]]`)
9588
*/
9689
[[nodiscard]] std::string get_hostname() {
97-
// maximum number of characters is given as a constant under Linux
9890
#if defined(PLSSVM_HAS_POSIX_INCLUDES)
9991
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)
10892
std::string hostname(host_name_max, '\0');
10993
if (gethostname(hostname.data(), host_name_max) != 0) {
11094
hostname = "not available";
@@ -137,18 +121,6 @@ namespace {
137121
username = "not available";
138122
}
139123
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;
152124
#else
153125
return "not available";
154126
#endif
@@ -538,4 +510,3 @@ performance_tracker &global_performance_tracker() {
538510
} // namespace plssvm::detail::tracking
539511

540512
#undef PLSSVM_HAS_POSIX_INCLUDES
541-
#undef PLSSVM_HAS_WINDOWS_INCLUDES

0 commit comments

Comments
 (0)