@@ -27,7 +27,7 @@ macro cholmod_name(nm,typ) string("cholmod_", eval(typ) == SuiteSparse_long ? "l
27
27
for Ti in IndexTypes
28
28
@eval begin
29
29
function common (:: Type{$Ti} )
30
- a = fill (0xff , cholmod_com_sz )
30
+ a = fill (0xff , common_size )
31
31
@isok ccall ((@cholmod_name " start" $ Ti
32
32
, :libcholmod ), Cint, (Ptr{UInt8},), a)
33
33
set_print_level (a, 0 ) # no printing from CHOLMOD by default
@@ -36,16 +36,41 @@ for Ti in IndexTypes
36
36
end
37
37
end
38
38
39
+ const version_array = Array (Cint, 3 )
40
+ if dlsym (dlopen (" libcholmod" ), :cholmod_version ) != C_NULL
41
+ ccall ((:cholmod_version , :libcholmod ), Cint, (Ptr{Cint},), version_array)
42
+ else
43
+ ccall ((:jl_cholmod_version , :libsuitesparse_wrapper ), Cint, (Ptr{Cint},), version_array)
44
+ end
45
+ const version = VersionNumber (version_array... )
46
+
39
47
# ## These offsets are defined in SuiteSparse_wrapper.c
48
+ const common_size = ccall ((:jl_cholmod_common_size ,:libsuitesparse_wrapper ),Int,())
49
+
40
50
const cholmod_com_offsets = Array (Csize_t, 19 )
41
51
ccall ((:jl_cholmod_common_offsets , :libsuitesparse_wrapper ),
42
- Void, (Ptr{Csize_t},), cholmod_com_offsets)
52
+ Void, (Ptr{Csize_t},), cholmod_com_offsets)
53
+
43
54
const common_supernodal = (1 : 4 ) + cholmod_com_offsets[4 ]
44
55
const common_final_ll = (1 : 4 ) + cholmod_com_offsets[7 ]
45
56
const common_print = (1 : 4 ) + cholmod_com_offsets[13 ]
46
57
const common_itype = (1 : 4 ) + cholmod_com_offsets[18 ]
47
58
const common_dtype = (1 : 4 ) + cholmod_com_offsets[19 ]
48
59
60
+ function __init__ ()
61
+ println (" Hej" )
62
+ if dlsym (dlopen (" libcholmod" ), :cholmod_version ) == C_NULL
63
+ throw (CHOLMODException (" your version of CHOLMOD is old. It might not work correctly with Julia. Please upgrade to a more recent version." ))
64
+ else
65
+ tmp = Array (Cint, 3 )
66
+ ccall ((:cholmod_version , :libcholmod ), Cint, (Ptr{Cint},), version_array)
67
+ ccall ((:jl_cholmod_version , :libsuitesparse_wrapper ), Cint, (Ptr{Cint},), tmp)
68
+ if tmp != version_array
69
+ throw (CHOLMODException (" your version of CHOLMOD differs from the version used when Julia was build. These versions must match." ))
70
+ end
71
+ end
72
+ end
73
+
49
74
function set_print_level (cm:: Array{UInt8} , lev:: Integer )
50
75
cm[common_print] = reinterpret (UInt8, [int32 (lev)])
51
76
end
0 commit comments