Skip to content

Commit 43345d6

Browse files
committed
int -> intptr_t -> void* is safer
1 parent 605241e commit 43345d6

File tree

1 file changed

+1
-24
lines changed

1 file changed

+1
-24
lines changed

cuda_core/cuda/core/experimental/_memory.pyx

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -42,29 +42,6 @@ if TYPE_CHECKING:
4242
# MemoryResource both inherit from it
4343

4444

45-
cdef extern from * nogil:
46-
"""
47-
#if defined(__GNUC__)
48-
#pragma GCC diagnostic push
49-
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
50-
#elif defined(_MSC_VER)
51-
#pragma warning(push)
52-
#pragma warning(disable : 4312)
53-
#endif
54-
55-
void* unsafe_cast_from_int(int x) {
56-
return (void*)x;
57-
}
58-
59-
#if defined(__GNUC__)
60-
#pragma GCC diagnostic pop
61-
#elif defined(_MSC_VER)
62-
#pragma warning(pop)
63-
#endif
64-
"""
65-
void* unsafe_cast_from_int(int x)
66-
67-
6845
PyCapsule = TypeVar("PyCapsule")
6946
"""Represent the capsule type."""
7047

@@ -881,7 +858,7 @@ cdef class DeviceMemoryResource(_cyMemoryResource, MemoryResource):
881858
cdef int handle = int(alloc_handle)
882859
with nogil:
883860
HANDLE_RETURN(cydriver.cuMemPoolImportFromShareableHandle(
884-
&(self._mempool_handle), unsafe_cast_from_int(handle), _IPC_HANDLE_TYPE, 0)
861+
&(self._mempool_handle), <void*><intptr_t>(handle), _IPC_HANDLE_TYPE, 0)
885862
)
886863
if uuid is not None:
887864
registered = self.register(uuid)

0 commit comments

Comments
 (0)