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