1#![allow(non_camel_case_types, non_snake_case, dead_code, deprecated)]
3#![allow(clippy::unreadable_literal)]
4#![allow(clippy::missing_safety_doc)]
5#![allow(clippy::cognitive_complexity)]
6#![allow(clippy::upper_case_acronyms)]
7#![allow(clippy::wildcard_imports)]
8#![allow(clippy::module_name_repetitions)]
9#![cfg_attr(docsrs, feature(doc_cfg))]
10
11#[cfg(feature = "static")]
12extern crate hdf5_src;
13#[cfg(feature = "zlib")]
14extern crate libz_sys;
15#[cfg(feature = "mpio")]
16extern crate mpi_sys;
17
18macro_rules! extern_static {
19 ($dest:ident, $src:ident) => {
20 extern "C" {
21 static $src: id_t;
22 }
23 pub static $dest: &'static id_t = unsafe { &$src };
24 };
25}
26
27#[cfg(all(feature = "mpio", not(feature = "have-parallel")))]
28compile_error!("Enabling \"mpio\" feature requires HDF5 library built with MPI support");
29
30#[cfg(all(feature = "mpio", feature = "static"))]
31compile_error!("\"mpio\" and \"static\" are incompatible features");
32
33pub mod h5;
34pub mod h5a;
35pub mod h5ac;
36pub mod h5c;
37pub mod h5d;
38pub mod h5e;
39pub mod h5f;
40pub mod h5fd;
41pub mod h5g;
42pub mod h5i;
43pub mod h5l;
44pub mod h5mm;
45pub mod h5o;
46pub mod h5p;
47pub mod h5r;
48pub mod h5s;
49pub mod h5t;
50pub mod h5vl;
51pub mod h5z;
52
53#[cfg(feature = "1.8.15")]
54pub mod h5pl;
55
56#[cfg(feature = "1.14.0")]
57pub mod h5es;
58
59#[allow(non_camel_case_types)]
60mod internal_prelude {
61 pub use crate::h5::{
62 haddr_t, hbool_t, herr_t, hsize_t, hssize_t, htri_t, H5_ih_info_t, H5_index_t,
63 H5_iter_order_t,
64 };
65 pub use crate::h5i::hid_t;
66 pub use crate::h5t::H5T_cset_t;
67 pub use libc::{int64_t, off_t, size_t, ssize_t, time_t, uint32_t, uint64_t, FILE};
68 #[allow(unused_imports)]
69 pub use std::os::raw::{
70 c_char, c_double, c_float, c_int, c_long, c_longlong, c_uchar, c_uint, c_ulong,
71 c_ulonglong, c_void,
72 };
73}
74
75use parking_lot::ReentrantMutex;
76pub static LOCK: ReentrantMutex<()> = ReentrantMutex::new(());
78
79include!(concat!(env!("OUT_DIR"), "/version.rs"));
80
81#[cfg(test)]
82mod tests {
83 use super::h5::H5get_libversion;
84 use super::h5::H5open;
85 use super::h5p::H5P_CLS_ROOT;
86 use super::{Version, HDF5_VERSION, LOCK};
87
88 #[test]
89 fn version_test() {
90 let _lock = LOCK.lock();
91 let (mut major, mut minor, mut micro) = (0, 0, 0);
92 unsafe { H5get_libversion(&mut major, &mut minor, &mut micro) };
93 let runtime_version = Version { major: major as _, minor: minor as _, micro: micro as _ };
94
95 assert_eq!(runtime_version, HDF5_VERSION);
96 }
97
98 #[test]
99 pub fn test_smoke() {
100 let _lock = LOCK.lock();
101 unsafe {
102 H5open();
103 assert!(*H5P_CLS_ROOT > 0);
104 }
105 }
106}