@@ -23,6 +23,27 @@ GAP_jll.is_available() ||
2323 error (""" This platform or julia version is currently not supported by GAP:
2424 $(Base. BinaryPlatforms. host_triplet ()) """ )
2525
26+ # Julia >= 1.10 will at some point add support for (de)serializing foreign
27+ # types (the types, not the instances, at least not yet). We want (and need)
28+ # to use that if available, which also requires changes in GAP resp. GAP_jll.
29+ # To determine whether to use it, we therefore check two conditions:
30+ # (1) whether the Julia kernel exports `jl_reinit_foreign_type`, and
31+ # (2) whether or not GAP_jll defines GapObj.
32+ # See https://github.com/JuliaLang/julia/pull/44527
33+ # and https://github.com/JuliaLang/julia/pull/47407
34+ function use_jl_reinit_foreign_type ()
35+ if isdefined (GAP_jll, :GapObj )
36+ # GAP_jll still provides GapObj => use the old system
37+ return false
38+ end
39+ # otherwise try to use the new system
40+ try
41+ cglobal (:jl_reinit_foreign_type ) != C_NULL
42+ catch
43+ false
44+ end
45+ end
46+
2647include (" setup.jl" )
2748
2849import Base: length, finalize
@@ -75,6 +96,10 @@ const real_JuliaInterface_path = Ref{String}()
7596JuliaInterface_path () = real_JuliaInterface_path[]
7697
7798function initialize (argv:: Vector{String} )
99+ if use_jl_reinit_foreign_type ()
100+ ccall ((:GAP_InitJuliaMemoryInterface , libgap), Nothing, (Any, Ptr{Nothing}), @__MODULE__ , C_NULL )
101+ end
102+
78103 handle_signals = isdefined (Main, :__GAP_ARGS__ ) # a bit of a hack...
79104 error_handler_func = handle_signals ? C_NULL : @cfunction (error_handlerwrap, Cvoid, ())
80105
@@ -112,7 +137,7 @@ function initialize(argv::Vector{String})
112137 # # At this point, the GAP module has not been completely initialized, and
113138 # # hence is not yet available under the global binding "GAP"; but
114139 # # JuliaInterface needs to access it. To make that possible, we dlopen
115- # # its kernel extension already here, and poke a point to this module
140+ # # its kernel extension already here, and poke a pointer to this module
116141 # # into the kernel extension's global variable `gap_module`
117142 @debug " storing pointer to Julia module 'GAP' into JuliaInterface"
118143 Libdl. dlopen (JuliaInterface_path ())
0 commit comments