Skip to content

Commit 8bd2eb1

Browse files
KenoJeffBezanson
authored andcommitted
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.
1 parent d98db1c commit 8bd2eb1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

base/array.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ segfault your program, in the same manner as C.
244244
function unsafe_copyto!(dest::Ptr{T}, src::Ptr{T}, n) where T
245245
# Do not use this to copy data between pointer arrays.
246246
# It can't be made safe no matter how carefully you checked.
247-
ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, UInt),
247+
ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t),
248248
dest, src, n * aligned_sizeof(T))
249249
return dest
250250
end
@@ -268,13 +268,13 @@ function unsafe_copyto!(dest::Array{T}, doffs, src::Array{T}, soffs, n) where T
268268
ccall(:jl_array_ptr_copy, Cvoid, (Any, Ptr{Cvoid}, Any, Ptr{Cvoid}, Int),
269269
dest, destp, src, srcp, n)
270270
elseif isbitstype(T)
271-
ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, UInt),
271+
ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t),
272272
destp, srcp, n * aligned_sizeof(T))
273273
elseif isbitsunion(T)
274-
ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, UInt),
274+
ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t),
275275
destp, srcp, n * aligned_sizeof(T))
276276
# copy selector bytes
277-
ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, UInt),
277+
ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t),
278278
ccall(:jl_array_typetagdata, Ptr{UInt8}, (Any,), dest) + doffs - 1,
279279
ccall(:jl_array_typetagdata, Ptr{UInt8}, (Any,), src) + soffs - 1,
280280
n)

base/ryu/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
const MANTISSA_MASK = Base.significand_mask(Float64)
22
const EXP_MASK = Base.exponent_mask(Float64) >> Base.significand_bits(Float64)
33

4-
memcpy(d, doff, s, soff, n) = ccall(:memcpy, Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}, Int), d + doff - 1, s + soff - 1, n)
5-
memmove(d, doff, s, soff, n) = ccall(:memmove, Cvoid, (Ptr{Cvoid}, Ptr{Cvoid}, Int), d + doff - 1, s + soff - 1, n)
4+
memcpy(d, doff, s, soff, n) = (ccall(:memcpy, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), d + doff - 1, s + soff - 1, n); nothing)
5+
memmove(d, doff, s, soff, n) = (ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), d + doff - 1, s + soff - 1, n); nothing)
66

77
# Note: these are smaller than the values given in Figure 4 from the paper
88
# see https://github.com/ulfjack/ryu/issues/119

0 commit comments

Comments
 (0)