-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Libc methods for memmove/memcpy/memset/memcmp (#49550)
These are used in many places (and are actually LLVM compiler intrinsics), so it probably makes more sense to define them one and export them to users. The Libc module contains some code that we might not care to have as part of bootstrapping. However, the C-memory methods are directly called throughout bootstrapping so these are now defined in a seperate "cmem.jl" file that is defined in Base then imported into `Libc` for the public interface. Co-authored-by: Jameson Nash <[email protected]>
- Loading branch information
Showing
24 changed files
with
158 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# This file is a part of Julia. License is MIT: https://julialang.org/license | ||
|
||
""" | ||
memcpy(dst::Ptr, src::Ptr, n::Integer) -> Ptr{Cvoid} | ||
Call `memcpy` from the C standard library. | ||
!!! compat "Julia 1.10" | ||
Support for `memcpy` requires at least Julia 1.10. | ||
""" | ||
function memcpy(dst::Ptr, src::Ptr, n::Integer) | ||
ccall(:memcpy, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), dst, src, n) | ||
end | ||
|
||
""" | ||
memmove(dst::Ptr, src::Ptr, n::Integer) -> Ptr{Cvoid} | ||
Call `memmove` from the C standard library. | ||
!!! compat "Julia 1.10" | ||
Support for `memmove` requires at least Julia 1.10. | ||
""" | ||
function memmove(dst::Ptr, src::Ptr, n::Integer) | ||
ccall(:memmove, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), dst, src, n) | ||
end | ||
|
||
""" | ||
memset(dst::Ptr, val, n::Integer) -> Ptr{Cvoid} | ||
Call `memset` from the C standard library. | ||
!!! compat "Julia 1.10" | ||
Support for `memset` requires at least Julia 1.10. | ||
""" | ||
function memset(p::Ptr, val, n::Integer) | ||
ccall(:memset, Ptr{Cvoid}, (Ptr{Cvoid}, Cint, Csize_t), p, val, n) | ||
end | ||
|
||
""" | ||
memcmp(a::Ptr, b::Ptr, n::Integer) -> Int | ||
Call `memcmp` from the C standard library. | ||
!!! compat "Julia 1.10" | ||
Support for `memcmp` requires at least Julia 1.9. | ||
""" | ||
function memcmp(a::Ptr, b::Ptr, n::Integer) | ||
ccall(:memcmp, Cint, (Ptr{Cvoid}, Ptr{Cvoid}, Csize_t), a, b, n % Csize_t) % Int | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.