Skip to content

Commit 9733b98

Browse files
committed
Add AMDGPU comments
1 parent 3ca28b1 commit 9733b98

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/ccalls.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ render_arg(io, arg::Base.RefValue{T}) where {T} = print(io, "Ref{", T, "}")
9090

9191
# TODO: replace with JuliaLang/julia#49933 once merged
9292

93+
# note that this is generally only safe with functions that do not call back into Julia.
94+
# when callbacks occur, the code should ensure the GC is not running by wrapping the code
95+
# in the `@gcunsafe` macro
96+
9397
function ccall_macro_lower(func, rettype, types, args, nreq)
9498
# instead of re-using ccall or Expr(:foreigncall) to perform argument conversion,
9599
# we need to do so ourselves in order to insert a jl_gc_safe_enter|leave
@@ -136,6 +140,10 @@ end
136140
Call a foreign function just like `@ccall`, but marking it safe for the GC to run. This is
137141
useful for functions that may block, so that the GC isn't blocked from running, but may also
138142
be required to prevent deadlocks (see JuliaGPU/CUDA.jl#2261).
143+
144+
Note that this is generally only safe with non-Julia C functions that do not call back into
145+
Julia. When using callbacks, the code should make sure to transition back into GC-unsafe
146+
mode using the `@gcunsafe` macro.
139147
"""
140148
macro gcsafe_ccall(expr)
141149
return ccall_macro_lower(Base.ccall_macro_parse(expr)...)

0 commit comments

Comments
 (0)