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://www.hdfgroup.org/licenses.               *
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 macros & information for file access
16  */
17 
18 #ifndef H5Fprivate_H
19 #define H5Fprivate_H
20 
21 /* Early typedefs to avoid circular dependencies */
22 typedef struct H5F_t H5F_t;
23 
24 /* Include package's public header */
25 #include "H5Fpublic.h"
26 
27 /* Public headers needed by this file */
28 #include "H5FDpublic.h" /* File drivers                 */
29 
30 /* Private headers needed by this file */
31 #include "H5MMprivate.h" /* Memory management            */
32 #ifdef H5_HAVE_PARALLEL
33 #include "H5Pprivate.h"  /* Property lists               */
34 #endif                   /* H5_HAVE_PARALLEL */
35 #include "H5VMprivate.h" /* Vectors and arrays           */
36 #include "H5VLprivate.h" /* Virtual Object Layer         */
37 
38 /**************************/
39 /* Library Private Macros */
40 /**************************/
41 
42 /*
43  * Encode and decode macros for file meta-data.
44  * Currently, all file meta-data is little-endian.
45  */
46 
47 #define INT16ENCODE(p, i)                                                                                    \
48     {                                                                                                        \
49         *(p) = (uint8_t)((unsigned)(i)&0xff);                                                                \
50         (p)++;                                                                                               \
51         *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff);                                                       \
52         (p)++;                                                                                               \
53     }
54 
55 #define UINT16ENCODE(p, i)                                                                                   \
56     {                                                                                                        \
57         *(p) = (uint8_t)((unsigned)(i)&0xff);                                                                \
58         (p)++;                                                                                               \
59         *(p) = (uint8_t)(((unsigned)(i) >> 8) & 0xff);                                                       \
60         (p)++;                                                                                               \
61     }
62 
63 #define INT32ENCODE(p, i)                                                                                    \
64     {                                                                                                        \
65         *(p) = (uint8_t)((uint32_t)(i)&0xff);                                                                \
66         (p)++;                                                                                               \
67         *(p) = (uint8_t)(((uint32_t)(i) >> 8) & 0xff);                                                       \
68         (p)++;                                                                                               \
69         *(p) = (uint8_t)(((uint32_t)(i) >> 16) & 0xff);                                                      \
70         (p)++;                                                                                               \
71         *(p) = (uint8_t)(((uint32_t)(i) >> 24) & 0xff);                                                      \
72         (p)++;                                                                                               \
73     }
74 
75 #define UINT32ENCODE(p, i)                                                                                   \
76     {                                                                                                        \
77         *(p) = (uint8_t)((i)&0xff);                                                                          \
78         (p)++;                                                                                               \
79         *(p) = (uint8_t)(((i) >> 8) & 0xff);                                                                 \
80         (p)++;                                                                                               \
81         *(p) = (uint8_t)(((i) >> 16) & 0xff);                                                                \
82         (p)++;                                                                                               \
83         *(p) = (uint8_t)(((i) >> 24) & 0xff);                                                                \
84         (p)++;                                                                                               \
85     }
86 
87 /* Encode an unsigned integer into a variable-sized buffer */
88 /* (Assumes that the high bits of the integer are zero) */
89 #define ENCODE_VAR(p, typ, n, l)                                                                             \
90     {                                                                                                        \
91         typ      _n = (n);                                                                                   \
92         size_t   _i;                                                                                         \
93         uint8_t *_p = (uint8_t *)(p);                                                                        \
94                                                                                                              \
95         for (_i = 0; _i < l; _i++, _n >>= 8)                                                                 \
96             *_p++ = (uint8_t)(_n & 0xff);                                                                    \
97         (p) = (uint8_t *)(p) + l;                                                                            \
98     }
99 
100 /* Encode a 32-bit unsigned integer into a variable-sized buffer */
101 /* (Assumes that the high bits of the integer are zero) */
102 #define UINT32ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint32_t, n, l)
103 
104 #define INT64ENCODE(p, n)                                                                                    \
105     {                                                                                                        \
106         int64_t  _n = (n);                                                                                   \
107         size_t   _i;                                                                                         \
108         uint8_t *_p = (uint8_t *)(p);                                                                        \
109                                                                                                              \
110         for (_i = 0; _i < sizeof(int64_t); _i++, _n >>= 8)                                                   \
111             *_p++ = (uint8_t)(_n & 0xff);                                                                    \
112         for (/*void*/; _i < 8; _i++)                                                                         \
113             *_p++ = (uint8_t)((n) < 0 ? 0xff : 0);                                                           \
114         (p) = (uint8_t *)(p) + 8;                                                                            \
115     }
116 
117 #define UINT64ENCODE(p, n)                                                                                   \
118     {                                                                                                        \
119         uint64_t _n = (n);                                                                                   \
120         size_t   _i;                                                                                         \
121         uint8_t *_p = (uint8_t *)(p);                                                                        \
122                                                                                                              \
123         for (_i = 0; _i < sizeof(uint64_t); _i++, _n >>= 8)                                                  \
124             *_p++ = (uint8_t)(_n & 0xff);                                                                    \
125         for (/*void*/; _i < 8; _i++)                                                                         \
126             *_p++ = 0;                                                                                       \
127         (p) = (uint8_t *)(p) + 8;                                                                            \
128     }
129 
130 /* Encode a 64-bit unsigned integer into a variable-sized buffer */
131 /* (Assumes that the high bits of the integer are zero) */
132 #define UINT64ENCODE_VAR(p, n, l) ENCODE_VAR(p, uint64_t, n, l)
133 
134 /* Encode a 64-bit unsigned integer and its length into a variable-sized buffer */
135 /* (Assumes that the high bits of the integer are zero) */
136 #define UINT64ENCODE_VARLEN(p, n)                                                                            \
137     {                                                                                                        \
138         uint64_t __n = (uint64_t)(n);                                                                        \
139         unsigned _s  = H5VM_limit_enc_size(__n);                                                             \
140                                                                                                              \
141         *(p)++ = (uint8_t)_s;                                                                                \
142         UINT64ENCODE_VAR(p, __n, _s);                                                                        \
143     }
144 
145 #define H5_ENCODE_UNSIGNED(p, n)                                                                             \
146     {                                                                                                        \
147         HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t));                                              \
148         UINT32ENCODE(p, n)                                                                                   \
149     }
150 
151 /* Assumes the endianness of uint64_t is the same as double */
152 #define H5_ENCODE_DOUBLE(p, n)                                                                               \
153     {                                                                                                        \
154         uint64_t _n;                                                                                         \
155         size_t   _u;                                                                                         \
156         uint8_t *_p = (uint8_t *)(p);                                                                        \
157                                                                                                              \
158         HDcompile_assert(sizeof(double) == 8);                                                               \
159         HDcompile_assert(sizeof(double) == sizeof(uint64_t));                                                \
160         H5MM_memcpy(&_n, &n, sizeof(double));                                                                \
161         for (_u = 0; _u < sizeof(uint64_t); _u++, _n >>= 8)                                                  \
162             *_p++ = (uint8_t)(_n & 0xff);                                                                    \
163         (p) = (uint8_t *)(p) + 8;                                                                            \
164     }
165 
166 /* DECODE converts little endian bytes pointed by p to integer values and store
167  * it in i.  For signed values, need to do sign-extension when converting
168  * the last byte which carries the sign bit.
169  * The macros does not require i be of a certain byte sizes.  It just requires
170  * i be big enough to hold the intended value range.  E.g. INT16DECODE works
171  * correctly even if i is actually a 64bit int like in a Cray.
172  */
173 
174 #define INT16DECODE(p, i)                                                                                    \
175     {                                                                                                        \
176         (i) = (int16_t)((*(p)&0xff));                                                                        \
177         (p)++;                                                                                               \
178         (i) |= (int16_t)(((*(p)&0xff) << 8) | ((*(p)&0x80) ? ~0xffff : 0x0));                                \
179         (p)++;                                                                                               \
180     }
181 
182 #define UINT16DECODE(p, i)                                                                                   \
183     {                                                                                                        \
184         (i) = (uint16_t)(*(p)&0xff);                                                                         \
185         (p)++;                                                                                               \
186         (i) |= (uint16_t)((*(p)&0xff) << 8);                                                                 \
187         (p)++;                                                                                               \
188     }
189 
190 #define INT32DECODE(p, i)                                                                                    \
191     {                                                                                                        \
192         (i) = ((int32_t)(*(p)&0xff));                                                                        \
193         (p)++;                                                                                               \
194         (i) |= ((int32_t)(*(p)&0xff) << 8);                                                                  \
195         (p)++;                                                                                               \
196         (i) |= ((int32_t)(*(p)&0xff) << 16);                                                                 \
197         (p)++;                                                                                               \
198         (i) |= ((int32_t)(((*(p) & (unsigned)0xff) << 24) | ((*(p)&0x80) ? ~0xffffffffULL : 0x0ULL)));       \
199         (p)++;                                                                                               \
200     }
201 
202 #define UINT32DECODE(p, i)                                                                                   \
203     {                                                                                                        \
204         (i) = (uint32_t)(*(p)&0xff);                                                                         \
205         (p)++;                                                                                               \
206         (i) |= ((uint32_t)(*(p)&0xff) << 8);                                                                 \
207         (p)++;                                                                                               \
208         (i) |= ((uint32_t)(*(p)&0xff) << 16);                                                                \
209         (p)++;                                                                                               \
210         (i) |= ((uint32_t)(*(p)&0xff) << 24);                                                                \
211         (p)++;                                                                                               \
212     }
213 
214 /* Decode a variable-sized buffer */
215 /* (Assumes that the high bits of the integer will be zero) */
216 #define DECODE_VAR(p, n, l)                                                                                  \
217     {                                                                                                        \
218         size_t _i;                                                                                           \
219                                                                                                              \
220         n = 0;                                                                                               \
221         (p) += l;                                                                                            \
222         for (_i = 0; _i < l; _i++)                                                                           \
223             n = (n << 8) | *(--p);                                                                           \
224         (p) += l;                                                                                            \
225     }
226 
227 /* Decode a variable-sized buffer into a 32-bit unsigned integer */
228 /* (Assumes that the high bits of the integer will be zero) */
229 #define UINT32DECODE_VAR(p, n, l) DECODE_VAR(p, n, l)
230 
231 #define INT64DECODE(p, n)                                                                                    \
232     {                                                                                                        \
233         /* WE DON'T CHECK FOR OVERFLOW! */                                                                   \
234         size_t _i;                                                                                           \
235                                                                                                              \
236         n = 0;                                                                                               \
237         (p) += 8;                                                                                            \
238         for (_i = 0; _i < sizeof(int64_t); _i++)                                                             \
239             n = (n << 8) | *(--p);                                                                           \
240         (p) += 8;                                                                                            \
241     }
242 
243 #define UINT64DECODE(p, n)                                                                                   \
244     {                                                                                                        \
245         /* WE DON'T CHECK FOR OVERFLOW! */                                                                   \
246         size_t _i;                                                                                           \
247                                                                                                              \
248         n = 0;                                                                                               \
249         (p) += 8;                                                                                            \
250         for (_i = 0; _i < sizeof(uint64_t); _i++)                                                            \
251             n = (n << 8) | *(--p);                                                                           \
252         (p) += 8;                                                                                            \
253     }
254 
255 /* Decode a variable-sized buffer into a 64-bit unsigned integer */
256 /* (Assumes that the high bits of the integer will be zero) */
257 #define UINT64DECODE_VAR(p, n, l) DECODE_VAR(p, n, l)
258 
259 /* Decode a 64-bit unsigned integer and its length from a variable-sized buffer */
260 /* (Assumes that the high bits of the integer will be zero) */
261 #define UINT64DECODE_VARLEN(p, n)                                                                            \
262     {                                                                                                        \
263         unsigned _s = *(p)++;                                                                                \
264                                                                                                              \
265         UINT64DECODE_VAR(p, n, _s);                                                                          \
266     }
267 
268 #define H5_DECODE_UNSIGNED(p, n)                                                                             \
269     {                                                                                                        \
270         HDcompile_assert(sizeof(unsigned) == sizeof(uint32_t));                                              \
271         UINT32DECODE(p, n)                                                                                   \
272     }
273 
274 /* Assumes the endianness of uint64_t is the same as double */
275 #define H5_DECODE_DOUBLE(p, n)                                                                               \
276     {                                                                                                        \
277         uint64_t _n;                                                                                         \
278         size_t   _u;                                                                                         \
279                                                                                                              \
280         HDcompile_assert(sizeof(double) == 8);                                                               \
281         HDcompile_assert(sizeof(double) == sizeof(uint64_t));                                                \
282         _n = 0;                                                                                              \
283         (p) += 8;                                                                                            \
284         for (_u = 0; _u < sizeof(uint64_t); _u++)                                                            \
285             _n = (_n << 8) | *(--p);                                                                         \
286         H5MM_memcpy(&(n), &_n, sizeof(double));                                                              \
287         (p) += 8;                                                                                            \
288     }
289 
290 /* clang-format off */
291 /* Address-related macros */
292 #define H5F_addr_overflow(X,Z)    (HADDR_UNDEF==(X) ||                      \
293                 HADDR_UNDEF==(X)+(haddr_t)(Z) ||                            \
294                 (X)+(haddr_t)(Z)<(X))
295 #define H5F_addr_defined(X)    ((X)!=HADDR_UNDEF)
296 /* The H5F_addr_eq() macro guarantees that Y is not HADDR_UNDEF by making
297  * certain that X is not HADDR_UNDEF and then checking that X equals Y
298  */
299 #define H5F_addr_eq(X,Y)    ((X)!=HADDR_UNDEF &&                            \
300                 (X)==(Y))
301 #define H5F_addr_ne(X,Y)    (!H5F_addr_eq((X),(Y)))
302 #define H5F_addr_lt(X,Y)     ((X)!=HADDR_UNDEF &&                           \
303                 (Y)!=HADDR_UNDEF &&                                         \
304                 (X)<(Y))
305 #define H5F_addr_le(X,Y)    ((X)!=HADDR_UNDEF &&                            \
306                 (Y)!=HADDR_UNDEF &&                                         \
307                 (X)<=(Y))
308 #define H5F_addr_gt(X,Y)    ((X)!=HADDR_UNDEF &&                            \
309                 (Y)!=HADDR_UNDEF &&                                         \
310                 (X)>(Y))
311 #define H5F_addr_ge(X,Y)    ((X)!=HADDR_UNDEF &&                            \
312                 (Y)!=HADDR_UNDEF &&                                         \
313                 (X)>=(Y))
314 #define H5F_addr_cmp(X,Y)    (H5F_addr_eq((X), (Y)) ? 0 :                   \
315                 (H5F_addr_lt((X), (Y)) ? -1 : 1))
316 #define H5F_addr_pow2(N)    ((haddr_t)1<<(N))
317 #define H5F_addr_overlap(O1,L1,O2,L2) (((O1) < (O2) && ((O1) + (L1)) > (O2)) || \
318                                  ((O1) >= (O2) && (O1) < ((O2) + (L2))))
319 /* clang-format on */
320 
321 /* If the module using this macro is allowed access to the private variables, access them directly */
322 #ifdef H5F_MODULE
323 #define H5F_LOW_BOUND(F)                 ((F)->shared->low_bound)
324 #define H5F_HIGH_BOUND(F)                ((F)->shared->high_bound)
325 #define H5F_SHARED_INTENT(F_SH)          ((F_SH)->flags)
326 #define H5F_INTENT(F)                    ((F)->shared->flags)
327 #define H5F_OPEN_NAME(F)                 ((F)->open_name)
328 #define H5F_ACTUAL_NAME(F)               ((F)->actual_name)
329 #define H5F_EXTPATH(F)                   ((F)->shared->extpath)
330 #define H5F_SHARED(F)                    ((F)->shared)
331 #define H5F_SAME_SHARED(F1, F2)          ((F1)->shared == (F2)->shared)
332 #define H5F_NOPEN_OBJS(F)                ((F)->nopen_objs)
333 #define H5F_INCR_NOPEN_OBJS(F)           ((F)->nopen_objs++)
334 #define H5F_DECR_NOPEN_OBJS(F)           ((F)->nopen_objs--)
335 #define H5F_ID_EXISTS(F)                 ((F)->id_exists)
336 #define H5F_PARENT(F)                    ((F)->parent)
337 #define H5F_NMOUNTS(F)                   ((F)->nmounts)
338 #define H5F_GET_READ_ATTEMPTS(F)         ((F)->shared->read_attempts)
339 #define H5F_DRIVER_ID(F)                 ((F)->shared->lf->driver_id)
340 #define H5F_GET_FILENO(F, FILENUM)       ((FILENUM) = (F)->shared->lf->fileno)
341 #define H5F_SHARED_HAS_FEATURE(F_SH, FL) ((F_SH)->lf->feature_flags & (FL))
342 #define H5F_HAS_FEATURE(F, FL)           ((F)->shared->lf->feature_flags & (FL))
343 #define H5F_BASE_ADDR(F)                 ((F)->shared->sblock->base_addr)
344 #define H5F_SYM_LEAF_K(F)                ((F)->shared->sblock->sym_leaf_k)
345 #define H5F_KVALUE(F, T)                 ((F)->shared->sblock->btree_k[(T)->id])
346 #define H5F_NREFS(F)                     ((F)->shared->nrefs)
347 #define H5F_SIZEOF_ADDR(F)               ((F)->shared->sizeof_addr)
348 #define H5F_SIZEOF_SIZE(F)               ((F)->shared->sizeof_size)
349 #define H5F_SOHM_ADDR(F)                 ((F)->shared->sohm_addr)
350 #define H5F_SET_SOHM_ADDR(F, A)          ((F)->shared->sohm_addr = (A))
351 #define H5F_SOHM_VERS(F)                 ((F)->shared->sohm_vers)
352 #define H5F_SET_SOHM_VERS(F, V)          ((F)->shared->sohm_vers = (V))
353 #define H5F_SOHM_NINDEXES(F)             ((F)->shared->sohm_nindexes)
354 #define H5F_SET_SOHM_NINDEXES(F, N)      ((F)->shared->sohm_nindexes = (N))
355 #define H5F_FCPL(F)                      ((F)->shared->fcpl_id)
356 #define H5F_GET_FC_DEGREE(F)             ((F)->shared->fc_degree)
357 #define H5F_EVICT_ON_CLOSE(F)            ((F)->shared->evict_on_close)
358 #define H5F_RDCC_NSLOTS(F)               ((F)->shared->rdcc_nslots)
359 #define H5F_RDCC_NBYTES(F)               ((F)->shared->rdcc_nbytes)
360 #define H5F_RDCC_W0(F)                   ((F)->shared->rdcc_w0)
361 #define H5F_SIEVE_BUF_SIZE(F)            ((F)->shared->sieve_buf_size)
362 #define H5F_GC_REF(F)                    ((F)->shared->gc_ref)
363 #define H5F_STORE_MSG_CRT_IDX(F)         ((F)->shared->store_msg_crt_idx)
364 #define H5F_SET_STORE_MSG_CRT_IDX(F, FL) ((F)->shared->store_msg_crt_idx = (FL))
365 #define H5F_GRP_BTREE_SHARED(F)          ((F)->shared->grp_btree_shared)
366 #define H5F_SET_GRP_BTREE_SHARED(F, RC)  (((F)->shared->grp_btree_shared = (RC)) ? SUCCEED : FAIL)
367 #define H5F_USE_TMP_SPACE(F)             ((F)->shared->fs.use_tmp_space)
368 #define H5F_IS_TMP_ADDR(F, ADDR)         (H5F_addr_le((F)->shared->fs.tmp_addr, (ADDR)))
369 #ifdef H5_HAVE_PARALLEL
370 #define H5F_COLL_MD_READ(F) ((F)->shared->coll_md_read)
371 #endif /* H5_HAVE_PARALLEL */
372 #define H5F_USE_MDC_LOGGING(F)         ((F)->shared->use_mdc_logging)
373 #define H5F_START_MDC_LOG_ON_ACCESS(F) ((F)->shared->start_mdc_log_on_access)
374 #define H5F_MDC_LOG_LOCATION(F)        ((F)->shared->mdc_log_location)
375 #define H5F_ALIGNMENT(F)               ((F)->shared->alignment)
376 #define H5F_THRESHOLD(F)               ((F)->shared->threshold)
377 #define H5F_PGEND_META_THRES(F)        ((F)->shared->fs.pgend_meta_thres)
378 #define H5F_POINT_OF_NO_RETURN(F)      ((F)->shared->fs.point_of_no_return)
379 #define H5F_NULL_FSM_ADDR(F)           ((F)->shared->null_fsm_addr)
380 #define H5F_GET_MIN_DSET_OHDR(F)       ((F)->shared->crt_dset_min_ohdr_flag)
381 #define H5F_SET_MIN_DSET_OHDR(F, V)    ((F)->shared->crt_dset_min_ohdr_flag = (V))
382 #define H5F_VOL_CLS(F)                 ((F)->shared->vol_cls)
383 #define H5F_VOL_OBJ(F)                 ((F)->vol_obj)
384 #define H5F_USE_FILE_LOCKING(F)        ((F)->shared->use_file_locking)
385 #else /* H5F_MODULE */
386 #define H5F_LOW_BOUND(F)                 (H5F_get_low_bound(F))
387 #define H5F_HIGH_BOUND(F)                (H5F_get_high_bound(F))
388 #define H5F_SHARED_INTENT(F_SH)          (H5F_shared_get_intent(F_SH))
389 #define H5F_INTENT(F)                    (H5F_get_intent(F))
390 #define H5F_OPEN_NAME(F)                 (H5F_get_open_name(F))
391 #define H5F_ACTUAL_NAME(F)               (H5F_get_actual_name(F))
392 #define H5F_EXTPATH(F)                   (H5F_get_extpath(F))
393 #define H5F_SHARED(F)                    (H5F_get_shared(F))
394 #define H5F_SAME_SHARED(F1, F2)          (H5F_same_shared((F1), (F2)))
395 #define H5F_NOPEN_OBJS(F)                (H5F_get_nopen_objs(F))
396 #define H5F_INCR_NOPEN_OBJS(F)           (H5F_incr_nopen_objs(F))
397 #define H5F_DECR_NOPEN_OBJS(F)           (H5F_decr_nopen_objs(F))
398 #define H5F_ID_EXISTS(F)                 (H5F_file_id_exists(F))
399 #define H5F_PARENT(F)                    (H5F_get_parent(F))
400 #define H5F_NMOUNTS(F)                   (H5F_get_nmounts(F))
401 #define H5F_GET_READ_ATTEMPTS(F)         (H5F_get_read_attempts(F))
402 #define H5F_DRIVER_ID(F)                 (H5F_get_driver_id(F))
403 #define H5F_GET_FILENO(F, FILENUM)       (H5F_get_fileno((F), &(FILENUM)))
404 #define H5F_SHARED_HAS_FEATURE(F_SH, FL) (H5F_shared_has_feature(F_SH, FL))
405 #define H5F_HAS_FEATURE(F, FL)           (H5F_has_feature(F, FL))
406 #define H5F_BASE_ADDR(F)                 (H5F_get_base_addr(F))
407 #define H5F_SYM_LEAF_K(F)                (H5F_sym_leaf_k(F))
408 #define H5F_KVALUE(F, T)                 (H5F_Kvalue(F, T))
409 #define H5F_NREFS(F)                     (H5F_get_nrefs(F))
410 #define H5F_SIZEOF_ADDR(F)               (H5F_sizeof_addr(F))
411 #define H5F_SIZEOF_SIZE(F)               (H5F_sizeof_size(F))
412 #define H5F_SOHM_ADDR(F)                 (H5F_get_sohm_addr(F))
413 #define H5F_SET_SOHM_ADDR(F, A)          (H5F_set_sohm_addr((F), (A)))
414 #define H5F_SOHM_VERS(F)                 (H5F_get_sohm_vers(F))
415 #define H5F_SET_SOHM_VERS(F, V)          (H5F_set_sohm_vers((F), (V)))
416 #define H5F_SOHM_NINDEXES(F)             (H5F_get_sohm_nindexes(F))
417 #define H5F_SET_SOHM_NINDEXES(F, N)      (H5F_set_sohm_nindexes((F), (N)))
418 #define H5F_FCPL(F)                      (H5F_get_fcpl(F))
419 #define H5F_GET_FC_DEGREE(F)             (H5F_get_fc_degree(F))
420 #define H5F_EVICT_ON_CLOSE(F)            (H5F_get_evict_on_close(F))
421 #define H5F_RDCC_NSLOTS(F)               (H5F_rdcc_nslots(F))
422 #define H5F_RDCC_NBYTES(F)               (H5F_rdcc_nbytes(F))
423 #define H5F_RDCC_W0(F)                   (H5F_rdcc_w0(F))
424 #define H5F_SIEVE_BUF_SIZE(F)            (H5F_sieve_buf_size(F))
425 #define H5F_GC_REF(F)                    (H5F_gc_ref(F))
426 #define H5F_STORE_MSG_CRT_IDX(F)         (H5F_store_msg_crt_idx(F))
427 #define H5F_SET_STORE_MSG_CRT_IDX(F, FL) (H5F_set_store_msg_crt_idx((F), (FL)))
428 #define H5F_GRP_BTREE_SHARED(F)          (H5F_grp_btree_shared(F))
429 #define H5F_SET_GRP_BTREE_SHARED(F, RC)  (H5F_set_grp_btree_shared((F), (RC)))
430 #define H5F_USE_TMP_SPACE(F)             (H5F_use_tmp_space(F))
431 #define H5F_IS_TMP_ADDR(F, ADDR)         (H5F_is_tmp_addr((F), (ADDR)))
432 #ifdef H5_HAVE_PARALLEL
433 #define H5F_COLL_MD_READ(F) (H5F_coll_md_read(F))
434 #endif /* H5_HAVE_PARALLEL */
435 #define H5F_USE_MDC_LOGGING(F)         (H5F_use_mdc_logging(F))
436 #define H5F_START_MDC_LOG_ON_ACCESS(F) (H5F_start_mdc_log_on_access(F))
437 #define H5F_MDC_LOG_LOCATION(F)        (H5F_mdc_log_location(F))
438 #define H5F_ALIGNMENT(F)               (H5F_get_alignment(F))
439 #define H5F_THRESHOLD(F)               (H5F_get_threshold(F))
440 #define H5F_PGEND_META_THRES(F)        (H5F_get_pgend_meta_thres(F))
441 #define H5F_POINT_OF_NO_RETURN(F)      (H5F_get_point_of_no_return(F))
442 #define H5F_NULL_FSM_ADDR(F)           (H5F_get_null_fsm_addr(F))
443 #define H5F_GET_MIN_DSET_OHDR(F)       (H5F_get_min_dset_ohdr(F))
444 #define H5F_SET_MIN_DSET_OHDR(F, V)    (H5F_set_min_dset_ohdr((F), (V)))
445 #define H5F_VOL_CLS(F)                 (H5F_get_vol_cls(F))
446 #define H5F_VOL_OBJ(F)                 (H5F_get_vol_obj(F))
447 #define H5F_USE_FILE_LOCKING(F)        (H5F_get_use_file_locking(F))
448 #endif /* H5F_MODULE */
449 
450 /* Macros to encode/decode offset/length's for storing in the file */
451 #define H5F_ENCODE_OFFSET(f, p, o)                                                                           \
452     switch (H5F_SIZEOF_ADDR(f)) {                                                                            \
453         case 4:                                                                                              \
454             UINT32ENCODE(p, o);                                                                              \
455             break;                                                                                           \
456         case 8:                                                                                              \
457             UINT64ENCODE(p, o);                                                                              \
458             break;                                                                                           \
459         case 2:                                                                                              \
460             UINT16ENCODE(p, o);                                                                              \
461             break;                                                                                           \
462     }
463 
464 #define H5F_DECODE_OFFSET(f, p, o)                                                                           \
465     switch (H5F_SIZEOF_ADDR(f)) {                                                                            \
466         case 4:                                                                                              \
467             UINT32DECODE(p, o);                                                                              \
468             break;                                                                                           \
469         case 8:                                                                                              \
470             UINT64DECODE(p, o);                                                                              \
471             break;                                                                                           \
472         case 2:                                                                                              \
473             UINT16DECODE(p, o);                                                                              \
474             break;                                                                                           \
475     }
476 
477 #define H5F_ENCODE_LENGTH_LEN(p, l, s)                                                                       \
478     switch (s) {                                                                                             \
479         case 4:                                                                                              \
480             UINT32ENCODE(p, l);                                                                              \
481             break;                                                                                           \
482         case 8:                                                                                              \
483             UINT64ENCODE(p, l);                                                                              \
484             break;                                                                                           \
485         case 2:                                                                                              \
486             UINT16ENCODE(p, l);                                                                              \
487             break;                                                                                           \
488         default:                                                                                             \
489             HDassert("bad sizeof size" && 0);                                                                \
490     }
491 
492 #define H5F_ENCODE_LENGTH(f, p, l) H5F_ENCODE_LENGTH_LEN(p, l, H5F_SIZEOF_SIZE(f))
493 
494 #define H5F_DECODE_LENGTH_LEN(p, l, s)                                                                       \
495     switch (s) {                                                                                             \
496         case 4:                                                                                              \
497             UINT32DECODE(p, l);                                                                              \
498             break;                                                                                           \
499         case 8:                                                                                              \
500             UINT64DECODE(p, l);                                                                              \
501             break;                                                                                           \
502         case 2:                                                                                              \
503             UINT16DECODE(p, l);                                                                              \
504             break;                                                                                           \
505         default:                                                                                             \
506             HDassert("bad sizeof size" && 0);                                                                \
507     }
508 
509 #define H5F_DECODE_LENGTH(f, p, l) DECODE_VAR(p, l, H5F_SIZEOF_SIZE(f))
510 
511 /*
512  * Macros that check for overflows.  These are somewhat dangerous to fiddle
513  * with.
514  */
515 #if (H5_SIZEOF_SIZE_T >= H5_SIZEOF_OFF_T)
516 #define H5F_OVERFLOW_SIZET2OFFT(X) ((size_t)(X) >= (size_t)((size_t)1 << (8 * sizeof(HDoff_t) - 1)))
517 #else
518 #define H5F_OVERFLOW_SIZET2OFFT(X) 0
519 #endif
520 #if (H5_SIZEOF_HSIZE_T >= H5_SIZEOF_OFF_T)
521 #define H5F_OVERFLOW_HSIZET2OFFT(X) ((hsize_t)(X) >= (hsize_t)((hsize_t)1 << (8 * sizeof(HDoff_t) - 1)))
522 #else
523 #define H5F_OVERFLOW_HSIZET2OFFT(X) 0
524 #endif
525 
526 /* Sizes of object addresses & sizes in the file (in bytes) */
527 #define H5F_OBJ_ADDR_SIZE sizeof(haddr_t)
528 #define H5F_OBJ_SIZE_SIZE sizeof(hsize_t)
529 
530 /* File-wide default character encoding can not yet be set via the file
531  * creation property list and is always ASCII. */
532 #define H5F_DEFAULT_CSET H5T_CSET_ASCII
533 
534 /* ========= File Creation properties ============ */
535 #define H5F_CRT_USER_BLOCK_NAME    "block_size"  /* Size of the file user block in bytes */
536 #define H5F_CRT_SYM_LEAF_NAME      "symbol_leaf" /* 1/2 rank for symbol table leaf nodes */
537 #define H5F_CRT_SYM_LEAF_DEF       4
538 #define H5F_CRT_BTREE_RANK_NAME    "btree_rank"    /* 1/2 rank for btree internal nodes    */
539 #define H5F_CRT_ADDR_BYTE_NUM_NAME "addr_byte_num" /* Byte number in an address            */
540 #define H5F_CRT_OBJ_BYTE_NUM_NAME  "obj_byte_num"  /* Byte number for object size          */
541 #define H5F_CRT_SUPER_VERS_NAME    "super_version" /* Version number of the superblock     */
542 /* Number of shared object header message indexes */
543 #define H5F_CRT_SHMSG_NINDEXES_NAME    "num_shmsg_indexes"
544 #define H5F_CRT_SHMSG_INDEX_TYPES_NAME "shmsg_message_types" /* Types of message in each index */
545 /* Minimum size of messages in each index */
546 #define H5F_CRT_SHMSG_INDEX_MINSIZE_NAME  "shmsg_message_minsize"
547 #define H5F_CRT_SHMSG_LIST_MAX_NAME       "shmsg_list_max"       /* Shared message list maximum size */
548 #define H5F_CRT_SHMSG_BTREE_MIN_NAME      "shmsg_btree_min"      /* Shared message B-tree minimum size */
549 #define H5F_CRT_FILE_SPACE_STRATEGY_NAME  "file_space_strategy"  /* File space handling strategy */
550 #define H5F_CRT_FREE_SPACE_PERSIST_NAME   "free_space_persist"   /* Free-space persisting status */
551 #define H5F_CRT_FREE_SPACE_THRESHOLD_NAME "free_space_threshold" /* Free space section threshold */
552 #define H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME "file_space_page_size" /* File space page size */
553 
554 /* ========= File Access properties ============ */
555 #define H5F_ACS_META_CACHE_INIT_CONFIG_NAME                                                                  \
556     "mdc_initCacheCfg"                                  /* Initial metadata cache resize configuration */
557 #define H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */
558 #define H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME "rdcc_nbytes" /* Size of raw data chunk cache(bytes) */
559 #define H5F_ACS_PREEMPT_READ_CHUNKS_NAME  "rdcc_w0"     /* Preemption read chunks first */
560 #define H5F_ACS_ALIGN_THRHD_NAME          "threshold"   /* Threshold for alignment */
561 #define H5F_ACS_ALIGN_NAME                "align"       /* Alignment */
562 #define H5F_ACS_META_BLOCK_SIZE_NAME                                                                         \
563     "meta_block_size" /* Minimum metadata allocation block size (when aggregating metadata allocations) */
564 #define H5F_ACS_SIEVE_BUF_SIZE_NAME                                                                          \
565     "sieve_buf_size" /* Maximum sieve buffer size (when data sieving is allowed by file driver) */
566 #define H5F_ACS_SDATA_BLOCK_SIZE_NAME                                                                        \
567     "sdata_block_size" /* Minimum "small data" allocation block size (when aggregating "small" raw data      \
568                           allocations) */
569 #define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref"             /* Garbage-collect references */
570 #define H5F_ACS_FILE_DRV_NAME        "vfd_info"           /* File driver ID & info */
571 #define H5F_ACS_VOL_CONN_NAME        "vol_connector_info" /* VOL connector ID & info */
572 #define H5F_ACS_CLOSE_DEGREE_NAME    "close_degree"       /* File close degree */
573 #define H5F_ACS_FAMILY_OFFSET_NAME   "family_offset"      /* Offset position in file for family file driver */
574 #define H5F_ACS_FAMILY_NEWSIZE_NAME                                                                          \
575     "family_newsize" /* New member size of family driver.  (private property only used by h5repart) */
576 #define H5F_ACS_FAMILY_TO_SINGLE_NAME                                                                        \
577     "family_to_single" /* Whether to convert family to a single-file driver.  (private property only used by \
578                           h5repart) */
579 #define H5F_ACS_MULTI_TYPE_NAME        "multi_type"        /* Data type in multi file driver */
580 #define H5F_ACS_LIBVER_LOW_BOUND_NAME  "libver_low_bound"  /* 'low' bound of library format versions */
581 #define H5F_ACS_LIBVER_HIGH_BOUND_NAME "libver_high_bound" /* 'high' bound of library format versions */
582 #define H5F_ACS_WANT_POSIX_FD_NAME                                                                           \
583     "want_posix_fd" /* Internal: query the file descriptor from the core VFD, instead of the memory address  \
584                      */
585 #define H5F_ACS_METADATA_READ_ATTEMPTS_NAME "metadata_read_attempts" /* # of metadata read attempts */
586 #define H5F_ACS_OBJECT_FLUSH_CB_NAME        "object_flush_cb"        /* Object flush callback */
587 #define H5F_ACS_EFC_SIZE_NAME               "efc_size"               /* Size of external file cache */
588 #define H5F_ACS_FILE_IMAGE_INFO_NAME                                                                         \
589     "file_image_info" /* struct containing initial file image and callback info */
590 #define H5F_ACS_CLEAR_STATUS_FLAGS_NAME                                                                      \
591     "clear_status_flags" /* Whether to clear superblock status_flags (private property only used by h5clear) \
592                           */
593 #define H5F_ACS_NULL_FSM_ADDR_NAME "null_fsm_addr" /* Nullify addresses of free-space managers */
594 /* Private property used only by h5clear */
595 #define H5F_ACS_SKIP_EOF_CHECK_NAME "skip_eof_check" /* Skip EOF check */
596 /* Private property used only by h5clear */
597 #define H5F_ACS_USE_MDC_LOGGING_NAME  "use_mdc_logging"  /* Whether to use metadata cache logging */
598 #define H5F_ACS_MDC_LOG_LOCATION_NAME "mdc_log_location" /* Name of metadata cache log location */
599 #define H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME                                                                 \
600     "start_mdc_log_on_access" /* Whether logging starts on file create/open */
601 #define H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME                                                                     \
602     "evict_on_close_flag" /* Whether or not the metadata cache will evict objects on close */
603 #define H5F_ACS_COLL_MD_WRITE_FLAG_NAME                                                                      \
604     "collective_metadata_write" /* property indicating whether metadata writes are done collectively or not  \
605                                  */
606 #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME                                                            \
607     "mdc_initCacheImageCfg" /* Initial metadata cache image creation configuration */
608 #define H5F_ACS_PAGE_BUFFER_SIZE_NAME "page_buffer_size" /* the maximum size for the page buffer cache */
609 #define H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME                                                               \
610     "page_buffer_min_meta_perc" /* the min metadata percentage for the page buffer cache */
611 #define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME                                                                \
612     "page_buffer_min_raw_perc" /* the min raw data percentage for the page buffer cache */
613 #define H5F_ACS_USE_FILE_LOCKING_NAME                                                                        \
614     "use_file_locking" /* whether or not we use file locks for SWMR control and to prevent multiple writers  \
615                         */
616 #define H5F_ACS_IGNORE_DISABLED_FILE_LOCKS_NAME                                                              \
617     "ignore_disabled_file_locks" /* whether or not we ignore "locks disabled" errors */
618 #ifdef H5_HAVE_PARALLEL
619 #define H5F_ACS_MPI_PARAMS_COMM_NAME "mpi_params_comm" /* the MPI communicator */
620 #define H5F_ACS_MPI_PARAMS_INFO_NAME "mpi_params_info" /* the MPI info struct */
621 #endif                                                 /* H5_HAVE_PARALLEL */
622 
623 /* ======================== File Mount properties ====================*/
624 #define H5F_MNT_SYM_LOCAL_NAME "local" /* Whether absolute symlinks local to file. */
625 
626 #ifdef H5_HAVE_PARALLEL
627 /* Which process writes metadata */
628 #define H5_PAR_META_WRITE 0
629 #endif /* H5_HAVE_PARALLEL */
630 
631 /* Define the HDF5 file signature */
632 #define H5F_SIGNATURE     "\211HDF\r\n\032\n"
633 #define H5F_SIGNATURE_LEN 8
634 
635 /* Version #'s of the major components of the file format */
636 #define HDF5_SUPERBLOCK_VERSION_DEF 0 /* The default super block format      */
637 #define HDF5_SUPERBLOCK_VERSION_1   1 /* Version with non-default B-tree 'K' value */
638 #define HDF5_SUPERBLOCK_VERSION_2   2 /* Revised version with superblock extension and checksum */
639 #define HDF5_SUPERBLOCK_VERSION_3                                                                            \
640     3 /* With file locking and consistency flags (at least this version for SWMR support) */
641 #define HDF5_SUPERBLOCK_VERSION_LATEST HDF5_SUPERBLOCK_VERSION_3 /* The maximum super block format    */
642 #define HDF5_SUPERBLOCK_VERSION_V18_LATEST                                                                   \
643     HDF5_SUPERBLOCK_VERSION_2       /* The latest superblock version for v18 */
644 #define HDF5_FREESPACE_VERSION    0 /* of the Free-Space Info      */
645 #define HDF5_OBJECTDIR_VERSION    0 /* of the Object Directory format */
646 #define HDF5_SHAREDHEADER_VERSION 0 /* of the Shared-Header Info      */
647 #define HDF5_DRIVERINFO_VERSION_0 0 /* of the Driver Information Block*/
648 
649 /* B-tree internal 'K' values */
650 #define HDF5_BTREE_SNODE_IK_DEF 16
651 #define HDF5_BTREE_CHUNK_IK_DEF                                                                              \
652     32                                  /* Note! this value is assumed                                       \
653                                            to be 32 for version 0                                            \
654                                            of the superblock and                                             \
655                                            if it is changed, the code                                        \
656                                            must compensate. -QAK                                             \
657                                         */
658 #define HDF5_BTREE_IK_MAX_ENTRIES 65536 /* 2^16 - 2 bytes for storing entries (children) */
659 /* See format specification on version 1 B-trees */
660 
661 /* Default file space handling strategy */
662 #define H5F_FILE_SPACE_STRATEGY_DEF H5F_FSPACE_STRATEGY_FSM_AGGR
663 
664 /* Default free space section threshold used by free-space managers */
665 #define H5F_FREE_SPACE_PERSIST_DEF FALSE
666 
667 /* Default free space section threshold used by free-space managers */
668 #define H5F_FREE_SPACE_THRESHOLD_DEF 1
669 
670 /* For paged aggregation: default file space page size when not set */
671 #define H5F_FILE_SPACE_PAGE_SIZE_DEF 4096
672 /* For paged aggregation: minimum value for file space page size */
673 #define H5F_FILE_SPACE_PAGE_SIZE_MIN 512
674 /* For paged aggregation: maximum value for file space page size: 1 gigabyte */
675 #define H5F_FILE_SPACE_PAGE_SIZE_MAX 1024 * 1024 * 1024
676 
677 /* For paged aggregation: drop free-space with size <= this threshold for small meta section */
678 #define H5F_FILE_SPACE_PGEND_META_THRES 0
679 
680 /* Default for threshold for alignment (can be set via H5Pset_alignment()) */
681 #define H5F_ALIGN_DEF 1
682 /* Default for alignment (can be set via H5Pset_alignment()) */
683 #define H5F_ALIGN_THRHD_DEF 1
684 /* Default size for meta data aggregation block (can be set via H5Pset_meta_block_size()) */
685 #define H5F_META_BLOCK_SIZE_DEF 2048
686 /* Default size for small data aggregation block (can be set via H5Pset_small_data_block_size()) */
687 #define H5F_SDATA_BLOCK_SIZE_DEF 2048
688 
689 /* Check for file using paged aggregation */
690 #define H5F_SHARED_PAGED_AGGR(F_SH) ((F_SH)->fs_strategy == H5F_FSPACE_STRATEGY_PAGE && (F_SH)->fs_page_size)
691 #define H5F_PAGED_AGGR(F)           (F->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE && F->shared->fs_page_size)
692 
693 /* Metadata read attempt values */
694 #define H5F_METADATA_READ_ATTEMPTS      1   /* Default # of read attempts for non-SWMR access */
695 #define H5F_SWMR_METADATA_READ_ATTEMPTS 100 /* Default # of read attempts for SWMR access */
696 
697 /* Macros to define signatures of all objects in the file */
698 
699 /* Size of signature information (on disk) */
700 /* (all on-disk signatures should be this length) */
701 #define H5_SIZEOF_MAGIC 4
702 
703 /* Size of checksum information (on disk) */
704 /* (all on-disk checksums should be this length) */
705 #define H5_SIZEOF_CHKSUM 4
706 
707 /* v1 B-tree node signature */
708 #define H5B_MAGIC "TREE"
709 
710 /* v2 B-tree signatures */
711 #define H5B2_HDR_MAGIC  "BTHD" /* Header */
712 #define H5B2_INT_MAGIC  "BTIN" /* Internal node */
713 #define H5B2_LEAF_MAGIC "BTLF" /* Leaf node */
714 
715 /* Extensible array signatures */
716 #define H5EA_HDR_MAGIC    "EAHD" /* Header */
717 #define H5EA_IBLOCK_MAGIC "EAIB" /* Index block */
718 #define H5EA_SBLOCK_MAGIC "EASB" /* Super block */
719 #define H5EA_DBLOCK_MAGIC "EADB" /* Data block */
720 
721 /* Fixed array signatures */
722 #define H5FA_HDR_MAGIC    "FAHD" /* Header */
723 #define H5FA_DBLOCK_MAGIC "FADB" /* Data block */
724 
725 /* Free space signatures */
726 #define H5FS_HDR_MAGIC   "FSHD" /* Header */
727 #define H5FS_SINFO_MAGIC "FSSE" /* Serialized sections */
728 
729 /* Symbol table node signature */
730 #define H5G_NODE_MAGIC "SNOD"
731 
732 /* Fractal heap signatures */
733 #define H5HF_HDR_MAGIC    "FRHP" /* Header */
734 #define H5HF_IBLOCK_MAGIC "FHIB" /* Indirect block */
735 #define H5HF_DBLOCK_MAGIC "FHDB" /* Direct block */
736 
737 /* Global heap signature */
738 #define H5HG_MAGIC "GCOL"
739 
740 /* Local heap signature */
741 #define H5HL_MAGIC "HEAP"
742 
743 /* Object header signatures */
744 #define H5O_HDR_MAGIC "OHDR" /* Header */
745 #define H5O_CHK_MAGIC "OCHK" /* Continuation chunk */
746 
747 /* Shared Message signatures */
748 #define H5SM_TABLE_MAGIC "SMTB" /* Shared Message Table */
749 #define H5SM_LIST_MAGIC  "SMLI" /* Shared Message List */
750 
751 /****************************/
752 /* Library Private Typedefs */
753 /****************************/
754 
755 /* Forward declarations (for prototypes & type definitions) */
756 struct H5B_class_t;
757 struct H5UC_t;
758 struct H5O_loc_t;
759 struct H5HG_heap_t;
760 struct H5VL_class_t;
761 struct H5P_genplist_t;
762 
763 /* Forward declarations for anonymous H5F objects */
764 
765 /* Main file structures */
766 typedef struct H5F_shared_t H5F_shared_t;
767 
768 /* Block aggregation structure */
769 typedef struct H5F_blk_aggr_t H5F_blk_aggr_t;
770 
771 /* Structure for object flush callback property (H5Pset_object_flush_cb)*/
772 typedef struct H5F_object_flush_t {
773     H5F_flush_cb_t func;  /* The callback function */
774     void *         udata; /* User data */
775 } H5F_object_flush_t;
776 
777 /* Concise info about a block of bytes in a file */
778 typedef struct H5F_block_t {
779     haddr_t offset; /* Offset of the block in the file */
780     hsize_t length; /* Length of the block in the file */
781 } H5F_block_t;
782 
783 /* Enum for free space manager state */
784 typedef enum H5F_fs_state_t {
785     H5F_FS_STATE_CLOSED   = 0, /* Free space manager is closed */
786     H5F_FS_STATE_OPEN     = 1, /* Free space manager has been opened */
787     H5F_FS_STATE_DELETING = 2  /* Free space manager is being deleted */
788 } H5F_fs_state_t;
789 
790 /* For paged aggregation */
791 /* The values 0 to 6 is the same as H5F_mem_t */
792 typedef enum H5F_mem_page_t {
793     H5F_MEM_PAGE_DEFAULT     = 0, /* Not used */
794     H5F_MEM_PAGE_SUPER       = 1,
795     H5F_MEM_PAGE_BTREE       = 2,
796     H5F_MEM_PAGE_DRAW        = 3,
797     H5F_MEM_PAGE_GHEAP       = 4,
798     H5F_MEM_PAGE_LHEAP       = 5,
799     H5F_MEM_PAGE_OHDR        = 6,
800     H5F_MEM_PAGE_LARGE_SUPER = 7,
801     H5F_MEM_PAGE_LARGE_BTREE = 8,
802     H5F_MEM_PAGE_LARGE_DRAW  = 9,
803     H5F_MEM_PAGE_LARGE_GHEAP = 10,
804     H5F_MEM_PAGE_LARGE_LHEAP = 11,
805     H5F_MEM_PAGE_LARGE_OHDR  = 12,
806     H5F_MEM_PAGE_NTYPES      = 13 /* Sentinel value - must be last */
807 } H5F_mem_page_t;
808 
809 /* Aliases for H5F_mem_page_t enum values */
810 #define H5F_MEM_PAGE_META    H5F_MEM_PAGE_SUPER       /* Small-sized meta data */
811 #define H5F_MEM_PAGE_GENERIC H5F_MEM_PAGE_LARGE_SUPER /* Large-sized generic: meta and raw */
812 
813 /* Type of prefix for opening prefixed files */
814 typedef enum H5F_prefix_open_t {
815     H5F_PREFIX_VDS   = 0, /* Virtual dataset prefix */
816     H5F_PREFIX_ELINK = 1, /* External link prefix   */
817     H5F_PREFIX_EFILE = 2  /* External file prefix   */
818 } H5F_prefix_open_t;
819 
820 /*****************************/
821 /* Library-private Variables */
822 /*****************************/
823 
824 /***************************************/
825 /* Library-private Function Prototypes */
826 /***************************************/
827 
828 /* Private functions */
829 H5_DLL herr_t H5F_init(void);
830 H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id);
831 H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/);
832 H5_DLL hid_t  H5F_get_file_id(H5VL_object_t *vol_obj, H5I_type_t obj_type, hbool_t app_ref);
833 
834 /* Functions that retrieve values from the file struct */
835 H5_DLL H5F_libver_t H5F_get_low_bound(const H5F_t *f);
836 H5_DLL H5F_libver_t H5F_get_high_bound(const H5F_t *f);
837 H5_DLL unsigned     H5F_shared_get_intent(const H5F_shared_t *f);
838 H5_DLL unsigned     H5F_get_intent(const H5F_t *f);
839 H5_DLL char *       H5F_get_open_name(const H5F_t *f);
840 H5_DLL char *       H5F_get_actual_name(const H5F_t *f);
841 H5_DLL char *       H5F_get_extpath(const H5F_t *f);
842 H5_DLL H5F_shared_t *H5F_get_shared(const H5F_t *f);
843 H5_DLL hbool_t       H5F_same_shared(const H5F_t *f1, const H5F_t *f2);
844 H5_DLL unsigned      H5F_get_nopen_objs(const H5F_t *f);
845 H5_DLL unsigned      H5F_incr_nopen_objs(H5F_t *f);
846 H5_DLL unsigned      H5F_decr_nopen_objs(H5F_t *f);
847 H5_DLL hbool_t       H5F_file_id_exists(const H5F_t *f);
848 H5_DLL H5F_t *  H5F_get_parent(const H5F_t *f);
849 H5_DLL unsigned H5F_get_nmounts(const H5F_t *f);
850 H5_DLL unsigned H5F_get_read_attempts(const H5F_t *f);
851 H5_DLL hid_t    H5F_get_access_plist(H5F_t *f, hbool_t app_ref);
852 H5_DLL hid_t    H5F_get_id(H5F_t *file);
853 H5_DLL herr_t   H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref, size_t *obj_id_count_ptr);
854 H5_DLL herr_t   H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *oid_list,
855                                 hbool_t app_ref, size_t *obj_id_count_ptr);
856 H5_DLL hsize_t  H5F_get_pgend_meta_thres(const H5F_t *f);
857 H5_DLL hbool_t  H5F_get_point_of_no_return(const H5F_t *f);
858 H5_DLL hbool_t  H5F_get_null_fsm_addr(const H5F_t *f);
859 H5_DLL hbool_t  H5F_get_min_dset_ohdr(const H5F_t *f);
860 H5_DLL herr_t   H5F_set_min_dset_ohdr(H5F_t *f, hbool_t minimize);
861 H5_DLL const H5VL_class_t *H5F_get_vol_cls(const H5F_t *f);
862 H5_DLL H5VL_object_t *H5F_get_vol_obj(const H5F_t *f);
863 H5_DLL hbool_t        H5F_get_file_locking(const H5F_t *f);
864 
865 /* Functions than retrieve values set/cached from the superblock/FCPL */
866 H5_DLL haddr_t            H5F_get_base_addr(const H5F_t *f);
867 H5_DLL unsigned           H5F_sym_leaf_k(const H5F_t *f);
868 H5_DLL unsigned           H5F_Kvalue(const H5F_t *f, const struct H5B_class_t *type);
869 H5_DLL unsigned           H5F_get_nrefs(const H5F_t *f);
870 H5_DLL uint8_t            H5F_sizeof_addr(const H5F_t *f);
871 H5_DLL uint8_t            H5F_sizeof_size(const H5F_t *f);
872 H5_DLL haddr_t            H5F_get_sohm_addr(const H5F_t *f);
873 H5_DLL herr_t             H5F_set_sohm_addr(H5F_t *f, haddr_t addr);
874 H5_DLL unsigned           H5F_get_sohm_vers(const H5F_t *f);
875 H5_DLL herr_t             H5F_set_sohm_vers(H5F_t *f, unsigned vers);
876 H5_DLL unsigned           H5F_get_sohm_nindexes(const H5F_t *f);
877 H5_DLL herr_t             H5F_set_sohm_nindexes(H5F_t *f, unsigned nindexes);
878 H5_DLL hid_t              H5F_get_fcpl(const H5F_t *f);
879 H5_DLL H5F_close_degree_t H5F_get_fc_degree(const H5F_t *f);
880 H5_DLL hbool_t            H5F_get_evict_on_close(const H5F_t *f);
881 H5_DLL size_t             H5F_rdcc_nbytes(const H5F_t *f);
882 H5_DLL size_t             H5F_rdcc_nslots(const H5F_t *f);
883 H5_DLL double             H5F_rdcc_w0(const H5F_t *f);
884 H5_DLL size_t             H5F_sieve_buf_size(const H5F_t *f);
885 H5_DLL unsigned           H5F_gc_ref(const H5F_t *f);
886 H5_DLL hbool_t            H5F_store_msg_crt_idx(const H5F_t *f);
887 H5_DLL herr_t             H5F_set_store_msg_crt_idx(H5F_t *f, hbool_t flag);
888 H5_DLL struct H5UC_t *    H5F_grp_btree_shared(const H5F_t *f);
889 H5_DLL herr_t             H5F_set_grp_btree_shared(H5F_t *f, struct H5UC_t *rc);
890 H5_DLL hbool_t            H5F_use_tmp_space(const H5F_t *f);
891 H5_DLL hbool_t            H5F_is_tmp_addr(const H5F_t *f, haddr_t addr);
892 H5_DLL hsize_t            H5F_get_alignment(const H5F_t *f);
893 H5_DLL hsize_t            H5F_get_threshold(const H5F_t *f);
894 #ifdef H5_HAVE_PARALLEL
895 H5_DLL H5P_coll_md_read_flag_t H5F_coll_md_read(const H5F_t *f);
896 #endif /* H5_HAVE_PARALLEL */
897 H5_DLL hbool_t H5F_use_mdc_logging(const H5F_t *f);
898 H5_DLL hbool_t H5F_start_mdc_log_on_access(const H5F_t *f);
899 H5_DLL char *  H5F_mdc_log_location(const H5F_t *f);
900 
901 /* Functions that retrieve values from VFD layer */
902 H5_DLL hid_t   H5F_get_driver_id(const H5F_t *f);
903 H5_DLL herr_t  H5F_get_fileno(const H5F_t *f, unsigned long *filenum);
904 H5_DLL hbool_t H5F_shared_has_feature(const H5F_shared_t *f, unsigned feature);
905 H5_DLL hbool_t H5F_has_feature(const H5F_t *f, unsigned feature);
906 H5_DLL haddr_t H5F_shared_get_eoa(const H5F_shared_t *f_sh, H5FD_mem_t type);
907 H5_DLL haddr_t H5F_get_eoa(const H5F_t *f, H5FD_mem_t type);
908 H5_DLL herr_t  H5F_get_vfd_handle(const H5F_t *file, hid_t fapl, void **file_handle);
909 
910 /* Functions that check file mounting information */
911 H5_DLL hbool_t H5F_is_mount(const H5F_t *file);
912 H5_DLL hbool_t H5F_has_mount(const H5F_t *file);
913 H5_DLL herr_t  H5F_traverse_mount(struct H5O_loc_t *oloc /*in,out*/);
914 H5_DLL herr_t  H5F_flush_mounts(H5F_t *f);
915 
916 /* Functions that operate on blocks of bytes wrt super block */
917 H5_DLL herr_t H5F_shared_block_read(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size,
918                                     void *buf /*out*/);
919 H5_DLL herr_t H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf /*out*/);
920 H5_DLL herr_t H5F_shared_block_write(H5F_shared_t *f_sh, H5FD_mem_t type, haddr_t addr, size_t size,
921                                      const void *buf);
922 H5_DLL herr_t H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf);
923 
924 /* Functions that flush or evict */
925 H5_DLL herr_t H5F_flush_tagged_metadata(H5F_t *f, haddr_t tag);
926 H5_DLL herr_t H5F_evict_tagged_metadata(H5F_t *f, haddr_t tag);
927 
928 /* Functions that verify a piece of metadata with checksum */
929 H5_DLL herr_t H5F_get_checksums(const uint8_t *buf, size_t chk_size, uint32_t *s_chksum, uint32_t *c_chksum);
930 
931 /* Routine to track the # of retries */
932 H5_DLL herr_t H5F_track_metadata_read_retries(H5F_t *f, unsigned actype, unsigned retries);
933 H5_DLL herr_t H5F_set_retries(H5F_t *f);
934 H5_DLL herr_t H5F_get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info);
935 
936 /* Routine to invoke callback function upon object flush */
937 H5_DLL herr_t H5F_object_flush_cb(H5F_t *f, hid_t obj_id);
938 
939 /* Address-related functions */
940 H5_DLL void H5F_addr_encode(const H5F_t *f, uint8_t **pp, haddr_t addr);
941 H5_DLL void H5F_addr_encode_len(size_t addr_len, uint8_t **pp, haddr_t addr);
942 H5_DLL void H5F_addr_decode(const H5F_t *f, const uint8_t **pp, haddr_t *addr_p);
943 H5_DLL void H5F_addr_decode_len(size_t addr_len, const uint8_t **pp, haddr_t *addr_p);
944 
945 /* Shared file list related routines */
946 H5_DLL void H5F_sfile_assert_num(unsigned n);
947 
948 /* Routines for creating & destroying "fake" file structures */
949 H5_DLL H5F_t *H5F_fake_alloc(uint8_t sizeof_size);
950 H5_DLL herr_t H5F_fake_free(H5F_t *f);
951 
952 /* Superblock related routines */
953 H5_DLL herr_t H5F_super_dirty(H5F_t *f);
954 H5_DLL herr_t H5F_eoa_dirty(H5F_t *f);
955 
956 /* Parallel I/O (i.e. MPI) related routines */
957 #ifdef H5_HAVE_PARALLEL
958 H5_DLL int      H5F_mpi_get_rank(const H5F_t *f);
959 H5_DLL MPI_Comm H5F_mpi_get_comm(const H5F_t *f);
960 H5_DLL int      H5F_shared_mpi_get_size(const H5F_shared_t *f_sh);
961 H5_DLL int      H5F_mpi_get_size(const H5F_t *f);
962 H5_DLL herr_t   H5F_mpi_retrieve_comm(hid_t loc_id, hid_t acspl_id, MPI_Comm *mpi_comm);
963 H5_DLL herr_t   H5F_get_mpi_atomicity(H5F_t *file, hbool_t *flag);
964 H5_DLL herr_t   H5F_set_mpi_atomicity(H5F_t *file, hbool_t flag);
965 #endif /* H5_HAVE_PARALLEL */
966 
967 /* External file cache routines */
968 H5_DLL herr_t H5F_efc_close(H5F_t *parent, H5F_t *file);
969 
970 /* File prefix routines */
971 H5_DLL H5F_t *H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix_type,
972                                    const char *prop_prefix, const char *file_name, unsigned file_intent,
973                                    hid_t fapl_id);
974 
975 /* Global heap CWFS routines */
976 H5_DLL herr_t H5F_cwfs_add(H5F_t *f, struct H5HG_heap_t *heap);
977 H5_DLL herr_t H5F_cwfs_find_free_heap(H5F_t *f, size_t need, haddr_t *addr);
978 H5_DLL herr_t H5F_cwfs_advance_heap(H5F_t *f, struct H5HG_heap_t *heap, hbool_t add_heap);
979 H5_DLL herr_t H5F_cwfs_remove_heap(H5F_shared_t *shared, struct H5HG_heap_t *heap);
980 
981 /* Debugging functions */
982 H5_DLL herr_t H5F_debug(H5F_t *f, FILE *stream, int indent, int fwidth);
983 
984 #endif /* H5Fprivate_H */
985