From 1e5f0d6de865b1bf44c6c2f667b8db3f82bc2a3e Mon Sep 17 00:00:00 2001 From: Tim Besard Date: Tue, 9 Apr 2024 17:18:18 +0200 Subject: [PATCH] Adapt to JuliaLang/julia#53687. --- src/pointer.jl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/pointer.jl b/src/pointer.jl index c49b006a15..c09b227863 100644 --- a/src/pointer.jl +++ b/src/pointer.jl @@ -73,8 +73,15 @@ Base.:(==)(x::CuPtr, y::CuPtr) = UInt(x) == UInt(y) Base.:(<)(x::CuPtr, y::CuPtr) = UInt(x) < UInt(y) Base.:(-)(x::CuPtr, y::CuPtr) = UInt(x) - UInt(y) +if VERSION >= v"1.12.0-DEV.225" +Base.:(+)(x::CuPtr{T}, y::Integer) where T = + reinterpret(CuPtr{T}, Base.add_ptr(reinterpret(Ptr{T}, x), (y % UInt) % UInt)) +Base.:(-)(x::CuPtr{T}, y::Integer) where T = + reinterpret(CuPtr{T}, Base.sub_ptr(reinterpret(Ptr{T}, x), (y % UInt) % UInt)) +else Base.:(+)(x::CuPtr, y::Integer) = oftype(x, Base.add_ptr(UInt(x), (y % UInt) % UInt)) Base.:(-)(x::CuPtr, y::Integer) = oftype(x, Base.sub_ptr(UInt(x), (y % UInt) % UInt)) +end Base.:(+)(x::Integer, y::CuPtr) = y + x @@ -186,8 +193,15 @@ Base.:(==)(x::CuArrayPtr, y::CuArrayPtr) = UInt(x) == UInt(y) Base.:(<)(x::CuArrayPtr, y::CuArrayPtr) = UInt(x) < UInt(y) Base.:(-)(x::CuArrayPtr, y::CuArrayPtr) = UInt(x) - UInt(y) +if VERSION >= v"1.12.0-DEV.225" +Base.:(+)(x::CuArrayPtr{T}, y::Integer) where T = + reinterpret(CuArrayPtr{T}, Base.add_ptr(reinterpret(Ptr{T}, x), (y % UInt) % UInt)) +Base.:(-)(x::CuArrayPtr{T}, y::Integer) where T = + reinterpret(CuArrayPtr{T}, Base.sub_ptr(reinterpret(Ptr{T}, x), (y % UInt) % UInt)) +else Base.:(+)(x::CuArrayPtr, y::Integer) = oftype(x, Base.add_ptr(UInt(x), (y % UInt) % UInt)) Base.:(-)(x::CuArrayPtr, y::Integer) = oftype(x, Base.sub_ptr(UInt(x), (y % UInt) % UInt)) +end Base.:(+)(x::Integer, y::CuArrayPtr) = y + x