Skip to content

Commit c599908

Browse files
committed
save
1 parent 4cfc6e2 commit c599908

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Reexport = "0.2, 1.0"
2424
SciMLBase = "1.92"
2525
PrecompileTools = "1"
2626
Sundials_jll = "6"
27-
julia = "1.10"
27+
julia = "1.6"
2828

2929
[extras]
3030
AlgebraicMultigrid = "2169fc97-5a83-5252-b627-83903c6c433c"

gen/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ Sundials_jll = "fb77eaff-e24c-56d4-86b1-d163f2edb164"
66

77
[compat]
88
Clang = "0.17"
9+
Sundials_jll = "6.6"
10+
julia = "1.10"

gen/rewrite.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cat libsundials_api.jl | \
2+
perl -pe 's/ARKRhsFn_wrapper//g' | \
3+
perl -pe 's/CVRhsFn_wrapper//g' | \
4+
perl -pe 's/CVRootFn_wrapper//g' | \
5+
perl -pe 's/IDAResFn_wrapper//g' | \
6+
perl -pe 's/IDARootFn_wrapper//g' | \
7+
perl -pe 's/KINSysFn_wrapper//g' | \
8+
perl -pe 's/ARKRhsFn_wrapper//g' | \
9+
perl -pe 's/convert\(N_Vector, (.+)\)/$1/g' \
10+
> libsundials_api_rewrite.jl

src/Sundials.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ include("types_and_consts_additions.jl")
6161
include("handle.jl")
6262
include("nvector_wrapper.jl")
6363

64-
include("./lib/libsundials_api.jl")
64+
include("./lib/libsundials_api_rewrite.jl")
6565

6666
for ff in names(@__MODULE__; all = true)
6767
fname = string(ff)

src/lib/libsundials_api.jl

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# Modified from autogenerated code to fix memory safety:
2+
#
3+
# N_Vector https://github.com/SciML/Sundials.jl/issues/367
4+
# Global edits:
5+
# convert(N_Vector, x) -> x
6+
# some_arg::::N_Vector -> some_arg::Union{N_Vector, NVector}
7+
#
8+
# Remove automatic use of @cfunction by CVRhsFn_wrapper and similar
9+
# (this is unsafe as a C ptr is returned from the temporary @cfunction closure which may then be garbage collected)
10+
11+
112
function ARKStepCreate(fe::ARKRhsFn, fi::ARKRhsFn, t0::realtype, y0::N_Vector)
213
ccall((:ARKStepCreate, libsundials_arkode), ARKStepMemPtr, (ARKRhsFn, ARKRhsFn, realtype, N_Vector), fe, fi, t0, y0)
314
end
@@ -7871,4 +7882,3 @@ end
78717882
function SUNNonlinSolGetSysFn_Newton(NLS::SUNNonlinearSolver, SysFn)
78727883
ccall((:SUNNonlinSolGetSysFn_Newton, libsundials_sunnonlinsolnewton), Cint, (SUNNonlinearSolver, Ptr{SUNNonlinSolSysFn}), NLS, SysFn)
78737884
end
7874-

0 commit comments

Comments
 (0)