From 8bd2eb193df9b0c42ddca68a29e844782fac0934 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Mon, 23 Dec 2019 02:46:29 +0100 Subject: [PATCH] Correct signature of memmove (#34165) wasm was complaining about the incorrect Cvoid rather than Ptr{Void} in the :memmove calls in ryu, but while we're here also change the third argument to Csize_t, since that's what the standard says it is. --- base/array.jl | 8 ++++---- base/ryu/utils.jl | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/base/array.jl b/base/array.jl index ca89fc1571cbe..cdffc3798bf5d 100644 --- a/base/array.jl +++ b/base/array.jl @@ -244,7 +244,7 @@ segfault your program, in the same manner as C. function unsafe_copyto!(dest::Ptr{T}, src::Ptr{T}, n) where T # Do not use this to copy data between pointer arrays. # It can't be made safe no matter how carefully you checked. - ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, UInt), + ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), dest, src, n * aligned_sizeof(T)) return dest end @@ -268,13 +268,13 @@ function unsafe_copyto!(dest::Array{T}, doffs, src::Array{T}, soffs, n) where T ccall(:jl_array_ptr_copy, Cvoid, (Any, Ptr{Cvoid}, Any, Ptr{Cvoid}, Int), dest, destp, src, srcp, n) elseif isbitstype(T) - ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, UInt), + ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), destp, srcp, n * aligned_sizeof(T)) elseif isbitsunion(T) - ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, UInt), + ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), destp, srcp, n * aligned_sizeof(T)) # copy selector bytes - ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, UInt), + ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), ccall(:jl_array_typetagdata, Ptr{UInt8}, (Any,), dest) + doffs - 1, ccall(:jl_array_typetagdata, Ptr{UInt8}, (Any,), src) + soffs - 1, n) diff --git a/base/ryu/utils.jl b/base/ryu/utils.jl index 46a88c0ef9d9f..49b0856f4c6f1 100644 --- a/base/ryu/utils.jl +++ b/base/ryu/utils.jl @@ -1,8 +1,8 @@ const MANTISSA_MASK = Base.significand_mask(Float64) const EXP_MASK = Base.exponent_mask(Float64) >> Base.significand_bits(Float64) -memcpy(d, doff, s, soff, n) = ccall(:memcpy, Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}, Int), d + doff - 1, s + soff - 1, n) -memmove(d, doff, s, soff, n) = ccall(:memmove, Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}, Int), d + doff - 1, s + soff - 1, n) +memcpy(d, doff, s, soff, n) = (ccall(:memcpy, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), d + doff - 1, s + soff - 1, n); nothing) +memmove(d, doff, s, soff, n) = (ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), d + doff - 1, s + soff - 1, n); nothing) # Note: these are smaller than the values given in Figure 4 from the paper # see https://github.com/ulfjack/ryu/issues/119