@@ -97,18 +97,20 @@ render_arg(io, arg::Base.RefValue{T}) where {T} = print(io, "Ref{", T, "}")
9797
9898const HAS_CCALL_GCSAFE = VERSION >= v " 1.13.0-DEV.70"
9999
100- if HAS_CCALL_GCSAFE
101- """
102- @gcsafe_ccall ...
100+ """
101+ @gcsafe_ccall ...
103102
104- Call a foreign function just like `@ccall`, but marking it safe for the GC to run. This is
105- useful for functions that may block, so that the GC isn't blocked from running, but may also
106- be required to prevent deadlocks (see JuliaGPU/CUDA.jl#2261).
103+ Call a foreign function just like `@ccall`, but marking it safe for the GC to run. This is
104+ useful for functions that may block, so that the GC isn't blocked from running, but may also
105+ be required to prevent deadlocks (see JuliaGPU/CUDA.jl#2261).
107106
108- Note that this is generally only safe with non-Julia C functions that do not call back into
109- Julia. When using callbacks, the code should make sure to transition back into GC-unsafe
110- mode using the `@gcunsafe` macro.
111- """
107+ Note that this is generally only safe with non-Julia C functions that do not call back into
108+ Julia. When using callbacks, the code should make sure to transition back into GC-unsafe
109+ mode using the `@gcunsafe` macro.
110+ """
111+ macro gcsafe_ccall end
112+
113+ if HAS_CCALL_GCSAFE
112114 macro gcsafe_ccall (exprs)
113115 exprs = pushfirst (exprs, :(gc_safe = true ))
114116 return Base. ccall_macro_lower ((:ccall ), Base. ccall_macro_parse (exprs)... )
@@ -154,17 +156,6 @@ function ccall_macro_lower(func, rettype, types, args, nreq)
154156 end
155157end
156158
157- """
158- @gcsafe_ccall ...
159-
160- Call a foreign function just like `@ccall`, but marking it safe for the GC to run. This is
161- useful for functions that may block, so that the GC isn't blocked from running, but may also
162- be required to prevent deadlocks (see JuliaGPU/CUDA.jl#2261).
163-
164- Note that this is generally only safe with non-Julia C functions that do not call back into
165- Julia. When using callbacks, the code should make sure to transition back into GC-unsafe
166- mode using the `@gcunsafe` macro.
167- """
168159macro gcsafe_ccall (expr)
169160 return ccall_macro_lower (Base. ccall_macro_parse (expr)... )
170161end
0 commit comments