Skip to content

Commit 740039e

Browse files
committed
Fix Windows build: use _close() on Win32 for fd cleanup
Made-with: Cursor
1 parent e75c096 commit 740039e

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

cuda_core/cuda/core/_cpp/resource_handles.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
#include <unordered_map>
1313
#include <vector>
1414

15-
#ifndef _WIN32
15+
#ifdef _WIN32
16+
#include <io.h>
17+
#else
1618
#include <unistd.h>
1719
#endif
1820

@@ -1124,14 +1126,19 @@ CuLinkHandle create_culink_handle_ref(CUlinkState state) {
11241126
// File Descriptor Handles
11251127
// ============================================================================
11261128

1127-
#ifndef _WIN32
11281129
FileDescriptorHandle create_fd_handle(int fd) {
11291130
return FileDescriptorHandle(
11301131
new int(fd),
1131-
[](const int* p) { ::close(*p); delete p; }
1132+
[](const int* p) {
1133+
#ifdef _WIN32
1134+
::_close(*p);
1135+
#else
1136+
::close(*p);
1137+
#endif
1138+
delete p;
1139+
}
11321140
);
11331141
}
1134-
#endif
11351142

11361143
FileDescriptorHandle create_fd_handle_ref(int fd) {
11371144
return std::make_shared<const int>(fd);

0 commit comments

Comments
 (0)