-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathH5private.h
2568 lines (2364 loc) · 101 KB
/
H5private.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://www.hdfgroup.org/licenses. *
* If you do not have access to either file, you may request a copy from *
* [email protected]. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Purpose: This file is included by all HDF5 library source files to
* define common things which are not defined in the HDF5 API.
* The configuration constants like H5_HAVE_UNISTD_H etc. are
* defined in H5config.h which is included by H5public.h.
*/
#ifndef H5private_H
#define H5private_H
#include "H5public.h" /* Include Public Definitions */
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <float.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
/* POSIX headers */
#ifdef H5_HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#ifdef H5_HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef H5_HAVE_PWD_H
#include <pwd.h>
#endif
#ifdef H5_HAVE_WAITPID
#include <sys/wait.h>
#endif
/* Include the Pthreads header, if necessary */
#if defined(H5_HAVE_THREADSAFE) && defined(H5_HAVE_PTHREAD_H)
#include <pthread.h>
#endif
/*
* The `struct stat' data type for stat() and fstat(). This is a POSIX file
* but often appears on non-POSIX systems also. The `struct stat' is required
* for HDF5 to compile, although only a few fields are actually used.
*/
#ifdef H5_HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
/*
* flock() in sys/file.h is used for the implementation of file locking.
*/
#if defined(H5_HAVE_FLOCK) && defined(H5_HAVE_SYS_FILE_H)
#include <sys/file.h>
#endif
/*
* Resource usage is not Posix.1 but HDF5 uses it anyway for some performance
* and debugging code if available.
*/
#ifdef H5_HAVE_SYS_RESOURCE_H
#include <sys/resource.h>
#endif
/*
* Unix ioctls. These are used by h5ls (and perhaps others) to determine a
* reasonable output width.
*/
#ifdef H5_HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
/*
* Dynamic library handling. These are needed for dynamically loading I/O
* filters and VFDs.
*/
#ifdef H5_HAVE_DLFCN_H
#include <dlfcn.h>
#endif
#ifdef H5_HAVE_DIRENT_H
#include <dirent.h>
#endif
/* Define the default VFD for this platform. Since the removal of the
* Windows VFD, this is sec2 for all platforms.
*
* Note well: if you change the default, then be sure to change
* H5_default_vfd_init() to call that default's initializer. Also,
* make sure that the initializer for each *non*-default VFD calls
* H5_init_library(); also, make sure that the initializer for default
* VFD does *not* call H5_init_library().
*/
#define H5_DEFAULT_VFD H5FD_SEC2
/* Define the default VOL driver */
#define H5_DEFAULT_VOL H5VL_NATIVE
#ifdef H5_HAVE_WIN32_API
/* The following two defines must be before any windows headers are included */
#define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */
#define NOGDI /* Exclude Graphic Display Interface macros */
#include <windows.h>
#include <direct.h> /* For _getcwd() */
#include <io.h> /* POSIX I/O */
#include <winsock2.h> /* For GetUserName() */
#include <shlwapi.h> /* For StrStrIA */
#ifdef H5_HAVE_THREADSAFE
#include <process.h> /* For _beginthread() */
#endif
#endif /*H5_HAVE_WIN32_API*/
#ifndef F_OK
#define F_OK 00
#define W_OK 02
#define R_OK 04
#endif
/* uthash is an external, header-only hash table implementation.
*
* We include the file directly in src/ and #define a few functions
* to use our internal memory calls.
*/
#if 0
#define uthash_malloc(sz) H5MM_malloc(sz)
#define uthash_free(ptr, sz) H5MM_free(ptr) /* Ignoring sz is intentional */
#define HASH_NONFATAL_OOM 1 /* Don't abort() on out-of-memory */
#include "uthash.h"
#endif
/*
* NT doesn't define SIGBUS, but since NT only runs on processors
* that do not have alignment constraints a SIGBUS would never be
* raised, so we just replace it with SIGILL (which also should
* never be raised by the hdf5 library).
*/
#ifndef SIGBUS
#define SIGBUS SIGILL
#endif
/*
* Does the compiler support the __attribute__(()) syntax? It's no
* big deal if we don't.
*
* Note that Solaris Studio supports attribute, but does not support the
* attributes we use.
*
* When using H5_ATTR_FALLTHROUGH, you should also include a comment that
* says FALLTHROUGH to reduce warnings on compilers that don't use
* attributes but do respect fall-through comments.
*
* H5_ATTR_CONST is redefined in tools/h5repack/dynlib_rpk.c to quiet
* gcc warnings (it has to use the public API and can't include this
* file). Be sure to update that file if the #ifdefs change here.
*/
/* clang-format off */
#if defined(H5_HAVE_ATTRIBUTE) && !defined(__SUNPRO_C)
# define H5_ATTR_FORMAT(X, Y, Z) __attribute__((format(X, Y, Z)))
# define H5_ATTR_UNUSED __attribute__((unused))
# ifdef H5_HAVE_PARALLEL
# define H5_ATTR_PARALLEL_UNUSED __attribute__((unused))
# define H5_ATTR_PARALLEL_USED /*void*/
# else
# define H5_ATTR_PARALLEL_UNUSED /*void*/
# define H5_ATTR_PARALLEL_USED __attribute__((unused))
# endif
# ifdef H5_NO_DEPRECATED_SYMBOLS
# define H5_ATTR_DEPRECATED_USED H5_ATTR_UNUSED
# else
# define H5_ATTR_DEPRECATED_USED /*void*/
# endif
# ifdef H5_DEBUG_API
# define H5_ATTR_DEBUG_API_USED /*void*/
# else
# define H5_ATTR_DEBUG_API_USED H5_ATTR_UNUSED
# endif /* H5_DEBUG_API */
# ifndef NDEBUG
# define H5_ATTR_NDEBUG_UNUSED /*void*/
# else
# define H5_ATTR_NDEBUG_UNUSED H5_ATTR_UNUSED
# endif
# define H5_ATTR_NORETURN __attribute__((noreturn))
# define H5_ATTR_CONST __attribute__((const))
# define H5_ATTR_PURE __attribute__((pure))
# if defined(__clang__) || defined(__GNUC__) && __GNUC__ >= 7 && !defined(__INTEL_COMPILER)
# define H5_ATTR_FALLTHROUGH __attribute__((fallthrough));
# else
# define H5_ATTR_FALLTHROUGH /* FALLTHROUGH */
# endif
# if defined(__GNUC__) && !defined(__INTEL_COMPILER)
# define H5_ATTR_MALLOC __attribute__((malloc))
# else
# define H5_ATTR_MALLOC /*void*/
# endif
/* Turns off optimizations for a function. Goes after the return type.
* Not generally needed in the library, but ancient versions of clang
* (7.3.3, possibly others) have trouble with some of the onion VFD decode
* functions and need the optimizer turned off. This macro can go away when
* we figure out what's going on and can engineer another solution.
*/
# if defined(__clang__)
# define H5_ATTR_NO_OPTIMIZE __attribute__((optnone))
# else
# define H5_ATTR_NO_OPTIMIZE /*void*/
# endif
#else
# define H5_ATTR_FORMAT(X, Y, Z) /*void*/
# define H5_ATTR_UNUSED /*void*/
# define H5_ATTR_NDEBUG_UNUSED /*void*/
# define H5_ATTR_DEBUG_API_USED /*void*/
# define H5_ATTR_DEPRECATED_USED /*void*/
# define H5_ATTR_PARALLEL_UNUSED /*void*/
# define H5_ATTR_PARALLEL_USED /*void*/
# define H5_ATTR_NORETURN /*void*/
# define H5_ATTR_CONST /*void*/
# define H5_ATTR_PURE /*void*/
# define H5_ATTR_FALLTHROUGH /*void*/
# define H5_ATTR_MALLOC /*void*/
# define H5_ATTR_NO_OPTIMIZE /*void*/
#endif
/* clang-format on */
/*
* Networking headers used by the mirror VFD and related tests and utilities.
*/
#ifdef H5_HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef H5_HAVE_NETDB_H
#include <netdb.h>
#endif
#ifdef H5_HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef H5_HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
/*
* Status return values for the `herr_t' type.
* Since some unix/c routines use 0 and -1 (or more precisely, non-negative
* vs. negative) as their return code, and some assumption had been made in
* the code about that, it is important to keep these constants the same
* values. When checking the success or failure of an integer-valued
* function, remember to compare against zero and not one of these two
* values.
*/
#define SUCCEED 0
#define FAIL (-1)
/* The HDF5 library uses the symbol `ERR` frequently. So do
* header files for libraries such as curses(3), terminfo(3), etc.
* Remove its definition here to avoid clashes with HDF5.
*/
#ifdef ERR
#undef ERR
#endif
/* number of members in an array */
#ifndef NELMTS
#define NELMTS(X) (sizeof(X) / sizeof(X[0]))
#endif
/* minimum of two, three, or four values */
#undef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MIN2(a, b) MIN(a, b)
#define MIN3(a, b, c) MIN(a, MIN(b, c))
#define MIN4(a, b, c, d) MIN(MIN(a, b), MIN(c, d))
/* maximum of two, three, or four values */
#undef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MAX2(a, b) MAX(a, b)
#define MAX3(a, b, c) MAX(a, MAX(b, c))
#define MAX4(a, b, c, d) MAX(MAX(a, b), MAX(c, d))
/* limit the middle value to be within a range (inclusive) */
#define RANGE(LO, X, HI) MAX(LO, MIN(X, HI))
/* absolute value */
#ifndef ABS
#define ABS(a) (((a) >= 0) ? (a) : -(a))
#endif
/* sign of argument */
#ifndef SIGN
#define SIGN(a) ((a) > 0 ? 1 : (a) < 0 ? -1 : 0)
#endif
/* test for number that is a power of 2 */
/* (from: http://graphics.stanford.edu/~seander/bithacks.html#DetermineIfPowerOf2) */
#define POWER_OF_TWO(n) (!(n & (n - 1)) && n)
/* Raise an integer to a power of 2 */
#define H5_EXP2(n) (1 << (n))
/* Check if a read of size bytes starting at ptr would overflow past
* the last valid byte, pointed to by buffer_end.
*/
#define H5_IS_BUFFER_OVERFLOW(ptr, size, buffer_end) (((ptr) + (size)-1) > (buffer_end))
/*
* HDF Boolean type.
*/
#ifndef FALSE
#define FALSE false
#endif
#ifndef TRUE
#define TRUE true
#endif
/*
* The max value for ssize_t.
*
* Only needed where ssize_t isn't a thing (e.g., Windows)
*/
#ifndef SSIZE_MAX
#define SSIZE_MAX ((ssize_t)(((size_t)1 << (8 * sizeof(ssize_t) - 1)) - 1))
#endif
/*
* Maximum & minimum values for HDF5 typedefs.
*/
#define HSIZET_MAX ((hsize_t)ULLONG_MAX)
#define HSSIZET_MAX ((hssize_t)LLONG_MAX)
#define HSSIZET_MIN (~(HSSIZET_MAX))
#ifdef H5_HAVE_PARALLEL
/* Define a type for safely sending size_t values with MPI */
#if SIZE_MAX == UCHAR_MAX
#define H5_SIZE_T_AS_MPI_TYPE MPI_UNSIGNED_CHAR
#elif SIZE_MAX == USHRT_MAX
#define H5_SIZE_T_AS_MPI_TYPE MPI_UNSIGNED_SHORT
#elif SIZE_MAX == UINT_MAX
#define H5_SIZE_T_AS_MPI_TYPE MPI_UNSIGNED
#elif SIZE_MAX == ULONG_MAX
#define H5_SIZE_T_AS_MPI_TYPE MPI_UNSIGNED_LONG
#elif SIZE_MAX == ULLONG_MAX
#define H5_SIZE_T_AS_MPI_TYPE MPI_UNSIGNED_LONG_LONG
#else
#error "no suitable MPI type for size_t"
#endif
#endif /* H5_HAVE_PARALLEL */
/*
* Types and max sizes for POSIX I/O.
* OS X (Darwin) is odd since the max I/O size does not match the types.
*/
#if defined(H5_HAVE_WIN32_API)
#define h5_posix_io_t unsigned int
#define h5_posix_io_ret_t int
#define H5_POSIX_MAX_IO_BYTES INT_MAX
#elif defined(H5_HAVE_DARWIN)
#define h5_posix_io_t size_t
#define h5_posix_io_ret_t ssize_t
#define H5_POSIX_MAX_IO_BYTES INT_MAX
#else
#define h5_posix_io_t size_t
#define h5_posix_io_ret_t ssize_t
#define H5_POSIX_MAX_IO_BYTES SSIZE_MAX
#endif
/* POSIX I/O mode used as the third parameter to open/_open
* when creating a new file (O_CREAT is set).
*/
#if defined(H5_HAVE_WIN32_API)
#define H5_POSIX_CREATE_MODE_RW (_S_IREAD | _S_IWRITE)
#else
#define H5_POSIX_CREATE_MODE_RW 0666
#endif
/* Represents an empty asynchronous request handle.
* Used in the VOL code.
*/
#define H5_REQUEST_NULL NULL
/*
* Methods to compare the equality of floating-point values:
*
* 1. H5_XXX_ABS_EQUAL - check if the difference is smaller than the
* Epsilon value. The Epsilon values, FLT_EPSILON, DBL_EPSILON,
* and LDBL_EPSILON, are defined by compiler in float.h.
*
* 2. H5_XXX_REL_EQUAL - check if the relative difference is smaller than a
* predefined value M. See if two values are relatively equal.
* It's the developer's responsibility not to pass in the value 0, which
* may cause the equation to fail.
*/
#define H5_FLT_ABS_EQUAL(X, Y) (HDfabsf((X) - (Y)) < FLT_EPSILON)
#define H5_DBL_ABS_EQUAL(X, Y) (HDfabs((X) - (Y)) < DBL_EPSILON)
#define H5_LDBL_ABS_EQUAL(X, Y) (HDfabsl((X) - (Y)) < LDBL_EPSILON)
#define H5_FLT_REL_EQUAL(X, Y, M) (HDfabsf(((Y) - (X)) / (X)) < (M))
#define H5_DBL_REL_EQUAL(X, Y, M) (HDfabs(((Y) - (X)) / (X)) < (M))
#define H5_LDBL_REL_EQUAL(X, Y, M) (HDfabsl(((Y) - (X)) / (X)) < (M))
/* KiB, MiB, GiB, TiB, PiB, EiB - Used in profiling and timing code */
#define H5_KB (1024.0F)
#define H5_MB (1024.0F * 1024.0F)
#define H5_GB (1024.0F * 1024.0F * 1024.0F)
#define H5_TB (1024.0F * 1024.0F * 1024.0F * 1024.0F)
#define H5_PB (1024.0F * 1024.0F * 1024.0F * 1024.0F * 1024.0F)
#define H5_EB (1024.0F * 1024.0F * 1024.0F * 1024.0F * 1024.0F * 1024.0F)
#ifndef H5_HAVE_FLOCK
/* flock() operations. Used in the source so we have to define them when
* the call is not available (e.g.: Windows). These should NOT be used
* with system-provided flock() calls since the values will come from the
* header file.
*/
#define LOCK_SH 0x01
#define LOCK_EX 0x02
#define LOCK_NB 0x04
#define LOCK_UN 0x08
#endif /* H5_HAVE_FLOCK */
/* Macros for enabling/disabling particular GCC / clang warnings
*
* These are duplicated in H5FDmulti.c (we don't want to put them in the
* public header and the multi VFD can't use private headers). If you make
* changes here, be sure to update those as well.
*
* (see the following web-sites for more info:
* http://www.dbp-consulting.com/tutorials/SuppressingGCCWarnings.html
* http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas
*/
#define H5_DIAG_JOINSTR(x, y) x y
#define H5_DIAG_DO_PRAGMA(x) _Pragma(#x)
#define H5_DIAG_PRAGMA(x) H5_DIAG_DO_PRAGMA(GCC diagnostic x)
#define H5_DIAG_OFF(x) H5_DIAG_PRAGMA(push) H5_DIAG_PRAGMA(ignored H5_DIAG_JOINSTR("-W", x))
#define H5_DIAG_ON(x) H5_DIAG_PRAGMA(pop)
/* Macros for enabling/disabling particular GCC-only warnings.
* These pragmas are only implemented usefully in gcc 4.6+
*/
#if (((__GNUC__ * 100) + __GNUC_MINOR__) >= 406)
#define H5_GCC_DIAG_OFF(x) H5_DIAG_OFF(x)
#define H5_GCC_DIAG_ON(x) H5_DIAG_ON(x)
#else
#define H5_GCC_DIAG_OFF(x)
#define H5_GCC_DIAG_ON(x)
#endif
/* Macros for enabling/disabling particular clang-only warnings.
*/
#if defined(__clang__)
#define H5_CLANG_DIAG_OFF(x) H5_DIAG_OFF(x)
#define H5_CLANG_DIAG_ON(x) H5_DIAG_ON(x)
#else
#define H5_CLANG_DIAG_OFF(x)
#define H5_CLANG_DIAG_ON(x)
#endif
/* Macros for enabling/disabling particular GCC / clang warnings.
* These macros should be used for warnings supported by both gcc and clang.
*/
#if (((__GNUC__ * 100) + __GNUC_MINOR__) >= 406) || defined(__clang__)
#define H5_GCC_CLANG_DIAG_OFF(x) H5_DIAG_OFF(x)
#define H5_GCC_CLANG_DIAG_ON(x) H5_DIAG_ON(x)
#else
#define H5_GCC_CLANG_DIAG_OFF(x)
#define H5_GCC_CLANG_DIAG_ON(x)
#endif
/* Function pointer typedef for qsort */
typedef int (*H5_sort_func_cb_t)(const void *, const void *);
/* Typedefs and functions for timing certain parts of the library. */
/* A set of elapsed/user/system times emitted as a time point by the
* platform-independent timers.
*/
typedef struct {
double user; /* User time in seconds */
double system; /* System time in seconds */
double elapsed; /* Elapsed (wall clock) time in seconds */
} H5_timevals_t;
/* Timer structure for platform-independent timers */
typedef struct {
H5_timevals_t initial; /* Current interval start time */
H5_timevals_t final_interval; /* Last interval elapsed time */
H5_timevals_t total; /* Total elapsed time for all intervals */
hbool_t is_running; /* Whether timer is running */
} H5_timer_t;
/* Returns library bandwidth as a pretty string */
H5_DLL void H5_bandwidth(char *buf /*out*/, size_t bufsize, double nbytes, double nseconds);
/* Timer functionality */
H5_DLL time_t H5_now(void);
H5_DLL uint64_t H5_now_usec(void);
H5_DLL herr_t H5_timer_init(H5_timer_t *timer /*in,out*/);
H5_DLL herr_t H5_timer_start(H5_timer_t *timer /*in,out*/);
H5_DLL herr_t H5_timer_stop(H5_timer_t *timer /*in,out*/);
H5_DLL herr_t H5_timer_get_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/);
H5_DLL herr_t H5_timer_get_total_times(H5_timer_t timer, H5_timevals_t *times /*in,out*/);
H5_DLL char *H5_timer_get_time_string(double seconds);
H5_DLL char *H5_strcasestr(const char *haystack, const char *needle);
/* Depth of object copy */
typedef enum {
H5_COPY_SHALLOW, /* Shallow copy from source to destination, just copy field pointers */
H5_COPY_DEEP /* Deep copy from source to destination, including duplicating fields pointed to */
} H5_copy_depth_t;
/* Common object copying udata (right now only used for groups and datasets) */
typedef struct H5O_copy_file_ud_common_t {
struct H5O_pline_t *src_pline; /* Copy of filter pipeline for object */
} H5O_copy_file_ud_common_t;
/* Unique object "position" */
typedef struct {
unsigned long fileno; /* The unique identifier for the file of the object */
haddr_t addr; /* The unique address of the object's header in that file */
} H5_obj_t;
#define H5_SIZEOF_H5_STAT_SIZE_T H5_SIZEOF_OFF_T
/* Put all Windows-specific definitions in H5win32defs.h so we
* can (mostly) assume a POSIX platform. Not all of the POSIX calls
* will have a Windows equivalent so some #ifdef protection is still
* necessary (e.g., fork()).
*/
#include "H5win32defs.h"
/* Platform-independent definitions for struct stat and off_t */
#ifndef H5_HAVE_WIN32_API
/* These definitions differ in Windows and are defined in
* H5win32defs for that platform.
*/
typedef struct stat h5_stat_t;
typedef off_t h5_stat_size_t;
#define HDoff_t off_t
#endif
/* Redefine all the POSIX and C functions. We should never see an
* undecorated POSIX or C function (or any other non-HDF5 function)
* in the source.
*/
#ifndef HDabort
#define HDabort() abort()
#endif
#ifndef HDabs
#define HDabs(X) abs(X)
#endif
#ifndef HDaccept
#define HDaccept(A, B, C) accept((A), (B), (C))
#endif
#ifndef HDaccess
#define HDaccess(F, M) access(F, M)
#endif
#ifndef HDacos
#define HDacos(X) acos(X)
#endif
#ifndef HDalarm
#define HDalarm(N) alarm(N)
#endif
#ifndef HDasctime
#define HDasctime(T) asctime(T)
#endif
#ifndef HDasin
#define HDasin(X) asin(X)
#endif
#ifndef HDasprintf
#define HDasprintf asprintf /*varargs*/
#endif
#ifndef HDassert
#define HDassert(X) assert(X)
#endif
#ifndef HDatan
#define HDatan(X) atan(X)
#endif
#ifndef HDatan2
#define HDatan2(X, Y) atan2(X, Y)
#endif
#ifndef HDatexit
#define HDatexit(F) atexit(F)
#endif
#ifndef HDatof
#define HDatof(S) atof(S)
#endif
#ifndef HDatoi
#define HDatoi(S) atoi(S)
#endif
#ifndef HDatol
#define HDatol(S) atol(S)
#endif
#ifndef HDatoll
#define HDatoll(S) atoll(S)
#endif
#ifndef HDbind
#define HDbind(A, B, C) bind((A), (B), (C))
#endif
#ifndef HDbsearch
#define HDbsearch(K, B, N, Z, F) bsearch(K, B, N, Z, F)
#endif
#ifndef HDcalloc
#define HDcalloc(N, Z) calloc(N, Z)
#endif
#ifndef HDceil
#define HDceil(X) ceil(X)
#endif
#ifndef HDcfgetispeed
#define HDcfgetispeed(T) cfgetispeed(T)
#endif
#ifndef HDcfgetospeed
#define HDcfgetospeed(T) cfgetospeed(T)
#endif
#ifndef HDcfsetispeed
#define HDcfsetispeed(T, S) cfsetispeed(T, S)
#endif
#ifndef HDcfsetospeed
#define HDcfsetospeed(T, S) cfsetospeed(T, S)
#endif
#ifndef HDchdir
#define HDchdir(S) chdir(S)
#endif
#ifndef HDchmod
#define HDchmod(S, M) chmod(S, M)
#endif
#ifndef HDchown
#define HDchown(S, O, G) chown(S, O, G)
#endif
#ifndef HDclearerr
#define HDclearerr(F) clearerr(F)
#endif
#ifndef HDclock
#define HDclock() clock()
#endif
#ifndef HDclock_gettime
#define HDclock_gettime(CID, TS) clock_gettime(CID, TS)
#endif
#ifndef HDclose
#define HDclose(F) close(F)
#endif
#ifndef HDclosedir
#define HDclosedir(D) closedir(D)
#endif
#ifndef HDconnect
#define HDconnect(A, B, C) connect((A), (B), (C))
#endif
#ifndef HDcos
#define HDcos(X) cos(X)
#endif
#ifndef HDcosh
#define HDcosh(X) cosh(X)
#endif
#ifndef HDcreat
#define HDcreat(S, M) creat(S, M)
#endif
#ifndef HDctermid
#define HDctermid(S) ctermid(S)
#endif
#ifndef HDctime
#define HDctime(T) ctime(T)
#endif
#ifndef HDcuserid
#define HDcuserid(S) cuserid(S)
#endif
#ifndef HDdifftime
#define HDdifftime(X, Y) difftime(X, Y)
#endif
#ifndef HDdiv
#define HDdiv(X, Y) div(X, Y)
#endif
#ifndef HDdup
#define HDdup(F) dup(F)
#endif
#ifndef HDdup2
#define HDdup2(F, I) dup2(F, I)
#endif
#ifndef HDexecv
#define HDexecv(S, AV) execv(S, AV)
#endif
#ifndef HDexecve
#define HDexecve(S, AV, E) execve(S, AV, E)
#endif
#ifndef HDexecvp
#define HDexecvp(S, AV) execvp(S, AV)
#endif
#ifndef HDexit
#define HDexit(N) exit(N)
#endif
#ifndef HD_exit
#define HD_exit(N) _exit(N)
#endif
#ifndef HDexp
#define HDexp(X) exp(X)
#endif
#ifndef HDexp2
#define HDexp2(X) exp2(X)
#endif
#ifndef HDfabs
#define HDfabs(X) fabs(X)
#endif
#ifndef HDfabsf
#define HDfabsf(X) fabsf(X)
#endif
#ifndef HDfabsl
#define HDfabsl(X) fabsl(X)
#endif
#ifndef HDfclose
#define HDfclose(F) fclose(F)
#endif
#ifndef HDfcntl
#define HDfcntl(F, C, ...) fcntl(F, C, __VA_ARGS__)
#endif
#ifndef HDfdopen
#define HDfdopen(N, S) fdopen(N, S)
#endif
#ifndef HDfeof
#define HDfeof(F) feof(F)
#endif
#ifndef HDferror
#define HDferror(F) ferror(F)
#endif
#ifndef HDfflush
#define HDfflush(F) fflush(F)
#endif
#ifndef HDfgetc
#define HDfgetc(F) fgetc(F)
#endif
#ifndef HDfgetpos
#define HDfgetpos(F, P) fgetpos(F, P)
#endif
#ifndef HDfgets
#define HDfgets(S, N, F) fgets(S, N, F)
#endif
#ifndef HDfileno
#define HDfileno(F) fileno(F)
#endif
/* Since flock is so prevalent, always build these functions
* when possible to avoid them becoming dead code.
*/
#ifdef H5_HAVE_FCNTL
H5_DLL int Pflock(int fd, int operation);
#endif
H5_DLL H5_ATTR_CONST int Nflock(int fd, int operation);
#ifndef HDflock
/* NOTE: flock(2) is not present on all POSIX systems.
* If it is not present, we try a flock() equivalent based on
* fcntl(2), then fall back to a function that always succeeds
* if it is not present at all (Windows uses a separate Wflock()
* function).
*/
#if defined(H5_HAVE_FLOCK)
#define HDflock(F, L) flock(F, L)
#elif defined(H5_HAVE_FCNTL)
#define HDflock(F, L) Pflock(F, L)
#else
#define HDflock(F, L) Nflock(F, L)
#endif
#endif /* HDflock */
#ifndef HDfloor
#define HDfloor(X) floor(X)
#endif
#ifndef HDfmod
#define HDfmod(X, Y) fmod(X, Y)
#endif
#ifndef HDfopen
#define HDfopen(S, M) fopen(S, M)
#endif
#ifndef HDfork
#define HDfork() fork()
#endif
#ifndef HDfprintf
#define HDfprintf fprintf
#endif
#ifndef HDfpathconf
#define HDfpathconf(F, N) fpathconf(F, N)
#endif
#ifndef HDfputc
#define HDfputc(C, F) fputc(C, F)
#endif
#ifndef HDfputs
#define HDfputs(S, F) fputs(S, F)
#endif
#ifndef HDfread
#define HDfread(M, Z, N, F) fread(M, Z, N, F)
#endif
#ifndef HDfree
#define HDfree(M) free(M)
#endif
#ifndef HDfreopen
#define HDfreopen(S, M, F) freopen(S, M, F)
#endif
#ifndef HDfrexp
#define HDfrexp(X, N) frexp(X, N)
#endif
#ifndef HDfrexpf
#define HDfrexpf(X, N) frexpf(X, N)
#endif
#ifndef HDfrexpl
#define HDfrexpl(X, N) frexpl(X, N)
#endif
#ifndef HDfscanf
#define HDfscanf fscanf
#endif
#ifndef HDfseek
#define HDfseek(F, O, W) fseeko(F, O, W)
#endif
#ifndef HDfsetpos
#define HDfsetpos(F, P) fsetpos(F, P)
#endif
#ifndef HDfstat
#define HDfstat(F, B) fstat(F, B)
#endif
#ifndef HDftell
#define HDftell(F) ftell(F)
#endif
#ifndef HDftruncate
#define HDftruncate(F, L) ftruncate(F, L)
#endif
#ifndef HDfwrite
#define HDfwrite(M, Z, N, F) fwrite(M, Z, N, F)
#endif
#ifndef HDgetc
#define HDgetc(F) getc(F)
#endif
#ifndef HDgetchar
#define HDgetchar() getchar()
#endif
#ifndef HDgetcwd
#define HDgetcwd(S, Z) getcwd(S, Z)
#endif
#ifndef HDgetdcwd
#define HDgetdcwd(D, S, Z) getcwd(S, Z)
#endif
/* Windows only - set to zero on other systems */
#ifndef HDgetdrive
#define HDgetdrive() 0
#endif
#ifndef HDgetegid
#define HDgetegid() getegid()
#endif
#ifndef HDgetenv
#define HDgetenv(S) getenv(S)
#endif
#ifndef HDgeteuid
#define HDgeteuid() geteuid()
#endif
#ifndef HDgetgid
#define HDgetgid() getgid()
#endif
#ifndef HDgetgrgid
#define HDgetgrgid(G) getgrgid(G)
#endif
#ifndef HDgetgrnam
#define HDgetgrnam(S) getgrnam(S)
#endif
#ifndef HDgetgroups
#define HDgetgroups(Z, G) getgroups(Z, G)
#endif
#ifndef HDgethostbyaddr
#define HDgethostbyaddr(A, B, C) gethostbyaddr((A), (B), (C))
#endif
#ifndef HDgethostname
#define HDgethostname(N, L) gethostname(N, L)
#endif
#ifndef HDgetpgrp
#define HDgetpgrp() getpgrp()
#endif
#ifndef HDgetpid
#define HDgetpid() getpid()
#endif
#ifndef HDgetppid
#define HDgetppid() getppid()
#endif
#ifndef HDgetpwnam
#define HDgetpwnam(S) getpwnam(S)
#endif
#ifndef HDgetpwuid
#define HDgetpwuid(U) getpwuid(U)
#endif
#ifndef HDgetrusage
#define HDgetrusage(X, S) getrusage(X, S)
#endif
/* Don't define HDgets - gets() was deprecated in C99 and removed in C11 */
#ifdef HDgets
#undef HDgets
#endif
#ifndef HDgettimeofday
#define HDgettimeofday(S, P) gettimeofday(S, P)
#endif
#ifndef HDgetuid
#define HDgetuid() getuid()
#endif
#ifndef HDgmtime
#define HDgmtime(T) gmtime(T)
#endif
#ifndef HDhtonl
#define HDhtonl(X) htonl((X))
#endif
#ifndef HDhtons
#define HDhtons(X) htons((X))
#endif
#ifndef HDinet_addr
#define HDinet_addr(C) inet_addr((C))
#endif
#ifndef HDinet_ntoa
#define HDinet_ntoa(C) inet_ntoa((C))
#endif
#ifndef HDisalnum
#define HDisalnum(C) isalnum((int)(C)) /* Cast for Solaris warning */
#endif
#ifndef HDisalpha
#define HDisalpha(C) isalpha((int)(C)) /* Cast for Solaris warning */
#endif
#ifndef HDisatty
#define HDisatty(F) isatty(F)
#endif
#ifndef HDiscntrl
#define HDiscntrl(C) iscntrl((int)(C)) /* Cast for solaris warning */
#endif
#ifndef HDisdigit
#define HDisdigit(C) isdigit((int)(C)) /* Cast for Solaris warning */
#endif
#ifndef HDisgraph
#define HDisgraph(C) isgraph((int)(C)) /* Cast for Solaris warning*/
#endif
#ifndef HDislower
#define HDislower(C) islower((int)(C)) /* Cast for Solaris warning */
#endif
#ifndef HDisnan
#define HDisnan(X) isnan(X)
#endif
#ifndef HDisprint
#define HDisprint(C) isprint((int)(C)) /* Cast for Solaris warning */
#endif
#ifndef HDispunct
#define HDispunct(C) ispunct((int)(C)) /* Cast for Solaris warning */
#endif
#ifndef HDisspace
#define HDisspace(C) isspace((int)(C)) /* Cast for Solaris warning */
#endif
#ifndef HDisupper
#define HDisupper(C) isupper((int)(C)) /* Cast for Solaris warning */
#endif
#ifndef HDisxdigit
#define HDisxdigit(C) isxdigit((int)(C)) /* Cast for Solaris warning */
#endif
#ifndef HDkill
#define HDkill(P, S) kill(P, S)
#endif
#ifndef HDlabs
#define HDlabs(X) labs(X)
#endif
#ifndef HDldexp
#define HDldexp(X, N) ldexp(X, N)
#endif
#ifndef HDldiv
#define HDldiv(X, Y) ldiv(X, Y)
#endif
#ifndef HDlink
#define HDlink(OLD, NEW) link(OLD, NEW)
#endif
#ifndef HDlisten