forked from HDFGroup/vol-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
H5private.h
2674 lines (2463 loc) · 103 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. *
* Copyright by the Board of Trustees of the University of Illinois. *
* 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://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* [email protected]. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* Programmer: Robb Matzke <[email protected]>
* Friday, October 30, 1998
*
* 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 the pthread header */
#ifdef H5_HAVE_THREADSAFE
#ifdef H5_HAVE_WIN32_API
#ifndef H5_HAVE_WIN_THREADS
#ifdef H5_HAVE_PTHREAD_H
#include <pthread.h>
#endif /* H5_HAVE_PTHREAD_H */
#endif /* H5_HAVE_WIN_THREADS */
#else /* H5_HAVE_WIN32_API */
#ifdef H5_HAVE_PTHREAD_H
#include <pthread.h>
#endif /* H5_HAVE_PTHREAD_H */
#endif /* H5_HAVE_WIN32_API */
#endif /* H5_HAVE_THREADSAFE */
/*
* Include ANSI-C header files.
*/
#ifdef H5_STDC_HEADERS
# include <assert.h>
# include <ctype.h>
# include <errno.h>
# include <fcntl.h>
# include <float.h>
# include <limits.h>
# include <math.h>
# include <signal.h>
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
#endif
/*
* If _POSIX_VERSION is defined in unistd.h then this system is Posix.1
* compliant. Otherwise all bets are off.
*/
#ifdef H5_HAVE_UNISTD_H
# include <sys/types.h>
# include <unistd.h>
#endif
#ifdef _POSIX_VERSION
# include <sys/wait.h>
# include <pwd.h>
#endif
/*
* C9x integer types
*/
#ifndef __cplusplus
#ifdef H5_HAVE_STDINT_H
# include <stdint.h>
#endif
#endif
/*
* The `struct stat' data type for stat() and fstat(). This is a Posix file
* but often apears 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
/*
* If a program may include both `time.h' and `sys/time.h' then
* TIME_WITH_SYS_TIME is defined (see AC_HEADER_TIME in configure.ac).
* On some older systems, `sys/time.h' includes `time.h' but `time.h' is not
* protected against multiple inclusion, so programs should not explicitly
* include both files. This macro is useful in programs that use, for example,
* `struct timeval' or `struct timezone' as well as `struct tm'. It is best
* used in conjunction with `HAVE_SYS_TIME_H', whose existence is checked
* by `AC_CHECK_HEADERS(sys/time.h)' in configure.ac.
*/
#if defined(H5_TIME_WITH_SYS_TIME)
# include <sys/time.h>
# include <time.h>
#elif defined(H5_HAVE_SYS_TIME_H)
# include <sys/time.h>
#else
# include <time.h>
#endif
/*
* Longjumps are used to detect alignment constrants
*/
#ifdef H5_HAVE_SETJMP_H
# include <setjmp.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
/*
* System information. These are needed on the DEC Alpha to turn off fixing
* of unaligned accesses by the operating system during detection of
* alignment constraints in H5detect.c:main().
*/
#ifdef H5_HAVE_SYS_SYSINFO_H
# include <sys/sysinfo.h>
#endif
#ifdef H5_HAVE_SYS_PROC_H
# include <sys/proc.h>
#endif
#ifdef H5_HAVE_IO_H
# include <io.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.
*/
#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 */
#ifdef H5_HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
#ifdef H5_HAVE_THREADSAFE
#include <process.h> /* For _beginthread() */
#endif
#include <windows.h>
#include <direct.h> /* For _getcwd() */
#endif /*H5_HAVE_WIN32_API*/
/* Various ways that inline functions can be declared */
#if defined(H5_HAVE___INLINE__)
/* GNU (alternative form) */
#define H5_INLINE __inline__
#elif defined(H5_HAVE___INLINE)
/* Visual Studio */
#define H5_INLINE __inline
#elif defined(H5_HAVE_INLINE)
/* GNU, C++
* Use "inline" as a last resort on the off-chance that there will
* be C++ problems.
*/
#define H5_INLINE inline
#else
#define H5_INLINE
#endif /* inline choices */
#ifndef F_OK
# define F_OK 00
# define W_OK 02
# define R_OK 04
#endif
/*
* MPE Instrumentation support
*/
#ifdef H5_HAVE_MPE
/*------------------------------------------------------------------------
* Purpose: Begin to collect MPE log information for a function. It should
* be ahead of the actual function's process.
*
* Programmer: Long Wang
*
*------------------------------------------------------------------------
*/
#include "mpe.h"
/*
* #define eventa(func_name) h5_mpe_ ## func_name ## _a
* #define eventb(func_name) h5_mpe_ ## func_name ## _b
*/
#define eventa(func_name) h5_mpe_eventa
#define eventb(func_name) h5_mpe_eventb
#define MPE_LOG_VARS \
static int eventa(FUNC) = -1; \
static int eventb(FUNC) = -1; \
char p_event_start[128];
/* Hardwire the color to "red", since that's what all the routines are using
* now. In the future, if we want to change that color for a given routine,
* we should define a "FUNC_ENTER_API_COLOR" macro which takes an extra 'color'
* parameter and then make additional FUNC_ENTER_<foo>_COLOR macros to get that
* color information down to the BEGIN_MPE_LOG macro (which should have a new
* BEGIN_MPE_LOG_COLOR variant). -QAK
*/
#define BEGIN_MPE_LOG \
if (H5_MPEinit_g){ \
sprintf(p_event_start, "start %s", FUNC); \
if (eventa(FUNC) == -1 && eventb(FUNC) == -1) { \
const char* p_color = "red"; \
eventa(FUNC)=MPE_Log_get_event_number(); \
eventb(FUNC)=MPE_Log_get_event_number(); \
MPE_Describe_state(eventa(FUNC), eventb(FUNC), FUNC, p_color); \
} \
MPE_Log_event(eventa(FUNC), 0, p_event_start); \
}
/*------------------------------------------------------------------------
* Purpose: Finish the collection of MPE log information for a function.
* It should be after the actual function's process.
*
* Programmer: Long Wang
*/
#define FINISH_MPE_LOG \
if (H5_MPEinit_g) { \
MPE_Log_event(eventb(FUNC), 0, FUNC); \
}
#else /* H5_HAVE_MPE */
#define MPE_LOG_VARS /* void */
#define BEGIN_MPE_LOG /* void */
#define FINISH_MPE_LOG /* void */
#endif /* H5_HAVE_MPE */
/*
* dmalloc (debugging malloc) support
*/
#ifdef H5_HAVE_DMALLOC_H
#include "dmalloc.h"
#endif /* H5_HAVE_DMALLOC_H */
/*
* 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.
*
* 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.
*/
#ifdef __cplusplus
# define H5_ATTR_FORMAT(X,Y,Z) /*void*/
# define H5_ATTR_UNUSED /*void*/
# define H5_ATTR_NORETURN /*void*/
# define H5_ATTR_CONST /*void*/
# define H5_ATTR_PURE /*void*/
#else /* __cplusplus */
#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))
# define H5_ATTR_NORETURN __attribute__((noreturn))
# define H5_ATTR_CONST __attribute__((const))
# define H5_ATTR_PURE __attribute__((pure))
#else
# define H5_ATTR_FORMAT(X,Y,Z) /*void*/
# define H5_ATTR_UNUSED /*void*/
# define H5_ATTR_NORETURN /*void*/
# define H5_ATTR_CONST /*void*/
# define H5_ATTR_PURE /*void*/
#endif
#endif /* __cplusplus */
/*
* 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)
#define UFAIL (unsigned)(-1)
/* 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))
/*
* HDF Boolean type.
*/
#ifndef FALSE
#define FALSE false
#endif
#ifndef TRUE
#define TRUE true
#endif
/*
* Numeric data types. Some of these might be defined in Posix.1g, otherwise
* we define them with the closest available type which is at least as large
* as the number of bits indicated in the type name. The `int8' types *must*
* be exactly one byte wide because we use it for pointer calculations to
* void* memory.
*/
#if H5_SIZEOF_INT8_T==0
typedef signed char int8_t;
# undef H5_SIZEOF_INT8_T
# define H5_SIZEOF_INT8_T H5_SIZEOF_CHAR
#elif H5_SIZEOF_INT8_T==1
#else
# error "the int8_t type must be 1 byte wide"
#endif
#if H5_SIZEOF_UINT8_T==0
typedef unsigned char uint8_t;
# undef H5_SIZEOF_UINT8_T
# define H5_SIZEOF_UINT8_T H5_SIZEOF_CHAR
#elif H5_SIZEOF_UINT8_T==1
#else
# error "the uint8_t type must be 1 byte wide"
#endif
#if H5_SIZEOF_INT16_T>=2
#elif H5_SIZEOF_SHORT>=2
typedef short int16_t;
# undef H5_SIZEOF_INT16_T
# define H5_SIZEOF_INT16_T H5_SIZEOF_SHORT
#elif H5_SIZEOF_INT>=2
typedef int int16_t;
# undef H5_SIZEOF_INT16_T
# define H5_SIZEOF_INT16_T H5_SIZEOF_INT
#else
# error "nothing appropriate for int16_t"
#endif
#if H5_SIZEOF_UINT16_T>=2
#elif H5_SIZEOF_SHORT>=2
typedef unsigned short uint16_t;
# undef H5_SIZEOF_UINT16_T
# define H5_SIZEOF_UINT16_T H5_SIZEOF_SHORT
#elif H5_SIZEOF_INT>=2
typedef unsigned uint16_t;
# undef H5_SIZEOF_UINT16_T
# define H5_SIZEOF_UINT16_T H5_SIZEOF_INT
#else
# error "nothing appropriate for uint16_t"
#endif
#if H5_SIZEOF_INT32_T>=4
#elif H5_SIZEOF_SHORT>=4
typedef short int32_t;
# undef H5_SIZEOF_INT32_T
# define H5_SIZEOF_INT32_T H5_SIZEOF_SHORT
#elif H5_SIZEOF_INT>=4
typedef int int32_t;
# undef H5_SIZEOF_INT32_T
# define H5_SIZEOF_INT32_T H5_SIZEOF_INT
#elif H5_SIZEOF_LONG>=4
typedef long int32_t;
# undef H5_SIZEOF_INT32_T
# define H5_SIZEOF_INT32_T H5_SIZEOF_LONG
#else
# error "nothing appropriate for int32_t"
#endif
/*
* Maximum and minimum values. These should be defined in <limits.h> for the
* most part.
*/
#ifndef LLONG_MAX
# define LLONG_MAX ((long long)(((unsigned long long)1 \
<<(8*sizeof(long long)-1))-1))
# define LLONG_MIN ((long long)(-LLONG_MAX)-1)
#endif
#ifndef ULLONG_MAX
# define ULLONG_MAX ((unsigned long long)((long long)(-1)))
#endif
#ifndef SIZET_MAX
# define SIZET_MAX ((size_t)(ssize_t)(-1))
# define SSIZET_MAX ((ssize_t)(((size_t)1<<(8*sizeof(ssize_t)-1))-1))
#endif
/*
* Maximum & minimum values for our typedefs.
*/
#define HSIZET_MAX ((hsize_t)ULLONG_MAX)
#define HSSIZET_MAX ((hssize_t)LLONG_MAX)
#define HSSIZET_MIN (~(HSSIZET_MAX))
/*
* 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 SSIZET_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
/*
* A macro to portably increment enumerated types.
*/
#ifndef H5_INC_ENUM
# define H5_INC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)+1))
#endif
/* Represents an empty asynchronous request handle.
* Used in the VOL code.
*/
#define H5_REQUEST_NULL NULL
/*
* A macro to portably decrement enumerated types.
*/
#ifndef H5_DEC_ENUM
# define H5_DEC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)-1))
#endif
/* Double constant wrapper
*
* Quiets gcc warnings from -Wunsuffixed-float-constants.
*
* This is a really annoying warning since the standard specifies that
* constants of type double do NOT get a suffix so there's no way
* to specify a constant of type double. To quiet gcc, we specify floating
* point constants as type long double and cast to double.
*
* Note that this macro only needs to be used where using a double
* is important. For most code, suffixing constants with F will quiet the
* compiler and not produce erroneous code.
*/
#define H5_DOUBLE(S) ((double) S ## L)
/*
* 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 */
/*
* Data types and functions for timing certain parts of the library.
*/
typedef struct {
double utime; /*user time */
double stime; /*system time */
double etime; /*elapsed wall-clock time */
} H5_timer_t;
H5_DLL void H5_timer_reset (H5_timer_t *timer);
H5_DLL void H5_timer_begin (H5_timer_t *timer);
H5_DLL void H5_timer_end (H5_timer_t *sum/*in,out*/,
H5_timer_t *timer/*in,out*/);
H5_DLL void H5_bandwidth(char *buf/*out*/, double nbytes, double nseconds);
H5_DLL time_t H5_now(void);
/* 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;
/*
* Redefine all the POSIX functions. We should never see a POSIX
* function (or any other non-HDF5 function) in the source!
*/
/* Put all platform-specific definitions in the following file */
/* so that the following definitions are platform free. */
#include "H5win32defs.h" /* For Windows-specific definitions */
#ifndef HDabort
#define HDabort() abort()
#endif /* HDabort */
#ifndef HDabs
#define HDabs(X) abs(X)
#endif /* HDabs */
#ifndef HDaccess
#define HDaccess(F,M) access(F, M)
#endif /* HDaccess */
#ifndef HDacos
#define HDacos(X) acos(X)
#endif /* HDacos */
#ifndef HDvasprintf
#ifdef H5_HAVE_VASPRINTF
#define HDvasprintf(RET, FMT, A) vasprintf(RET, FMT, A)
#endif /* H5_HAVE_VASPRINTF */
#endif /* HDvasprintf */
#ifndef HDalarm
#ifdef H5_HAVE_ALARM
#define HDalarm(N) alarm(N)
#else /* H5_HAVE_ALARM */
#define HDalarm(N) (0)
#endif /* H5_HAVE_ALARM */
#endif /* HDalarm */
#ifndef HDasctime
#define HDasctime(T) asctime(T)
#endif /* HDasctime */
#ifndef HDasin
#define HDasin(X) asin(X)
#endif /* HDasin */
#ifndef HDasprintf
#define HDasprintf asprintf /*varargs*/
#endif /* HDasprintf */
#ifndef HDassert
#define HDassert(X) assert(X)
#endif /* HDassert */
#ifndef HDatan
#define HDatan(X) atan(X)
#endif /* HDatan */
#ifndef HDatan2
#define HDatan2(X,Y) atan2(X,Y)
#endif /* HDatan2 */
#ifndef HDatexit
#define HDatexit(F) atexit(F)
#endif /* HDatexit */
#ifndef HDatof
#define HDatof(S) atof(S)
#endif /* HDatof */
#ifndef HDatoi
#define HDatoi(S) atoi(S)
#endif /* HDatoi */
#ifndef HDatol
#define HDatol(S) atol(S)
#endif /* HDatol */
#ifndef HDatoll
#define HDatoll(S) atoll(S)
#endif /* HDatol */
#ifndef HDbsearch
#define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F)
#endif /* HDbsearch */
#ifndef HDcalloc
#define HDcalloc(N,Z) calloc(N,Z)
#endif /* HDcalloc */
#ifndef HDceil
#define HDceil(X) ceil(X)
#endif /* HDceil */
#ifndef HDcfgetispeed
#define HDcfgetispeed(T) cfgetispeed(T)
#endif /* HDcfgetispeed */
#ifndef HDcfgetospeed
#define HDcfgetospeed(T) cfgetospeed(T)
#endif /* HDcfgetospeed */
#ifndef HDcfsetispeed
#define HDcfsetispeed(T,S) cfsetispeed(T,S)
#endif /* HDcfsetispeed */
#ifndef HDcfsetospeed
#define HDcfsetospeed(T,S) cfsetospeed(T,S)
#endif /* HDcfsetospeed */
#ifndef HDchdir
#define HDchdir(S) chdir(S)
#endif /* HDchdir */
#ifndef HDchmod
#define HDchmod(S,M) chmod(S,M)
#endif /* HDchmod */
#ifndef HDchown
#define HDchown(S,O,G) chown(S,O,G)
#endif /* HDchown */
#ifndef HDclearerr
#define HDclearerr(F) clearerr(F)
#endif /* HDclearerr */
#ifndef HDclock
#define HDclock() clock()
#endif /* HDclock */
#ifndef HDclose
#define HDclose(F) close(F)
#endif /* HDclose */
#ifndef HDclosedir
#define HDclosedir(D) closedir(D)
#endif /* HDclosedir */
#ifndef HDcos
#define HDcos(X) cos(X)
#endif /* HDcos */
#ifndef HDcosh
#define HDcosh(X) cosh(X)
#endif /* HDcosh */
#ifndef HDcreat
#define HDcreat(S,M) creat(S,M)
#endif /* HDcreat */
#ifndef HDctermid
#define HDctermid(S) ctermid(S)
#endif /* HDctermid */
#ifndef HDctime
#define HDctime(T) ctime(T)
#endif /* HDctime */
#ifndef HDcuserid
#define HDcuserid(S) cuserid(S)
#endif /* HDcuserid */
#ifndef HDdifftime
#ifdef H5_HAVE_DIFFTIME
#define HDdifftime(X,Y) difftime(X,Y)
#else /* H5_HAVE_DIFFTIME */
#define HDdifftime(X,Y) ((double)(X)-(double)(Y))
#endif /* H5_HAVE_DIFFTIME */
#endif /* HDdifftime */
#ifndef HDdiv
#define HDdiv(X,Y) div(X,Y)
#endif /* HDdiv */
#ifndef HDdup
#define HDdup(F) dup(F)
#endif /* HDdup */
#ifndef HDdup2
#define HDdup2(F,I) dup2(F,I)
#endif /* HDdup2 */
/* execl() variable arguments */
/* execle() variable arguments */
/* execlp() variable arguments */
#ifndef HDexecv
#define HDexecv(S,AV) execv(S,AV)
#endif /* HDexecv */
#ifndef HDexecve
#define HDexecve(S,AV,E) execve(S,AV,E)
#endif /* HDexecve */
#ifndef HDexecvp
#define HDexecvp(S,AV) execvp(S,AV)
#endif /* HDexecvp */
#ifndef HDexit
#define HDexit(N) exit(N)
#endif /* HDexit */
#ifndef HD_exit
#define HD_exit(N) _exit(N)
#endif /* HD_exit */
#ifndef HDexp
#define HDexp(X) exp(X)
#endif /* HDexp */
#ifndef HDexp2
#define HDexp2(X) exp2(X)
#endif /* HDexp2 */
#ifndef HDfabs
#define HDfabs(X) fabs(X)
#endif /* HDfabs */
/* use ABS() because fabsf() fabsl() are not common yet. */
#ifndef HDfabsf
#define HDfabsf(X) ABS(X)
#endif /* HDfabsf */
#ifndef HDfabsl
#define HDfabsl(X) ABS(X)
#endif /* HDfabsl */
#ifndef HDfclose
#define HDfclose(F) fclose(F)
#endif /* HDfclose */
#ifdef H5_HAVE_FCNTL
#ifndef HDfcntl
#define HDfcntl(F,C,...) fcntl(F,C,__VA_ARGS__)
#endif /* HDfcntl */
#endif /* H5_HAVE_FCNTL */
#ifndef HDfdopen
#define HDfdopen(N,S) fdopen(N,S)
#endif /* HDfdopen */
#ifndef HDfeof
#define HDfeof(F) feof(F)
#endif /* HDfeof */
#ifndef HDferror
#define HDferror(F) ferror(F)
#endif /* HDferror */
#ifndef HDfflush
#define HDfflush(F) fflush(F)
#endif /* HDfflush */
#ifndef HDfgetc
#define HDfgetc(F) fgetc(F)
#endif /* HDfgetc */
#ifndef HDfgetpos
#define HDfgetpos(F,P) fgetpos(F,P)
#endif /* HDfgetpos */
#ifndef HDfgets
#define HDfgets(S,N,F) fgets(S,N,F)
#endif /* HDfgets */
#ifndef HDfileno
#define HDfileno(F) fileno(F)
#endif /* HDfileno */
/* 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_HAVE_FCNTL */
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 fails 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 /* H5_HAVE_FLOCK */
#endif /* HDflock */
#ifndef HDfloor
#define HDfloor(X) floor(X)
#endif /* HDfloor */
#ifndef HDfmod
#define HDfmod(X,Y) fmod(X,Y)
#endif /* HDfmod */
#ifndef HDfopen
#define HDfopen(S,M) fopen(S,M)
#endif /* HDfopen */
#ifndef HDfork
#define HDfork() fork()
#endif /* HDfork */
#ifndef HDfprintf
#define HDfprintf fprintf
#endif
#ifndef HDfpathconf
#define HDfpathconf(F,N) fpathconf(F,N)
#endif /* HDfpathconf */
#ifndef HDfputc
#define HDfputc(C,F) fputc(C,F)
#endif /* HDfputc */
#ifndef HDfputs
#define HDfputs(S,F) fputs(S,F)
#endif /* HDfputs */
#ifndef HDfread
#define HDfread(M,Z,N,F) fread(M,Z,N,F)
#endif /* HDfread */
#ifndef HDfree
#define HDfree(M) free(M)
#endif /* HDfree */
#ifndef HDfreopen
#define HDfreopen(S,M,F) freopen(S,M,F)
#endif /* HDfreopen */
#ifndef HDfrexp
#define HDfrexp(X,N) frexp(X,N)
#endif /* HDfrexp */
/* Check for Cray-specific 'frexpf()' and 'frexpl()' routines */
#ifndef HDfrexpf
#ifdef H5_HAVE_FREXPF
#define HDfrexpf(X,N) frexpf(X,N)
#else /* H5_HAVE_FREXPF */
#define HDfrexpf(X,N) frexp(X,N)
#endif /* H5_HAVE_FREXPF */
#endif /* HDfrexpf */
#ifndef HDfrexpl
#ifdef H5_HAVE_FREXPL
#define HDfrexpl(X,N) frexpl(X,N)
#else /* H5_HAVE_FREXPL */
#define HDfrexpl(X,N) frexp(X,N)
#endif /* H5_HAVE_FREXPL */
#endif /* HDfrexpl */
/* fscanf() variable arguments */
#ifndef HDfseek
#define HDfseek(F,O,W) fseeko(F,O,W)
#endif /* HDfseek */
#ifndef HDfsetpos
#define HDfsetpos(F,P) fsetpos(F,P)
#endif /* HDfsetpos */
#ifndef HDfstat
#define HDfstat(F,B) fstat(F,B)
#endif /* HDfstat */
#ifndef HDlstat
#define HDlstat(S,B) lstat(S,B)
#endif /* HDlstat */
#ifndef HDstat
#define HDstat(S,B) stat(S,B)
#endif /* HDstat */
#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 /* H5_HAVE_WIN32_API */
#define H5_SIZEOF_H5_STAT_SIZE_T H5_SIZEOF_OFF_T
#ifndef HDftell
#define HDftell(F) ftello(F)
#endif /* HDftell */
#ifndef HDftruncate
#define HDftruncate(F,L) ftruncate(F,L)
#endif /* HDftruncate */
#ifndef HDfwrite
#define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F)
#endif /* HDfwrite */
#ifndef HDgetc
#define HDgetc(F) getc(F)
#endif /* HDgetc */
#ifndef HDgetchar
#define HDgetchar() getchar()
#endif /* HDgetchar */
#ifndef HDgetcwd
#define HDgetcwd(S,Z) getcwd(S,Z)
#endif /* HDgetcwd */
#ifndef HDgetdcwd
#define HDgetdcwd(D,S,Z) getcwd(S,Z)
#endif /* HDgetdcwd */
#ifndef HDgetdrive
#define HDgetdrive() 0
#endif /* HDgetdrive */
#ifndef HDgetegid
#define HDgetegid() getegid()
#endif /* HDgetegid() */
#ifndef HDgetenv
#define HDgetenv(S) getenv(S)
#endif /* HDgetenv */
#ifndef HDgeteuid
#define HDgeteuid() geteuid()
#endif /* HDgeteuid */
#ifndef HDgetgid
#define HDgetgid() getgid()
#endif /* HDgetgid */
#ifndef HDgetgrgid
#define HDgetgrgid(G) getgrgid(G)
#endif /* HDgetgrgid */
#ifndef HDgetgrnam
#define HDgetgrnam(S) getgrnam(S)
#endif /* HDgetgrnam */
#ifndef HDgetgroups
#define HDgetgroups(Z,G) getgroups(Z,G)
#endif /* HDgetgroups */
#ifndef HDgethostname
#define HDgethostname(N,L) gethostname(N,L)
#endif /* HDgetlogin */
#ifndef HDgetlogin
#define HDgetlogin() getlogin()
#endif /* HDgetlogin */
#ifndef HDgetpgrp
#define HDgetpgrp() getpgrp()
#endif /* HDgetpgrp */
#ifndef HDgetpid
#define HDgetpid() getpid()
#endif /* HDgetpid */
#ifndef HDgetppid
#define HDgetppid() getppid()
#endif /* HDgetppid */
#ifndef HDgetpwnam
#define HDgetpwnam(S) getpwnam(S)
#endif /* HDgetpwnam */
#ifndef HDgetpwuid
#define HDgetpwuid(U) getpwuid(U)
#endif /* HDgetpwuid */
#ifndef HDgetrusage
#define HDgetrusage(X,S) getrusage(X,S)
#endif /* HDgetrusage */
#ifndef HDgets
#define HDgets(S) gets(S)
#endif /* HDgets */
#ifndef HDgettimeofday
#define HDgettimeofday(S,P) gettimeofday(S,P)
#endif /* HDgettimeofday */
#ifndef HDgetuid