Remove unneeded cglobal in cglobal(dlsym(...))#1230
Conversation
This does not seem to work... |
|
Do we need a macro here instead? |
The `cglobal(::Ptr, ::T)` pattern here is really just a fancy way to
cast to `Ptr{T}` and it is likely to be deprecated soon, so best to
avoid using `cglobal` for this.
dlsym in cglobal(dlsym(...))cglobal in cglobal(dlsym(...))
|
Ah right this is a dynamic usage, sorry about that. The error is a bit obtuse, but it means that the argument is not known statically. The new form with |
|
Kind of. We actually use all of these statically... Lines 385 to 401 in 66ee074 |
|
Would there be any advantage or disadvantage to doing: julia> macro hdf5_global(ex)
quote
unsafe_load(Ptr{UInt64}(cglobal(($ex, HDF5_jll.libhdf5_path))))
end
end
@hdf5_global (macro with 1 method)
julia> @hdf5_global :H5T_STD_I16BE_g
0x030000000000004e |
|
Yes, that will opt in to Julia's built-in caching, rather than calling The macro would be a performance improvement over the status quo, in that case |
|
At the moment, we assign everything to a top-level const, so I guess this results in another layer of caching that gets stored in the precompile cache and may be a bit fragile. const H5P_DATASET_ACCESS = _read_const(:H5P_CLS_DATASET_ACCESS_ID_g) If someone switched out the HDF5 library in such a way that does not HDF5.jl to recompile, these constants might be invalid. I will merge this for now and consider refactoring later. |
The
cglobalis not needed here.We'd like to consider deprecating / removing this
cglobal(::Ptr)support in Julia 1.14 (JuliaLang/julia#61707).