HDF5  1.12.0
H5public.h
Go to the documentation of this file.
1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * Copyright by The HDF Group. *
3  * Copyright by the Board of Trustees of the University of Illinois. *
4  * All rights reserved. *
5  * *
6  * This file is part of HDF5. The full HDF5 copyright notice, including *
7  * terms governing use, modification, and redistribution, is contained in *
8  * the COPYING file, which can be found at the root of the source code *
9  * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
10  * If you do not have access to either file, you may request a copy from *
11  * help@hdfgroup.org. *
12  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
13 
14 /*
15  * This file contains public declarations for the HDF5 module.
16  */
17 #ifndef _H5public_H
18 #define _H5public_H
19 
20 /* Include files for public use... */
21 /*
22  * Since H5pubconf.h is a generated header file, it is messy to try
23  * to put a #ifndef _H5pubconf_H ... #endif guard in it.
24  * HDF5 has set an internal rule that it is being included here.
25  * Source files should NOT include H5pubconf.h directly but include
26  * it via H5public.h. The #ifndef _H5public_H guard above would
27  * prevent repeated include.
28  */
29 #include "H5pubconf.h" /*from configure */
30 
31 /* API Version macro wrapper definitions */
32 #include "H5version.h"
33 
34 #ifdef H5_HAVE_FEATURES_H
35 #include <features.h> /*for setting POSIX, BSD, etc. compatibility */
36 #endif
37 #ifdef H5_HAVE_SYS_TYPES_H
38 #include <sys/types.h>
39 #endif
40 #ifdef H5_STDC_HEADERS
41 # include <limits.h> /*for H5T_NATIVE_CHAR defn in H5Tpublic.h */
42 # include <stdarg.h> /*for variadic functions in H5VLpublic.h */
43 #endif
44 #ifndef __cplusplus
45 # ifdef H5_HAVE_STDINT_H
46 # include <stdint.h> /*for C9x types */
47 # endif
48 #else
49 # ifdef H5_HAVE_STDINT_H_CXX
50 # include <stdint.h> /*for C9x types when include from C++ */
51 # endif
52 #endif
53 #ifdef H5_HAVE_INTTYPES_H
54 # include <inttypes.h> /* For uint64_t on some platforms */
55 #endif
56 #ifdef H5_HAVE_STDDEF_H
57 # include <stddef.h>
58 #endif
59 #ifdef H5_HAVE_PARALLEL
60 /* Don't link against MPI C++ bindings */
61 # define MPICH_SKIP_MPICXX 1
62 # define OMPI_SKIP_MPICXX 1
63 # include <mpi.h>
64 #ifndef MPI_FILE_NULL /*MPIO may be defined in mpi.h already */
65 # include <mpio.h>
66 #endif
67 #endif
68 
69 
70 /* Include the Windows API adapter header early */
71 #include "H5api_adpt.h"
72 
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76 
77 /* Macros for enabling/disabling particular GCC warnings */
78 /* (see the following web-sites for more info:
79  * http://www.dbp-consulting.com/tutorials/SuppressingGCCWarnings.html
80  * http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas
81  */
82 /* These pragmas are only implemented usefully in gcc 4.6+ */
83 #if ((__GNUC__ * 100) + __GNUC_MINOR__) >= 406
84  #define H5_GCC_DIAG_STR(s) #s
85  #define H5_GCC_DIAG_JOINSTR(x,y) H5_GCC_DIAG_STR(x ## y)
86  #define H5_GCC_DIAG_DO_PRAGMA(x) _Pragma (#x)
87  #define H5_GCC_DIAG_PRAGMA(x) H5_GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
88 
89  #define H5_GCC_DIAG_OFF(x) H5_GCC_DIAG_PRAGMA(push) H5_GCC_DIAG_PRAGMA(ignored H5_GCC_DIAG_JOINSTR(-W,x))
90  #define H5_GCC_DIAG_ON(x) H5_GCC_DIAG_PRAGMA(pop)
91 #else
92  #define H5_GCC_DIAG_OFF(x)
93  #define H5_GCC_DIAG_ON(x)
94 #endif
95 
96 /* Version numbers */
97 #define H5_VERS_MAJOR 1 /* For major interface/format changes */
98 #define H5_VERS_MINOR 12 /* For minor interface/format changes */
99 #define H5_VERS_RELEASE 0 /* For tweaks, bug-fixes, or development */
100 #define H5_VERS_SUBRELEASE "" /* For pre-releases like snap0 */
101  /* Empty string for real releases. */
102 #define H5_VERS_INFO "HDF5 library version: 1.12.0" /* Full version string */
103 
104 #define H5check() H5check_version(H5_VERS_MAJOR,H5_VERS_MINOR, \
105  H5_VERS_RELEASE)
106 
107 /* macros for comparing the version */
108 #define H5_VERSION_GE(Maj,Min,Rel) \
109  (((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR==Min) && (H5_VERS_RELEASE>=Rel)) || \
110  ((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR>Min)) || \
111  (H5_VERS_MAJOR>Maj))
112 
113 #define H5_VERSION_LE(Maj,Min,Rel) \
114  (((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR==Min) && (H5_VERS_RELEASE<=Rel)) || \
115  ((H5_VERS_MAJOR==Maj) && (H5_VERS_MINOR<Min)) || \
116  (H5_VERS_MAJOR<Maj))
117 
118 /*
119  * Status return values. Failed integer functions in HDF5 result almost
120  * always in a negative value (unsigned failing functions sometimes return
121  * zero for failure) while successful return is non-negative (often zero).
122  * The negative failure value is most commonly -1, but don't bet on it. The
123  * proper way to detect failure is something like:
124  *
125  * if((dset = H5Dopen2(file, name)) < 0)
126  * fprintf(stderr, "unable to open the requested dataset\n");
127  */
128 typedef int herr_t;
129 
130 
131 /*
132  * Boolean type. Successful return values are zero (false) or positive
133  * (true). The typical true value is 1 but don't bet on it. Boolean
134  * functions cannot fail. Functions that return `htri_t' however return zero
135  * (false), positive (true), or negative (failure). The proper way to test
136  * for truth from a htri_t function is:
137  *
138  * if ((retval = H5Tcommitted(type))>0) {
139  * printf("data type is committed\n");
140  * } else if (!retval) {
141  * printf("data type is not committed\n");
142  * } else {
143  * printf("error determining whether data type is committed\n");
144  * }
145  */
146 #ifdef H5_HAVE_STDBOOL_H
147  #include <stdbool.h>
148 #else /* H5_HAVE_STDBOOL_H */
149  #ifndef __cplusplus
150  #if defined(H5_SIZEOF_BOOL) && (H5_SIZEOF_BOOL != 0)
151  #define bool _Bool
152  #else
153  #define bool unsigned int
154  #endif
155  #define true 1
156  #define false 0
157  #endif /* __cplusplus */
158 #endif /* H5_HAVE_STDBOOL_H */
159 typedef bool hbool_t;
160 typedef int htri_t;
161 
162 /* Define the ssize_t type if it not is defined */
163 #if H5_SIZEOF_SSIZE_T==0
164 /* Undefine this size, we will re-define it in one of the sections below */
165 #undef H5_SIZEOF_SSIZE_T
166 #if H5_SIZEOF_SIZE_T==H5_SIZEOF_INT
167 typedef int ssize_t;
168 # define H5_SIZEOF_SSIZE_T H5_SIZEOF_INT
169 #elif H5_SIZEOF_SIZE_T==H5_SIZEOF_LONG
170 typedef long ssize_t;
171 # define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG
172 #elif H5_SIZEOF_SIZE_T==H5_SIZEOF_LONG_LONG
173 typedef long long ssize_t;
174 # define H5_SIZEOF_SSIZE_T H5_SIZEOF_LONG_LONG
175 #else /* Can't find matching type for ssize_t */
176 # error "nothing appropriate for ssize_t"
177 #endif
178 #endif
179 
180 /*
181  * The sizes of file objects have their own types defined here, use a 64-bit
182  * type.
183  */
184 #if H5_SIZEOF_LONG_LONG >= 8
185 H5_GCC_DIAG_OFF(long-long)
186 typedef unsigned long long hsize_t;
187 typedef signed long long hssize_t;
188 H5_GCC_DIAG_ON(long-long)
189 # define H5_SIZEOF_HSIZE_T H5_SIZEOF_LONG_LONG
190 # define H5_SIZEOF_HSSIZE_T H5_SIZEOF_LONG_LONG
191 #else
192 # error "nothing appropriate for hsize_t"
193 #endif
194 #define HSIZE_UNDEF ((hsize_t)(hssize_t)(-1))
195 
196 /*
197  * File addresses have their own types.
198  */
199 #if H5_SIZEOF_INT >= 8
200  typedef unsigned haddr_t;
201 # define HADDR_UNDEF ((haddr_t)(-1))
202 # define H5_SIZEOF_HADDR_T H5_SIZEOF_INT
203 # ifdef H5_HAVE_PARALLEL
204 # define HADDR_AS_MPI_TYPE MPI_UNSIGNED
205 # endif /* H5_HAVE_PARALLEL */
206 #elif H5_SIZEOF_LONG >= 8
207  typedef unsigned long haddr_t;
208 # define HADDR_UNDEF ((haddr_t)(long)(-1))
209 # define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG
210 # ifdef H5_HAVE_PARALLEL
211 # define HADDR_AS_MPI_TYPE MPI_UNSIGNED_LONG
212 # endif /* H5_HAVE_PARALLEL */
213 #elif H5_SIZEOF_LONG_LONG >= 8
214  typedef unsigned long long haddr_t;
215 # define HADDR_UNDEF ((haddr_t)(long long)(-1))
216 # define H5_SIZEOF_HADDR_T H5_SIZEOF_LONG_LONG
217 # ifdef H5_HAVE_PARALLEL
218 # define HADDR_AS_MPI_TYPE MPI_LONG_LONG_INT
219 # endif /* H5_HAVE_PARALLEL */
220 #else
221 # error "nothing appropriate for haddr_t"
222 #endif
223 #if H5_SIZEOF_HADDR_T == H5_SIZEOF_INT
224 # define H5_PRINTF_HADDR_FMT "%u"
225 #elif H5_SIZEOF_HADDR_T == H5_SIZEOF_LONG
226 # define H5_PRINTF_HADDR_FMT "%lu"
227 #elif H5_SIZEOF_HADDR_T == H5_SIZEOF_LONG_LONG
228 # define H5_PRINTF_HADDR_FMT "%" H5_PRINTF_LL_WIDTH "u"
229 #else
230 # error "nothing appropriate for H5_PRINTF_HADDR_FMT"
231 #endif
232 #define HADDR_MAX (HADDR_UNDEF-1)
233 
234 /* uint32_t type is used for creation order field for messages. It may be
235  * defined in Posix.1g, otherwise it is defined here.
236  */
237 #if H5_SIZEOF_UINT32_T>=4
238 #elif H5_SIZEOF_SHORT>=4
239  typedef short uint32_t;
240 # undef H5_SIZEOF_UINT32_T
241 # define H5_SIZEOF_UINT32_T H5_SIZEOF_SHORT
242 #elif H5_SIZEOF_INT>=4
243  typedef unsigned int uint32_t;
244 # undef H5_SIZEOF_UINT32_T
245 # define H5_SIZEOF_UINT32_T H5_SIZEOF_INT
246 #elif H5_SIZEOF_LONG>=4
247  typedef unsigned long uint32_t;
248 # undef H5_SIZEOF_UINT32_T
249 # define H5_SIZEOF_UINT32_T H5_SIZEOF_LONG
250 #else
251 # error "nothing appropriate for uint32_t"
252 #endif
253 
254 /* int64_t type is used for creation order field for links. It may be
255  * defined in Posix.1g, otherwise it is defined here.
256  */
257 #if H5_SIZEOF_INT64_T>=8
258 #elif H5_SIZEOF_INT>=8
259  typedef int int64_t;
260 # undef H5_SIZEOF_INT64_T
261 # define H5_SIZEOF_INT64_T H5_SIZEOF_INT
262 #elif H5_SIZEOF_LONG>=8
263  typedef long int64_t;
264 # undef H5_SIZEOF_INT64_T
265 # define H5_SIZEOF_INT64_T H5_SIZEOF_LONG
266 #elif H5_SIZEOF_LONG_LONG>=8
267  typedef long long int64_t;
268 # undef H5_SIZEOF_INT64_T
269 # define H5_SIZEOF_INT64_T H5_SIZEOF_LONG_LONG
270 #else
271 # error "nothing appropriate for int64_t"
272 #endif
273 
274 /* uint64_t type is used for fields for H5O_info_t. It may be
275  * defined in Posix.1g, otherwise it is defined here.
276  */
277 #if H5_SIZEOF_UINT64_T>=8
278 #elif H5_SIZEOF_INT>=8
279  typedef unsigned uint64_t;
280 # undef H5_SIZEOF_UINT64_T
281 # define H5_SIZEOF_UINT64_T H5_SIZEOF_INT
282 #elif H5_SIZEOF_LONG>=8
283  typedef unsigned long uint64_t;
284 # undef H5_SIZEOF_UINT64_T
285 # define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG
286 #elif H5_SIZEOF_LONG_LONG>=8
287  typedef unsigned long long uint64_t;
288 # undef H5_SIZEOF_UINT64_T
289 # define H5_SIZEOF_UINT64_T H5_SIZEOF_LONG_LONG
290 #else
291 # error "nothing appropriate for uint64_t"
292 #endif
293 
294 /* Common iteration orders */
295 typedef enum {
296  H5_ITER_UNKNOWN = -1, /* Unknown order */
297  H5_ITER_INC, /* Increasing order */
298  H5_ITER_DEC, /* Decreasing order */
299  H5_ITER_NATIVE, /* No particular order, whatever is fastest */
300  H5_ITER_N /* Number of iteration orders */
302 
303 /* Iteration callback values */
304 /* (Actually, any positive value will cause the iterator to stop and pass back
305  * that positive value to the function that called the iterator)
306  */
307 #define H5_ITER_ERROR (-1)
308 #define H5_ITER_CONT (0)
309 #define H5_ITER_STOP (1)
310 
311 /*
312  * The types of indices on links in groups/attributes on objects.
313  * Primarily used for "<do> <foo> by index" routines and for iterating over
314  * links in groups/attributes on objects.
315  */
316 typedef enum H5_index_t {
317  H5_INDEX_UNKNOWN = -1, /* Unknown index type */
318  H5_INDEX_NAME, /* Index on names */
319  H5_INDEX_CRT_ORDER, /* Index on creation order */
320  H5_INDEX_N /* Number of indices defined */
322 
323 /*
324  * Storage info struct used by H5O_info_t and H5F_info_t
325  */
326 typedef struct H5_ih_info_t {
327  hsize_t index_size; /* btree and/or list */
330 
331 /* Tokens are unique and permanent identifiers that are
332  * used to reference HDF5 objects in a container. */
333 
334 /* The maximum size allowed for tokens */
335 #define H5O_MAX_TOKEN_SIZE (16) /* Allows for 128-bit tokens */
336 
337 /* Type for object tokens */
338 /* (Hoisted here, since it's used by both the H5Lpublic.h and H5Opublic.h headers) */
339 typedef struct H5O_token_t {
342 
343 /* Functions in H5.c */
344 H5_DLL herr_t H5open(void);
345 H5_DLL herr_t H5close(void);
348 H5_DLL herr_t H5set_free_list_limits (int reg_global_lim, int reg_list_lim,
349  int arr_global_lim, int arr_list_lim, int blk_global_lim,
350  int blk_list_lim);
351 H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum,
352  unsigned *relnum);
353 H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum,
354  unsigned relnum);
356 H5_DLL herr_t H5free_memory(void *mem);
357 H5_DLL void *H5allocate_memory(size_t size, hbool_t clear);
358 H5_DLL void *H5resize_memory(void *mem, size_t size);
359 
360 #ifdef __cplusplus
361 }
362 #endif
363 #endif /* _H5public_H */
364 
365 
H5allocate_memory
H5_DLL void * H5allocate_memory(size_t size, hbool_t clear)
Definition: H5.c:917
ssize_t
int ssize_t
Definition: H5public.h:167
size
iblock size
Definition: H5EAcache.c:787
H5O_MAX_TOKEN_SIZE
#define H5O_MAX_TOKEN_SIZE
Definition: H5public.h:335
H5resize_memory
H5_DLL void * H5resize_memory(void *mem, size_t size)
Definition: H5.c:958
uint32_t
uint32_t
Definition: H5overflow.txt:38
haddr_t
CATCH haddr_t
Definition: H5EAdblock.c:162
H5O_token_t::__data
uint8_t __data[H5O_MAX_TOKEN_SIZE]
Definition: H5public.h:340
H5_ITER_NATIVE
@ H5_ITER_NATIVE
Definition: H5public.h:299
H5_INDEX_CRT_ORDER
@ H5_INDEX_CRT_ORDER
Definition: H5public.h:319
H5close
H5_DLL herr_t H5close(void)
Definition: H5.c:876
H5_ITER_DEC
@ H5_ITER_DEC
Definition: H5public.h:298
H5_GCC_DIAG_OFF
#define H5_GCC_DIAG_OFF(x)
Definition: H5public.h:92
H5_ih_info_t::heap_size
hsize_t heap_size
Definition: H5public.h:328
uint8_t
unsigned char uint8_t
Definition: H5private.h:429
H5is_library_threadsafe
H5_DLL herr_t H5is_library_threadsafe(hbool_t *is_ts)
Definition: H5.c:1007
H5_INDEX_N
@ H5_INDEX_N
Definition: H5public.h:320
H5O_token_t
struct H5O_token_t H5O_token_t
H5_ih_info_t::index_size
hsize_t index_size
Definition: H5public.h:327
int64_t
int64_t
Definition: H5overflow.txt:35
H5_INDEX_UNKNOWN
@ H5_INDEX_UNKNOWN
Definition: H5public.h:317
htri_t
int htri_t
Definition: H5public.h:160
H5_iter_order_t
H5_iter_order_t
Definition: H5public.h:295
hssize_t
hssize_t
Definition: H5overflow.txt:45
H5_ITER_N
@ H5_ITER_N
Definition: H5public.h:300
H5_ih_info_t
Definition: H5public.h:326
H5version.h
H5check_version
H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum, unsigned relnum)
Definition: H5.c:740
H5free_memory
H5_DLL herr_t H5free_memory(void *mem)
Definition: H5.c:984
H5api_adpt.h
H5dont_atexit
H5_DLL herr_t H5dont_atexit(void)
Definition: H5.c:461
H5_INDEX_NAME
@ H5_INDEX_NAME
Definition: H5public.h:318
H5set_free_list_limits
H5_DLL herr_t H5set_free_list_limits(int reg_global_lim, int reg_list_lim, int arr_global_lim, int arr_list_lim, int blk_global_lim, int blk_list_lim)
Definition: H5.c:539
H5get_libversion
H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum)
Definition: H5.c:697
uint64_t
uint64_t
Definition: H5overflow.txt:39
H5open
H5_DLL herr_t H5open(void)
Definition: H5.c:854
H5_GCC_DIAG_ON
#define H5_GCC_DIAG_ON(x)
Definition: H5public.h:93
H5garbage_collect
H5_DLL herr_t H5garbage_collect(void)
Definition: H5.c:495
H5_ITER_UNKNOWN
@ H5_ITER_UNKNOWN
Definition: H5public.h:296
H5_DLL
#define H5_DLL
Definition: H5api_adpt.h:234
herr_t
int herr_t
Definition: H5public.h:128
hbool_t
bool hbool_t
Definition: H5public.h:159
H5_ih_info_t
struct H5_ih_info_t H5_ih_info_t
hsize_t
hsize_t
Definition: H5overflow.txt:44
H5O_token_t
Definition: H5public.h:339
H5_index_t
H5_index_t
Definition: H5public.h:316
H5_ITER_INC
@ H5_ITER_INC
Definition: H5public.h:297