Skip to content

Commit e79aa79

Browse files
committed
Add support for HDF5 1.12.0
1 parent 78af557 commit e79aa79

File tree

13 files changed

+493
-47
lines changed

13 files changed

+493
-47
lines changed

hdf5-sys/build.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl Version {
2525
}
2626

2727
pub fn parse(s: &str) -> Option<Self> {
28-
let re = Regex::new(r"^(1)\.(8|10)\.(\d\d?)(_\d+)?(-patch\d+)?$").ok()?;
28+
let re = Regex::new(r"^(1)\.(8|10|12)\.(\d\d?)(_\d+)?(-patch\d+)?$").ok()?;
2929
let captures = re.captures(s)?;
3030
Some(Self {
3131
major: captures.get(1).and_then(|c| c.as_str().parse::<u8>().ok())?,
@@ -35,7 +35,10 @@ impl Version {
3535
}
3636

3737
pub fn is_valid(self) -> bool {
38-
self.major == 1 && ((self.minor == 8 && self.micro >= 4) || (self.minor == 10))
38+
self.major == 1
39+
&& ((self.minor == 8 && self.micro >= 4)
40+
|| (self.minor == 10)
41+
|| (self.minor == 12 && self.micro == 0))
3942
}
4043
}
4144

@@ -592,6 +595,7 @@ impl Config {
592595
assert!(version >= Version::new(1, 8, 4), "required HDF5 version: >=1.8.4");
593596
let mut vs: Vec<_> = (5..=21).map(|v| Version::new(1, 8, v)).collect(); // 1.8.[5-21]
594597
vs.extend((0..=5).map(|v| Version::new(1, 10, v))); // 1.10.[0-5]
598+
vs.push(Version::new(1, 12, 0)); // 1.12.0
595599
for v in vs.into_iter().filter(|&v| version >= v) {
596600
println!("cargo:rustc-cfg=hdf5_{}_{}_{}", v.major, v.minor, v.micro);
597601
println!("cargo:version_{}_{}_{}=1", v.major, v.minor, v.micro);

hdf5-sys/src/h5f.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,22 @@ extern "C" {
139139
)]
140140
pub fn H5Fset_latest_format(file_id: hid_t, latest_format: hbool_t) -> herr_t;
141141
pub fn H5Fis_hdf5(filename: *const c_char) -> htri_t;
142+
#[cfg(hdf5_1_12_0)]
143+
pub fn H5Fis_accessible(container_name: *const c_char, fapl_id: hid_t) -> htri_t;
142144
pub fn H5Fcreate(
143145
filename: *const c_char, flags: c_uint, create_plist: hid_t, access_plist: hid_t,
144146
) -> hid_t;
145147
pub fn H5Fopen(filename: *const c_char, flags: c_uint, access_plist: hid_t) -> hid_t;
146148
pub fn H5Freopen(file_id: hid_t) -> hid_t;
147149
pub fn H5Fflush(object_id: hid_t, scope: H5F_scope_t) -> herr_t;
148150
pub fn H5Fclose(file_id: hid_t) -> herr_t;
151+
#[cfg(hdf5_1_12_0)]
152+
pub fn H5Fdelete(filename: *const c_char, fapl_id: hid_t) -> herr_t;
149153
pub fn H5Fget_create_plist(file_id: hid_t) -> hid_t;
150154
pub fn H5Fget_access_plist(file_id: hid_t) -> hid_t;
151155
pub fn H5Fget_intent(file_id: hid_t, intent: *mut c_uint) -> herr_t;
156+
#[cfg(hdf5_1_12_0)]
157+
pub fn H5Fget_fileno(file_id: hid_t, fileno: *mut c_ulong) -> herr_t;
152158
pub fn H5Fget_obj_count(file_id: hid_t, types: c_uint) -> ssize_t;
153159
pub fn H5Fget_obj_ids(
154160
file_id: hid_t, types: c_uint, max_objs: size_t, obj_id_list: *mut hid_t,

hdf5-sys/src/h5i.rs

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,27 @@ pub enum H5I_type_t {
88
H5I_UNINIT = -2,
99
H5I_BADID = -1,
1010
H5I_FILE = 1,
11-
H5I_GROUP = 2,
12-
H5I_DATATYPE = 3,
13-
H5I_DATASPACE = 4,
14-
H5I_DATASET = 5,
15-
H5I_ATTR = 6,
11+
H5I_GROUP,
12+
H5I_DATATYPE,
13+
H5I_DATASPACE,
14+
H5I_DATASET,
15+
#[cfg(hdf5_1_12_0)]
16+
H5I_MAP,
17+
H5I_ATTR,
18+
#[cfg(not(hdf5_1_12_0))]
1619
#[cfg_attr(hdf5_1_10_2, deprecated(note = "deprecated in HDF5 1.10.2"))]
17-
H5I_REFERENCE = 7,
18-
H5I_VFL = 8,
19-
H5I_GENPROP_CLS = 9,
20-
H5I_GENPROP_LST = 10,
21-
H5I_ERROR_CLASS = 11,
22-
H5I_ERROR_MSG = 12,
23-
H5I_ERROR_STACK = 13,
24-
H5I_NTYPES = 14,
20+
H5I_REFERENCE,
21+
H5I_VFL,
22+
#[cfg(hdf5_1_12_0)]
23+
H5I_VOL,
24+
H5I_GENPROP_CLS,
25+
H5I_GENPROP_LST,
26+
H5I_ERROR_CLASS,
27+
H5I_ERROR_MSG,
28+
H5I_ERROR_STACK,
29+
#[cfg(hdf5_1_12_0)]
30+
H5I_SPACE_SEL_ITER,
31+
H5I_NTYPES,
2532
}
2633

2734
#[cfg(hdf5_1_10_0)]
@@ -35,6 +42,8 @@ pub const H5I_INVALID_HID: hid_t = -1;
3542
pub type H5I_free_t = Option<extern "C" fn(arg1: *mut c_void) -> herr_t>;
3643
pub type H5I_search_func_t =
3744
Option<extern "C" fn(obj: *mut c_void, id: hid_t, key: *mut c_void) -> c_int>;
45+
#[cfg(hdf5_1_12_0)]
46+
pub type H5I_iterate_func_t = Option<extern "C" fn(id: hid_t, udata: *mut c_void) -> herr_t>;
3847

3948
extern "C" {
4049
pub fn H5Iregister(type_: H5I_type_t, object: *const c_void) -> hid_t;
@@ -55,6 +64,8 @@ extern "C" {
5564
pub fn H5Idec_type_ref(type_: H5I_type_t) -> c_int;
5665
pub fn H5Iget_type_ref(type_: H5I_type_t) -> c_int;
5766
pub fn H5Isearch(type_: H5I_type_t, func: H5I_search_func_t, key: *mut c_void) -> *mut c_void;
67+
#[cfg(hdf5_1_12_0)]
68+
pub fn H5Iiterate(type_: H5I_type_t, op: H5I_iterate_func_t, op_data: *mut c_void) -> herr_t;
5869
pub fn H5Inmembers(type_: H5I_type_t, num_members: *mut hsize_t) -> herr_t;
5970
pub fn H5Itype_exists(type_: H5I_type_t) -> htri_t;
6071
pub fn H5Iis_valid(id: hid_t) -> htri_t;

hdf5-sys/src/h5l.rs

Lines changed: 122 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ use std::mem;
22

33
pub use self::H5L_type_t::*;
44

5+
#[cfg(hdf5_1_12_0)]
6+
use crate::h5o::H5O_token_t;
57
use crate::internal_prelude::*;
68

79
pub const H5L_MAX_LINK_NAME_LEN: uint32_t = !0;
@@ -25,33 +27,33 @@ pub const H5L_TYPE_UD_MIN: H5L_type_t = H5L_TYPE_EXTERNAL;
2527

2628
#[repr(C)]
2729
#[derive(Debug, Copy, Clone)]
28-
pub struct H5L_info_t {
30+
pub struct H5L_info1_t {
2931
pub type_: H5L_type_t,
3032
pub corder_valid: hbool_t,
3133
pub corder: int64_t,
3234
pub cset: H5T_cset_t,
33-
pub u: H5L_info_t__u,
35+
pub u: H5L_info1_t__u,
3436
}
3537

36-
impl Default for H5L_info_t {
38+
impl Default for H5L_info1_t {
3739
fn default() -> Self {
3840
unsafe { mem::zeroed() }
3941
}
4042
}
4143

4244
#[repr(C)]
4345
#[derive(Debug, Copy, Clone)]
44-
pub struct H5L_info_t__u {
46+
pub struct H5L_info1_t__u {
4547
value: [u64; 1usize],
4648
}
4749

48-
impl Default for H5L_info_t__u {
50+
impl Default for H5L_info1_t__u {
4951
fn default() -> Self {
5052
unsafe { mem::zeroed() }
5153
}
5254
}
5355

54-
impl H5L_info_t__u {
56+
impl H5L_info1_t__u {
5557
pub unsafe fn address(&mut self) -> *mut haddr_t {
5658
&self.value as *const [u64; 1] as *mut haddr_t
5759
}
@@ -60,6 +62,39 @@ impl H5L_info_t__u {
6062
}
6163
}
6264

65+
#[repr(C)]
66+
#[derive(Debug, Copy, Clone)]
67+
#[cfg(hdf5_1_12_0)]
68+
pub struct H5L_info2_t {
69+
pub type_: H5L_type_t,
70+
pub corder_valid: hbool_t,
71+
pub corder: int64_t,
72+
pub cset: H5T_cset_t,
73+
pub u: H5L_info1_t__u,
74+
}
75+
76+
#[cfg(hdf5_1_12_0)]
77+
impl Default for H5L_info2_t {
78+
fn default() -> Self {
79+
unsafe { mem::zeroed() }
80+
}
81+
}
82+
83+
#[repr(C)]
84+
#[derive(Copy, Clone)]
85+
#[cfg(hdf5_1_12_0)]
86+
pub union H5L_info2_t__u {
87+
token: H5O_token_t,
88+
val_size: size_t,
89+
}
90+
91+
#[cfg(hdf5_1_12_0)]
92+
impl Default for H5L_info2_t__u {
93+
fn default() -> Self {
94+
unsafe { mem::zeroed() }
95+
}
96+
}
97+
6398
pub type H5L_create_func_t = Option<
6499
extern "C" fn(
65100
link_name: *const c_char,
@@ -132,11 +167,20 @@ impl Default for H5L_class_t {
132167
}
133168
}
134169

135-
pub type H5L_iterate_t = Option<
170+
pub type H5L_iterate1_t = Option<
171+
extern "C" fn(
172+
group: hid_t,
173+
name: *const c_char,
174+
info: *const H5L_info1_t,
175+
op_data: *mut c_void,
176+
) -> herr_t,
177+
>;
178+
#[cfg(hdf5_1_12_0)]
179+
pub type H5L_iterate2_t = Option<
136180
extern "C" fn(
137181
group: hid_t,
138182
name: *const c_char,
139-
info: *const H5L_info_t,
183+
info: *const H5L_info2_t,
140184
op_data: *mut c_void,
141185
) -> herr_t,
142186
>;
@@ -182,32 +226,82 @@ extern "C" {
182226
n: hsize_t, buf: *mut c_void, size: size_t, lapl_id: hid_t,
183227
) -> herr_t;
184228
pub fn H5Lexists(loc_id: hid_t, name: *const c_char, lapl_id: hid_t) -> htri_t;
185-
pub fn H5Lget_info(
186-
loc_id: hid_t, name: *const c_char, linfo: *mut H5L_info_t, lapl_id: hid_t,
229+
#[cfg_attr(hdf5_1_12_0, deprecated(note = "deprecated in HDF5 1.12.0, use H5Lget_info2()"))]
230+
#[cfg_attr(not(hdf5_1_12_0), link_name = "H5Lget_info")]
231+
pub fn H5Lget_info1(
232+
loc_id: hid_t, name: *const c_char, linfo: *mut H5L_info1_t, lapl_id: hid_t,
233+
) -> herr_t;
234+
#[cfg(hdf5_1_12_0)]
235+
pub fn H5Lget_info2(
236+
loc_id: hid_t, name: *const c_char, linfo: *mut H5L_info2_t, lapl_id: hid_t,
187237
) -> herr_t;
238+
#[cfg_attr(
239+
hdf5_1_12_0,
240+
deprecated(note = "deprecated in HDF5 1.12.0, use H5Lget_info_by_idx2()")
241+
)]
242+
#[cfg_attr(not(hdf5_1_12_0), link_name = "H5Lget_info_by_idx")]
188243
pub fn H5Lget_info_by_idx(
189244
loc_id: hid_t, group_name: *const c_char, idx_type: H5_index_t, order: H5_iter_order_t,
190-
n: hsize_t, linfo: *mut H5L_info_t, lapl_id: hid_t,
245+
n: hsize_t, linfo: *mut H5L_info1_t, lapl_id: hid_t,
246+
) -> herr_t;
247+
#[cfg(hdf5_1_12_0)]
248+
pub fn H5Lget_info_by_idx2(
249+
loc_id: hid_t, group_name: *const c_char, idx_type: H5_index_t, order: H5_iter_order_t,
250+
n: hsize_t, linfo: *mut H5L_info2_t, lapl_id: hid_t,
191251
) -> herr_t;
192252
pub fn H5Lget_name_by_idx(
193253
loc_id: hid_t, group_name: *const c_char, idx_type: H5_index_t, order: H5_iter_order_t,
194254
n: hsize_t, name: *mut c_char, size: size_t, lapl_id: hid_t,
195255
) -> ssize_t;
196-
pub fn H5Literate(
256+
#[cfg_attr(hdf5_1_12_0, deprecated(note = "deprecated in HDF5 1.12.0, use H5Literate2()"))]
257+
#[cfg_attr(not(hdf5_1_12_0), link_name = "H5Literate")]
258+
pub fn H5Literate1(
197259
grp_id: hid_t, idx_type: H5_index_t, order: H5_iter_order_t, idx: *mut hsize_t,
198-
op: H5L_iterate_t, op_data: *mut c_void,
260+
op: H5L_iterate1_t, op_data: *mut c_void,
199261
) -> herr_t;
200-
pub fn H5Literate_by_name(
262+
#[cfg(hdf5_1_12_0)]
263+
pub fn H5Literate2(
264+
grp_id: hid_t, idx_type: H5_index_t, order: H5_iter_order_t, idx: *mut hsize_t,
265+
op: H5L_iterate2_t, op_data: *mut c_void,
266+
) -> herr_t;
267+
#[cfg_attr(
268+
hdf5_1_12_0,
269+
deprecated(note = "deprecated in HDF5 1.12.0, use H5Literate_by_name2()")
270+
)]
271+
#[cfg_attr(not(hdf5_1_12_0), link_name = "H5Literate_by_name")]
272+
pub fn H5Literate_by_name1(
201273
loc_id: hid_t, group_name: *const c_char, idx_type: H5_index_t, order: H5_iter_order_t,
202-
idx: *mut hsize_t, op: H5L_iterate_t, op_data: *mut c_void, lapl_id: hid_t,
274+
idx: *mut hsize_t, op: H5L_iterate1_t, op_data: *mut c_void, lapl_id: hid_t,
203275
) -> herr_t;
204-
pub fn H5Lvisit(
205-
grp_id: hid_t, idx_type: H5_index_t, order: H5_iter_order_t, op: H5L_iterate_t,
276+
#[cfg(hdf5_1_12_0)]
277+
pub fn H5Literate_by_name2(
278+
loc_id: hid_t, group_name: *const c_char, idx_type: H5_index_t, order: H5_iter_order_t,
279+
idx: *mut hsize_t, op: H5L_iterate2_t, op_data: *mut c_void, lapl_id: hid_t,
280+
) -> herr_t;
281+
#[cfg_attr(hdf5_1_12_0, deprecated(note = "deprecated in HDF5 1.12.0, use H5Lvisit2()"))]
282+
#[cfg_attr(not(hdf5_1_12_0), link_name = "H5Lvisit")]
283+
pub fn H5Lvisit1(
284+
grp_id: hid_t, idx_type: H5_index_t, order: H5_iter_order_t, op: H5L_iterate1_t,
206285
op_data: *mut c_void,
207286
) -> herr_t;
208-
pub fn H5Lvisit_by_name(
287+
#[cfg(hdf5_1_12_0)]
288+
pub fn H5Lvisit2(
289+
grp_id: hid_t, idx_type: H5_index_t, order: H5_iter_order_t, op: H5L_iterate2_t,
290+
op_data: *mut c_void,
291+
) -> herr_t;
292+
#[cfg_attr(
293+
hdf5_1_12_0,
294+
deprecated(note = "deprecated in HDF5 1.12.0, use H5Lvisit_by_name2()")
295+
)]
296+
#[cfg_attr(not(hdf5_1_12_0), link_name = "H5Lvisit_by_name")]
297+
pub fn H5Lvisit_by_name1(
298+
loc_id: hid_t, group_name: *const c_char, idx_type: H5_index_t, order: H5_iter_order_t,
299+
op: H5L_iterate1_t, op_data: *mut c_void, lapl_id: hid_t,
300+
) -> herr_t;
301+
#[cfg(hdf5_1_12_0)]
302+
pub fn H5Lvisit_by_name2(
209303
loc_id: hid_t, group_name: *const c_char, idx_type: H5_index_t, order: H5_iter_order_t,
210-
op: H5L_iterate_t, op_data: *mut c_void, lapl_id: hid_t,
304+
op: H5L_iterate2_t, op_data: *mut c_void, lapl_id: hid_t,
211305
) -> herr_t;
212306
pub fn H5Lcreate_ud(
213307
link_loc_id: hid_t, link_name: *const c_char, link_type: H5L_type_t, udata: *const c_void,
@@ -225,3 +319,12 @@ extern "C" {
225319
link_name: *const c_char, lcpl_id: hid_t, lapl_id: hid_t,
226320
) -> herr_t;
227321
}
322+
323+
#[cfg(not(hdf5_1_12_0))]
324+
pub use self::{
325+
H5L_info1_t as H5L_info_t, H5L_iterate1_t as H5L_iterate_t, H5Literate1 as H5Literate,
326+
};
327+
#[cfg(hdf5_1_12_0)]
328+
pub use self::{
329+
H5L_info2_t as H5L_info_t, H5L_iterate2_t as H5L_iterate_t, H5Literate2 as H5Literate,
330+
};

0 commit comments

Comments
 (0)