1 // SPDX-License-Identifier: Apache-2.0 2 // 3 // Copyright 2008-2016 Conrad Sanderson (http://conradsanderson.id.au) 4 // Copyright 2008-2016 National ICT Australia (NICTA) 5 // 6 // Licensed under the Apache License, Version 2.0 (the "License"); 7 // you may not use this file except in compliance with the License. 8 // You may obtain a copy of the License at 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, software 12 // distributed under the License is distributed on an "AS IS" BASIS, 13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 // See the License for the specific language governing permissions and 15 // limitations under the License. 16 // ------------------------------------------------------------------------ 17 18 19 #if defined(ARMA_USE_HDF5) 20 21 #if !defined(ARMA_USE_HDF5_ALT) 22 23 // macros needed if the wrapper run-time library is not being used 24 25 #define arma_H5Tcopy H5Tcopy 26 #define arma_H5Tcreate H5Tcreate 27 #define arma_H5Tinsert H5Tinsert 28 #define arma_H5Tequal H5Tequal 29 #define arma_H5Tclose H5Tclose 30 31 #define arma_H5Dopen H5Dopen 32 #define arma_H5Dget_type H5Dget_type 33 #define arma_H5Dclose H5Dclose 34 #define arma_H5Dwrite H5Dwrite 35 #define arma_H5Dget_space H5Dget_space 36 #define arma_H5Dread H5Dread 37 #define arma_H5Dcreate H5Dcreate 38 39 #define arma_H5Sget_simple_extent_ndims H5Sget_simple_extent_ndims 40 #define arma_H5Sget_simple_extent_dims H5Sget_simple_extent_dims 41 #define arma_H5Sclose H5Sclose 42 #define arma_H5Screate_simple H5Screate_simple 43 44 #define arma_H5Ovisit H5Ovisit 45 46 #define arma_H5Eset_auto H5Eset_auto 47 #define arma_H5Eget_auto H5Eget_auto 48 49 #define arma_H5Fopen H5Fopen 50 #define arma_H5Fcreate H5Fcreate 51 #define arma_H5Fclose H5Fclose 52 #define arma_H5Fis_hdf5 H5Fis_hdf5 53 54 #define arma_H5Gcreate H5Gcreate 55 #define arma_H5Gopen H5Gopen 56 #define arma_H5Gclose H5Gclose 57 58 #define arma_H5Lexists H5Lexists 59 #define arma_H5Ldelete H5Ldelete 60 61 #define arma_H5T_NATIVE_UCHAR H5T_NATIVE_UCHAR 62 #define arma_H5T_NATIVE_CHAR H5T_NATIVE_CHAR 63 #define arma_H5T_NATIVE_SHORT H5T_NATIVE_SHORT 64 #define arma_H5T_NATIVE_USHORT H5T_NATIVE_USHORT 65 #define arma_H5T_NATIVE_INT H5T_NATIVE_INT 66 #define arma_H5T_NATIVE_UINT H5T_NATIVE_UINT 67 #define arma_H5T_NATIVE_LONG H5T_NATIVE_LONG 68 #define arma_H5T_NATIVE_ULONG H5T_NATIVE_ULONG 69 #define arma_H5T_NATIVE_LLONG H5T_NATIVE_LLONG 70 #define arma_H5T_NATIVE_ULLONG H5T_NATIVE_ULLONG 71 #define arma_H5T_NATIVE_FLOAT H5T_NATIVE_FLOAT 72 #define arma_H5T_NATIVE_DOUBLE H5T_NATIVE_DOUBLE 73 74 #else 75 76 // prototypes for the wrapper functions defined in the wrapper run-time library (src/wrapper.cpp) 77 78 extern "C" 79 { 80 // Wrapper functions for H5* functions. 81 hid_t arma_H5Tcopy(hid_t dtype_id); 82 hid_t arma_H5Tcreate(H5T_class_t cl, size_t size); 83 herr_t arma_H5Tinsert(hid_t dtype_id, const char* name, size_t offset, hid_t field_id); 84 htri_t arma_H5Tequal(hid_t dtype_id1, hid_t dtype_id2); 85 herr_t arma_H5Tclose(hid_t dtype_id); 86 87 hid_t arma_H5Dopen(hid_t loc_id, const char* name, hid_t dapl_id); 88 hid_t arma_H5Dget_type(hid_t dataset_id); 89 herr_t arma_H5Dclose(hid_t dataset_id); 90 hid_t arma_H5Dcreate(hid_t loc_id, const char* name, hid_t dtype_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); 91 herr_t arma_H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, const void* buf); 92 hid_t arma_H5Dget_space(hid_t dataset_id); 93 herr_t arma_H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, void* buf); 94 95 int arma_H5Sget_simple_extent_ndims(hid_t space_id); 96 int arma_H5Sget_simple_extent_dims(hid_t space_id, hsize_t* dims, hsize_t* maxdims); 97 herr_t arma_H5Sclose(hid_t space_id); 98 hid_t arma_H5Screate_simple(int rank, const hsize_t* current_dims, const hsize_t* maximum_dims); 99 100 herr_t arma_H5Ovisit(hid_t object_id, H5_index_t index_type, H5_iter_order_t order, H5O_iterate_t op, void* op_data); 101 102 herr_t arma_H5Eset_auto(hid_t estack_id, H5E_auto_t func, void* client_data); 103 herr_t arma_H5Eget_auto(hid_t estack_id, H5E_auto_t* func, void** client_data); 104 105 hid_t arma_H5Fopen(const char* name, unsigned flags, hid_t fapl_id); 106 hid_t arma_H5Fcreate(const char* name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); 107 herr_t arma_H5Fclose(hid_t file_id); 108 htri_t arma_H5Fis_hdf5(const char* name); 109 110 hid_t arma_H5Gcreate(hid_t loc_id, const char* name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); 111 hid_t arma_H5Gopen(hid_t loc_id, const char* name, hid_t gapl_id); 112 herr_t arma_H5Gclose(hid_t group_id); 113 114 htri_t arma_H5Lexists(hid_t loc_id, const char* name, hid_t lapl_id); 115 herr_t arma_H5Ldelete(hid_t loc_id, const char* name, hid_t lapl_id); 116 117 // Wrapper variables that represent the hid_t values for the H5T_NATIVE_* 118 // types. Note that H5T_NATIVE_UCHAR itself is a macro that resolves to about 119 // forty other macros, and we definitely don't want to hijack those, 120 // so this is the best way to go about wrapping these... 121 extern hid_t arma_H5T_NATIVE_UCHAR; 122 extern hid_t arma_H5T_NATIVE_CHAR; 123 extern hid_t arma_H5T_NATIVE_SHORT; 124 extern hid_t arma_H5T_NATIVE_USHORT; 125 extern hid_t arma_H5T_NATIVE_INT; 126 extern hid_t arma_H5T_NATIVE_UINT; 127 extern hid_t arma_H5T_NATIVE_LONG; 128 extern hid_t arma_H5T_NATIVE_ULONG; 129 extern hid_t arma_H5T_NATIVE_LLONG; 130 extern hid_t arma_H5T_NATIVE_ULLONG; 131 extern hid_t arma_H5T_NATIVE_FLOAT; 132 extern hid_t arma_H5T_NATIVE_DOUBLE; 133 134 } 135 136 // Lastly, we have to hijack H5open() and H5check_version(), which are called 137 // by some expanded macros of the other H5* functions. This means we can't 138 // create arma_H5open(), because we can't modify those macros. Instead, we'll 139 // create arma::H5open() and arma::H5check_version(), and then issue a using 140 // directive so that arma::H5open() and arma::H5check_version() are always 141 // called. 142 // 143 // There is potential danger in the use of a using directive like this, but in 144 // this case, I can't think of a better way to solve the problem, and I doubt 145 // this will cause problems in any situations that aren't truly bizarre. And 146 // if it does cause problems, the user can #define ARMA_DONT_USE_WRAPPER or 147 // #undef ARMA_USE_WRAPPER in their Armadillo configuration. 148 herr_t H5open(); 149 herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum); 150 151 using arma::H5open; 152 using arma::H5check_version; 153 154 #endif 155 156 #endif 157