osqp_rust_sys/src32/lin_sys/direct/pardiso/
pardiso_loader.rs1extern "C" {
2 fn lh_unload_lib(libhandle: soHandle_t) -> c_int;
3 fn lh_load_lib(libname: *const ::std::os::raw::c_char) -> soHandle_t;
4 fn printf(_: *const ::std::os::raw::c_char, _: ...) -> ::std::os::raw::c_int;
5 fn lh_load_sym(h: soHandle_t, symName: *const ::std::os::raw::c_char) -> voidfun;
6}
7pub type c_int = ::std::os::raw::c_int;
8pub type c_float = ::std::os::raw::c_double;
9pub type soHandle_t = *mut ::std::os::raw::c_void;
10pub type mkl_get_mt_t = Option::<unsafe extern "C" fn() -> ::std::os::raw::c_int>;
11pub type voidfun = Option::<unsafe extern "C" fn() -> ()>;
12pub type mkl_set_ifl_t = Option::<unsafe extern "C" fn(::std::os::raw::c_int) -> ::std::os::raw::c_int>;
13pub type pardiso_t = Option::<
14 unsafe extern "C" fn(
15 *mut *mut ::std::os::raw::c_void,
16 *const c_int,
17 *const c_int,
18 *const c_int,
19 *const c_int,
20 *const c_int,
21 *const c_float,
22 *const c_int,
23 *const c_int,
24 *mut c_int,
25 *const c_int,
26 *mut c_int,
27 *const c_int,
28 *mut c_float,
29 *mut c_float,
30 *mut c_int,
31 ) -> (),
32>;
33pub const c_print: unsafe extern "C" fn(*const ::std::os::raw::c_char, ...) -> ::std::os::raw::c_int = printf;
34pub const OSQP_NULL: ::std::os::raw::c_int = 0 as ::std::os::raw::c_int;
35static mut Pardiso_handle: soHandle_t = OSQP_NULL as soHandle_t;
36static mut func_pardiso: pardiso_t = unsafe {
37 ::std::mem::transmute::<isize, pardiso_t>(OSQP_NULL as isize)
38};
39static mut func_mkl_set_interface_layer: mkl_set_ifl_t = unsafe {
40 ::std::mem::transmute::<isize, mkl_set_ifl_t>(OSQP_NULL as isize)
41};
42static mut func_mkl_get_max_threads: mkl_get_mt_t = unsafe {
43 ::std::mem::transmute::<isize, mkl_get_mt_t>(OSQP_NULL as isize)
44};
45#[no_mangle]
46pub unsafe extern "C" fn pardiso(
47 mut pt: *mut *mut ::std::os::raw::c_void,
48 mut maxfct: *const c_int,
49 mut mnum: *const c_int,
50 mut mtype: *const c_int,
51 mut phase: *const c_int,
52 mut n: *const c_int,
53 mut a: *const c_float,
54 mut ia: *const c_int,
55 mut ja: *const c_int,
56 mut perm: *mut c_int,
57 mut nrhs: *const c_int,
58 mut iparm: *mut c_int,
59 mut msglvl: *const c_int,
60 mut b: *mut c_float,
61 mut x: *mut c_float,
62 mut error: *mut c_int,
63) {
64 if func_pardiso.is_some() {
65 func_pardiso
66 .expect(
67 "non-null function pointer",
68 )(
69 pt,
70 maxfct,
71 mnum,
72 mtype,
73 phase,
74 n,
75 a,
76 ia,
77 ja,
78 perm,
79 nrhs,
80 iparm,
81 msglvl,
82 b,
83 x,
84 error,
85 );
86 } else {
87 printf(
88 b"ERROR in %s: \0" as *const u8 as *const ::std::os::raw::c_char,
89 (*::std::mem::transmute::<&[u8; 8], &[::std::os::raw::c_char; 8]>(b"pardiso\0"))
90 .as_ptr(),
91 );
92 printf(b"Pardiso not loaded correctly\0" as *const u8 as *const ::std::os::raw::c_char);
93 printf(b"\n\0" as *const u8 as *const ::std::os::raw::c_char);
94 };
95}
96#[no_mangle]
97pub unsafe extern "C" fn mkl_set_interface_layer(mut code: c_int) -> c_int {
98 return func_mkl_set_interface_layer.expect("non-null function pointer")(code);
99}
100#[no_mangle]
101pub unsafe extern "C" fn mkl_get_max_threads() -> c_int {
102 return ::std::mem::transmute::<
103 _,
104 fn() -> ::std::os::raw::c_int,
105 >(func_mkl_get_max_threads.expect("non-null function pointer"))();
106}
107#[no_mangle]
108pub unsafe extern "C" fn lh_load_pardiso(mut libname: *const ::std::os::raw::c_char) -> c_int {
109 if !libname.is_null() {
110 Pardiso_handle = lh_load_lib(libname);
111 } else {
112 Pardiso_handle = lh_load_lib(
113 b"libmkl_rt.dylib\0" as *const u8 as *const ::std::os::raw::c_char,
114 );
115 }
116 if Pardiso_handle.is_null() {
117 return 1 as ::std::os::raw::c_int;
118 }
119 func_pardiso = ::std::mem::transmute::<
120 voidfun,
121 pardiso_t,
122 >(lh_load_sym(Pardiso_handle, b"pardiso\0" as *const u8 as *const ::std::os::raw::c_char));
123 if func_pardiso.is_none() {
124 return 1 as ::std::os::raw::c_int;
125 }
126 func_mkl_set_interface_layer = ::std::mem::transmute::<
127 voidfun,
128 mkl_set_ifl_t,
129 >(
130 lh_load_sym(
131 Pardiso_handle,
132 b"MKL_Set_Interface_Layer\0" as *const u8 as *const ::std::os::raw::c_char,
133 ),
134 );
135 if func_mkl_set_interface_layer.is_none() {
136 return 1 as ::std::os::raw::c_int;
137 }
138 func_mkl_get_max_threads = ::std::mem::transmute::<
139 voidfun,
140 mkl_get_mt_t,
141 >(
142 lh_load_sym(
143 Pardiso_handle,
144 b"MKL_Get_Max_Threads\0" as *const u8 as *const ::std::os::raw::c_char,
145 ),
146 );
147 if func_mkl_get_max_threads.is_none() {
148 return 1 as ::std::os::raw::c_int;
149 }
150 return 0 as ::std::os::raw::c_int;
151}
152#[no_mangle]
153pub unsafe extern "C" fn lh_unload_pardiso() -> c_int {
154 if Pardiso_handle.is_null() {
155 return 0 as ::std::os::raw::c_int;
156 }
157 return lh_unload_lib(Pardiso_handle);
158}