Skip to content

Commit 19abcf0

Browse files
committed
Fix Windows build: no-op fd handle with runtime_error guard
create_fd_handle and create_fd_handle_ref throw std::runtime_error on Windows since POSIX file descriptors are Linux-only. Made-with: Cursor
1 parent c5ba8f2 commit 19abcf0

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

cuda_core/cuda/core/_cpp/resource_handles.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <cstdint>
1010
#include <cstring>
1111
#include <mutex>
12+
#include <stdexcept>
1213
#include <unordered_map>
1314
#include <vector>
1415

@@ -1125,19 +1126,22 @@ CuLinkHandle create_culink_handle_ref(CUlinkState state) {
11251126
// ============================================================================
11261127

11271128
FileDescriptorHandle create_fd_handle(int fd) {
1129+
#ifdef _WIN32
1130+
throw std::runtime_error("create_fd_handle is not supported on Windows");
1131+
#else
11281132
return FileDescriptorHandle(
11291133
new int(fd),
1130-
[](const int* p) {
1131-
#ifndef _WIN32
1132-
::close(*p);
1133-
#endif
1134-
delete p;
1135-
}
1134+
[](const int* p) { ::close(*p); delete p; }
11361135
);
1136+
#endif
11371137
}
11381138

11391139
FileDescriptorHandle create_fd_handle_ref(int fd) {
1140+
#ifdef _WIN32
1141+
throw std::runtime_error("create_fd_handle_ref is not supported on Windows");
1142+
#else
11401143
return std::make_shared<const int>(fd);
1144+
#endif
11411145
}
11421146

11431147
} // namespace cuda_core

0 commit comments

Comments
 (0)