Line | Count | Source |
1 | | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
2 | | * Copyright by The HDF Group. * |
3 | | * All rights reserved. * |
4 | | * * |
5 | | * This file is part of HDF5. The full HDF5 copyright notice, including * |
6 | | * terms governing use, modification, and redistribution, is contained in * |
7 | | * the LICENSE file, which can be found at the root of the source code * |
8 | | * distribution tree, or in https://www.hdfgroup.org/licenses. * |
9 | | * If you do not have access to either file, you may request a copy from * |
10 | | * help@hdfgroup.org. * |
11 | | * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
12 | | |
13 | | /*------------------------------------------------------------------------- |
14 | | * |
15 | | * Created: H5Pfcpl.c |
16 | | * |
17 | | * Purpose: File creation property list class routines |
18 | | * |
19 | | *------------------------------------------------------------------------- |
20 | | */ |
21 | | |
22 | | /****************/ |
23 | | /* Module Setup */ |
24 | | /****************/ |
25 | | |
26 | | #include "H5Pmodule.h" /* This source code file is part of the H5P module */ |
27 | | |
28 | | /***********/ |
29 | | /* Headers */ |
30 | | /***********/ |
31 | | #include "H5private.h" /* Generic Functions */ |
32 | | #include "H5Bprivate.h" /* B-tree subclass names */ |
33 | | #include "H5Eprivate.h" /* Error handling */ |
34 | | #include "H5Fprivate.h" /* Files */ |
35 | | #include "H5Ppkg.h" /* Property lists */ |
36 | | |
37 | | /****************/ |
38 | | /* Local Macros */ |
39 | | /****************/ |
40 | | |
41 | | /* ========= File Creation properties ============ */ |
42 | | /* Definitions for the size of the file user block in bytes */ |
43 | 1 | #define H5F_CRT_USER_BLOCK_SIZE sizeof(hsize_t) |
44 | | #define H5F_CRT_USER_BLOCK_DEF 0 |
45 | 1 | #define H5F_CRT_USER_BLOCK_ENC H5P__encode_hsize_t |
46 | 1 | #define H5F_CRT_USER_BLOCK_DEC H5P__decode_hsize_t |
47 | | /* Definitions for the 1/2 rank for symbol table leaf nodes */ |
48 | 1 | #define H5F_CRT_SYM_LEAF_SIZE sizeof(unsigned) |
49 | 1 | #define H5F_CRT_SYM_LEAF_ENC H5P__encode_unsigned |
50 | 1 | #define H5F_CRT_SYM_LEAF_DEC H5P__decode_unsigned |
51 | | /* Definitions for the 1/2 rank for btree internal nodes */ |
52 | 1 | #define H5F_CRT_BTREE_RANK_SIZE sizeof(unsigned[H5B_NUM_BTREE_ID]) |
53 | | #define H5F_CRT_BTREE_RANK_DEF \ |
54 | | { \ |
55 | | HDF5_BTREE_SNODE_IK_DEF, HDF5_BTREE_CHUNK_IK_DEF \ |
56 | | } |
57 | 1 | #define H5F_CRT_BTREE_RANK_ENC H5P__fcrt_btree_rank_enc |
58 | 1 | #define H5F_CRT_BTREE_RANK_DEC H5P__fcrt_btree_rank_dec |
59 | | /* Definitions for byte number in an address */ |
60 | 1 | #define H5F_CRT_ADDR_BYTE_NUM_SIZE sizeof(uint8_t) |
61 | | #define H5F_CRT_ADDR_BYTE_NUM_DEF H5F_OBJ_ADDR_SIZE |
62 | 1 | #define H5F_CRT_ADDR_BYTE_NUM_ENC H5P__encode_uint8_t |
63 | 1 | #define H5F_CRT_ADDR_BYTE_NUM_DEC H5P__decode_uint8_t |
64 | | /* Definitions for byte number for object size */ |
65 | 1 | #define H5F_CRT_OBJ_BYTE_NUM_SIZE sizeof(uint8_t) |
66 | | #define H5F_CRT_OBJ_BYTE_NUM_DEF H5F_OBJ_SIZE_SIZE |
67 | 1 | #define H5F_CRT_OBJ_BYTE_NUM_ENC H5P__encode_uint8_t |
68 | 1 | #define H5F_CRT_OBJ_BYTE_NUM_DEC H5P__decode_uint8_t |
69 | | /* Definitions for version number of the superblock */ |
70 | 1 | #define H5F_CRT_SUPER_VERS_SIZE sizeof(unsigned) |
71 | | #define H5F_CRT_SUPER_VERS_DEF HDF5_SUPERBLOCK_VERSION_DEF |
72 | | /* Definitions for shared object header messages */ |
73 | 1 | #define H5F_CRT_SHMSG_NINDEXES_SIZE sizeof(unsigned) |
74 | | #define H5F_CRT_SHMSG_NINDEXES_DEF (0) |
75 | 1 | #define H5F_CRT_SHMSG_NINDEXES_ENC H5P__encode_unsigned |
76 | 1 | #define H5F_CRT_SHMSG_NINDEXES_DEC H5P__decode_unsigned |
77 | 1 | #define H5F_CRT_SHMSG_INDEX_TYPES_SIZE sizeof(unsigned[H5O_SHMESG_MAX_NINDEXES]) |
78 | | #define H5F_CRT_SHMSG_INDEX_TYPES_DEF \ |
79 | | { \ |
80 | | 0, 0, 0, 0, 0, 0 \ |
81 | | } |
82 | 1 | #define H5F_CRT_SHMSG_INDEX_TYPES_ENC H5P__fcrt_shmsg_index_types_enc |
83 | 1 | #define H5F_CRT_SHMSG_INDEX_TYPES_DEC H5P__fcrt_shmsg_index_types_dec |
84 | 1 | #define H5F_CRT_SHMSG_INDEX_MINSIZE_SIZE sizeof(unsigned[H5O_SHMESG_MAX_NINDEXES]) |
85 | | #define H5F_CRT_SHMSG_INDEX_MINSIZE_DEF \ |
86 | | { \ |
87 | | 250, 250, 250, 250, 250, 250 \ |
88 | | } |
89 | 1 | #define H5F_CRT_SHMSG_INDEX_MINSIZE_ENC H5P__fcrt_shmsg_index_minsize_enc |
90 | 1 | #define H5F_CRT_SHMSG_INDEX_MINSIZE_DEC H5P__fcrt_shmsg_index_minsize_dec |
91 | | /* Definitions for shared object header list/btree phase change cutoffs */ |
92 | 1 | #define H5F_CRT_SHMSG_LIST_MAX_SIZE sizeof(unsigned) |
93 | | #define H5F_CRT_SHMSG_LIST_MAX_DEF (50) |
94 | 1 | #define H5F_CRT_SHMSG_LIST_MAX_ENC H5P__encode_unsigned |
95 | 1 | #define H5F_CRT_SHMSG_LIST_MAX_DEC H5P__decode_unsigned |
96 | 1 | #define H5F_CRT_SHMSG_BTREE_MIN_SIZE sizeof(unsigned) |
97 | | #define H5F_CRT_SHMSG_BTREE_MIN_DEF (40) |
98 | 1 | #define H5F_CRT_SHMSG_BTREE_MIN_ENC H5P__encode_unsigned |
99 | 1 | #define H5F_CRT_SHMSG_BTREE_MIN_DEC H5P__decode_unsigned |
100 | | /* Definitions for file space handling strategy */ |
101 | 1 | #define H5F_CRT_FILE_SPACE_STRATEGY_SIZE sizeof(H5F_fspace_strategy_t) |
102 | | #define H5F_CRT_FILE_SPACE_STRATEGY_DEF H5F_FILE_SPACE_STRATEGY_DEF |
103 | 1 | #define H5F_CRT_FILE_SPACE_STRATEGY_ENC H5P__fcrt_fspace_strategy_enc |
104 | 1 | #define H5F_CRT_FILE_SPACE_STRATEGY_DEC H5P__fcrt_fspace_strategy_dec |
105 | 1 | #define H5F_CRT_FREE_SPACE_PERSIST_SIZE sizeof(bool) |
106 | | #define H5F_CRT_FREE_SPACE_PERSIST_DEF H5F_FREE_SPACE_PERSIST_DEF |
107 | 1 | #define H5F_CRT_FREE_SPACE_PERSIST_ENC H5P__encode_bool |
108 | 1 | #define H5F_CRT_FREE_SPACE_PERSIST_DEC H5P__decode_bool |
109 | 1 | #define H5F_CRT_FREE_SPACE_THRESHOLD_SIZE sizeof(hsize_t) |
110 | | #define H5F_CRT_FREE_SPACE_THRESHOLD_DEF H5F_FREE_SPACE_THRESHOLD_DEF |
111 | 1 | #define H5F_CRT_FREE_SPACE_THRESHOLD_ENC H5P__encode_hsize_t |
112 | 1 | #define H5F_CRT_FREE_SPACE_THRESHOLD_DEC H5P__decode_hsize_t |
113 | | /* Definitions for file space page size in support of level-2 page caching */ |
114 | 1 | #define H5F_CRT_FILE_SPACE_PAGE_SIZE_SIZE sizeof(hsize_t) |
115 | | #define H5F_CRT_FILE_SPACE_PAGE_SIZE_DEF H5F_FILE_SPACE_PAGE_SIZE_DEF |
116 | 1 | #define H5F_CRT_FILE_SPACE_PAGE_SIZE_ENC H5P__encode_hsize_t |
117 | 1 | #define H5F_CRT_FILE_SPACE_PAGE_SIZE_DEC H5P__decode_hsize_t |
118 | | |
119 | | /******************/ |
120 | | /* Local Typedefs */ |
121 | | /******************/ |
122 | | |
123 | | /********************/ |
124 | | /* Package Typedefs */ |
125 | | /********************/ |
126 | | |
127 | | /********************/ |
128 | | /* Local Prototypes */ |
129 | | /********************/ |
130 | | |
131 | | /* Property class callbacks */ |
132 | | static herr_t H5P__fcrt_reg_prop(H5P_genclass_t *pclass); |
133 | | |
134 | | /* property callbacks */ |
135 | | static herr_t H5P__fcrt_btree_rank_enc(const void *value, void **_pp, size_t *size); |
136 | | static herr_t H5P__fcrt_btree_rank_dec(const void **_pp, void *value); |
137 | | static herr_t H5P__fcrt_shmsg_index_types_enc(const void *value, void **_pp, size_t *size); |
138 | | static herr_t H5P__fcrt_shmsg_index_types_dec(const void **_pp, void *value); |
139 | | static herr_t H5P__fcrt_shmsg_index_minsize_enc(const void *value, void **_pp, size_t *size); |
140 | | static herr_t H5P__fcrt_shmsg_index_minsize_dec(const void **_pp, void *value); |
141 | | static herr_t H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size); |
142 | | static herr_t H5P__fcrt_fspace_strategy_dec(const void **_pp, void *_value); |
143 | | |
144 | | /*********************/ |
145 | | /* Package Variables */ |
146 | | /*********************/ |
147 | | |
148 | | /* File creation property list class library initialization object */ |
149 | | const H5P_libclass_t H5P_CLS_FCRT[1] = {{ |
150 | | "file create", /* Class name for debugging */ |
151 | | H5P_TYPE_FILE_CREATE, /* Class type */ |
152 | | |
153 | | &H5P_CLS_GROUP_CREATE_g, /* Parent class */ |
154 | | &H5P_CLS_FILE_CREATE_g, /* Pointer to class */ |
155 | | &H5P_CLS_FILE_CREATE_ID_g, /* Pointer to class ID */ |
156 | | &H5P_LST_FILE_CREATE_ID_g, /* Pointer to default property list ID */ |
157 | | H5P__fcrt_reg_prop, /* Default property registration routine */ |
158 | | |
159 | | NULL, /* Class creation callback */ |
160 | | NULL, /* Class creation callback info */ |
161 | | NULL, /* Class copy callback */ |
162 | | NULL, /* Class copy callback info */ |
163 | | NULL, /* Class close callback */ |
164 | | NULL /* Class close callback info */ |
165 | | }}; |
166 | | |
167 | | /*****************************/ |
168 | | /* Library Private Variables */ |
169 | | /*****************************/ |
170 | | |
171 | | /*******************/ |
172 | | /* Local Variables */ |
173 | | /*******************/ |
174 | | |
175 | | /* Property value defaults */ |
176 | | static const hsize_t H5F_def_userblock_size_g = H5F_CRT_USER_BLOCK_DEF; /* Default userblock size */ |
177 | | static const unsigned H5F_def_sym_leaf_k_g = |
178 | | H5F_CRT_SYM_LEAF_DEF; /* Default size for symbol table leaf nodes */ |
179 | | static const unsigned H5F_def_btree_k_g[H5B_NUM_BTREE_ID] = |
180 | | H5F_CRT_BTREE_RANK_DEF; /* Default 'K' values for B-trees in file */ |
181 | | static const uint8_t H5F_def_sizeof_addr_g = |
182 | | H5F_CRT_ADDR_BYTE_NUM_DEF; /* Default size of addresses in the file */ |
183 | | static const uint8_t H5F_def_sizeof_size_g = H5F_CRT_OBJ_BYTE_NUM_DEF; /* Default size of sizes in the file */ |
184 | | static const unsigned H5F_def_superblock_ver_g = H5F_CRT_SUPER_VERS_DEF; /* Default superblock version # */ |
185 | | static const unsigned H5F_def_num_sohm_indexes_g = H5F_CRT_SHMSG_NINDEXES_DEF; |
186 | | static const unsigned H5F_def_sohm_index_flags_g[H5O_SHMESG_MAX_NINDEXES] = H5F_CRT_SHMSG_INDEX_TYPES_DEF; |
187 | | static const unsigned H5F_def_sohm_index_minsizes_g[H5O_SHMESG_MAX_NINDEXES] = |
188 | | H5F_CRT_SHMSG_INDEX_MINSIZE_DEF; |
189 | | static const unsigned H5F_def_sohm_list_max_g = H5F_CRT_SHMSG_LIST_MAX_DEF; |
190 | | static const unsigned H5F_def_sohm_btree_min_g = H5F_CRT_SHMSG_BTREE_MIN_DEF; |
191 | | static const H5F_fspace_strategy_t H5F_def_file_space_strategy_g = H5F_CRT_FILE_SPACE_STRATEGY_DEF; |
192 | | static const bool H5F_def_free_space_persist_g = H5F_CRT_FREE_SPACE_PERSIST_DEF; |
193 | | static const hsize_t H5F_def_free_space_threshold_g = H5F_CRT_FREE_SPACE_THRESHOLD_DEF; |
194 | | static const hsize_t H5F_def_file_space_page_size_g = H5F_CRT_FILE_SPACE_PAGE_SIZE_DEF; |
195 | | |
196 | | /*------------------------------------------------------------------------- |
197 | | * Function: H5P__fcrt_reg_prop |
198 | | * |
199 | | * Purpose: Register the file creation property list class's properties |
200 | | * |
201 | | * Return: Non-negative on success/Negative on failure |
202 | | * |
203 | | *------------------------------------------------------------------------- |
204 | | */ |
205 | | static herr_t |
206 | | H5P__fcrt_reg_prop(H5P_genclass_t *pclass) |
207 | 1 | { |
208 | 1 | herr_t ret_value = SUCCEED; /* Return value */ |
209 | | |
210 | 1 | FUNC_ENTER_PACKAGE |
211 | | |
212 | | /* Register the user block size */ |
213 | 1 | if (H5P__register_real(pclass, H5F_CRT_USER_BLOCK_NAME, H5F_CRT_USER_BLOCK_SIZE, |
214 | 1 | &H5F_def_userblock_size_g, NULL, NULL, NULL, H5F_CRT_USER_BLOCK_ENC, |
215 | 1 | H5F_CRT_USER_BLOCK_DEC, NULL, NULL, NULL, NULL) < 0) |
216 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
217 | | |
218 | | /* Register the 1/2 rank for symbol table leaf nodes */ |
219 | 1 | if (H5P__register_real(pclass, H5F_CRT_SYM_LEAF_NAME, H5F_CRT_SYM_LEAF_SIZE, &H5F_def_sym_leaf_k_g, NULL, |
220 | 1 | NULL, NULL, H5F_CRT_SYM_LEAF_ENC, H5F_CRT_SYM_LEAF_DEC, NULL, NULL, NULL, |
221 | 1 | NULL) < 0) |
222 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
223 | | |
224 | | /* Register the 1/2 rank for btree internal nodes */ |
225 | 1 | if (H5P__register_real(pclass, H5F_CRT_BTREE_RANK_NAME, H5F_CRT_BTREE_RANK_SIZE, H5F_def_btree_k_g, NULL, |
226 | 1 | NULL, NULL, H5F_CRT_BTREE_RANK_ENC, H5F_CRT_BTREE_RANK_DEC, NULL, NULL, NULL, |
227 | 1 | NULL) < 0) |
228 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
229 | | |
230 | | /* Register the byte number for an address */ |
231 | 1 | if (H5P__register_real(pclass, H5F_CRT_ADDR_BYTE_NUM_NAME, H5F_CRT_ADDR_BYTE_NUM_SIZE, |
232 | 1 | &H5F_def_sizeof_addr_g, NULL, NULL, NULL, H5F_CRT_ADDR_BYTE_NUM_ENC, |
233 | 1 | H5F_CRT_ADDR_BYTE_NUM_DEC, NULL, NULL, NULL, NULL) < 0) |
234 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
235 | | |
236 | | /* Register the byte number for object size */ |
237 | 1 | if (H5P__register_real(pclass, H5F_CRT_OBJ_BYTE_NUM_NAME, H5F_CRT_OBJ_BYTE_NUM_SIZE, |
238 | 1 | &H5F_def_sizeof_size_g, NULL, NULL, NULL, H5F_CRT_OBJ_BYTE_NUM_ENC, |
239 | 1 | H5F_CRT_OBJ_BYTE_NUM_DEC, NULL, NULL, NULL, NULL) < 0) |
240 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
241 | | |
242 | | /* Register the superblock version number */ |
243 | | /* (Note: this property should not have an encode/decode callback -QAK) */ |
244 | 1 | if (H5P__register_real(pclass, H5F_CRT_SUPER_VERS_NAME, H5F_CRT_SUPER_VERS_SIZE, |
245 | 1 | &H5F_def_superblock_ver_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, |
246 | 1 | NULL) < 0) |
247 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
248 | | |
249 | | /* Register the shared OH message information */ |
250 | 1 | if (H5P__register_real(pclass, H5F_CRT_SHMSG_NINDEXES_NAME, H5F_CRT_SHMSG_NINDEXES_SIZE, |
251 | 1 | &H5F_def_num_sohm_indexes_g, NULL, NULL, NULL, H5F_CRT_SHMSG_NINDEXES_ENC, |
252 | 1 | H5F_CRT_SHMSG_NINDEXES_DEC, NULL, NULL, NULL, NULL) < 0) |
253 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
254 | 1 | if (H5P__register_real(pclass, H5F_CRT_SHMSG_INDEX_TYPES_NAME, H5F_CRT_SHMSG_INDEX_TYPES_SIZE, |
255 | 1 | &H5F_def_sohm_index_flags_g, NULL, NULL, NULL, H5F_CRT_SHMSG_INDEX_TYPES_ENC, |
256 | 1 | H5F_CRT_SHMSG_INDEX_TYPES_DEC, NULL, NULL, NULL, NULL) < 0) |
257 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
258 | 1 | if (H5P__register_real(pclass, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, H5F_CRT_SHMSG_INDEX_MINSIZE_SIZE, |
259 | 1 | &H5F_def_sohm_index_minsizes_g, NULL, NULL, NULL, H5F_CRT_SHMSG_INDEX_MINSIZE_ENC, |
260 | 1 | H5F_CRT_SHMSG_INDEX_MINSIZE_DEC, NULL, NULL, NULL, NULL) < 0) |
261 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
262 | | |
263 | | /* Register the shared OH cutoff size information */ |
264 | 1 | if (H5P__register_real(pclass, H5F_CRT_SHMSG_LIST_MAX_NAME, H5F_CRT_SHMSG_LIST_MAX_SIZE, |
265 | 1 | &H5F_def_sohm_list_max_g, NULL, NULL, NULL, H5F_CRT_SHMSG_LIST_MAX_ENC, |
266 | 1 | H5F_CRT_SHMSG_LIST_MAX_DEC, NULL, NULL, NULL, NULL) < 0) |
267 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
268 | 1 | if (H5P__register_real(pclass, H5F_CRT_SHMSG_BTREE_MIN_NAME, H5F_CRT_SHMSG_BTREE_MIN_SIZE, |
269 | 1 | &H5F_def_sohm_btree_min_g, NULL, NULL, NULL, H5F_CRT_SHMSG_BTREE_MIN_ENC, |
270 | 1 | H5F_CRT_SHMSG_BTREE_MIN_DEC, NULL, NULL, NULL, NULL) < 0) |
271 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
272 | | |
273 | | /* Register the file space handling strategy */ |
274 | 1 | if (H5P__register_real(pclass, H5F_CRT_FILE_SPACE_STRATEGY_NAME, H5F_CRT_FILE_SPACE_STRATEGY_SIZE, |
275 | 1 | &H5F_def_file_space_strategy_g, NULL, NULL, NULL, H5F_CRT_FILE_SPACE_STRATEGY_ENC, |
276 | 1 | H5F_CRT_FILE_SPACE_STRATEGY_DEC, NULL, NULL, NULL, NULL) < 0) |
277 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
278 | | |
279 | | /* Register the free-space persist flag */ |
280 | 1 | if (H5P__register_real(pclass, H5F_CRT_FREE_SPACE_PERSIST_NAME, H5F_CRT_FREE_SPACE_PERSIST_SIZE, |
281 | 1 | &H5F_def_free_space_persist_g, NULL, NULL, NULL, H5F_CRT_FREE_SPACE_PERSIST_ENC, |
282 | 1 | H5F_CRT_FREE_SPACE_PERSIST_DEC, NULL, NULL, NULL, NULL) < 0) |
283 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
284 | | |
285 | | /* Register the free space section threshold */ |
286 | 1 | if (H5P__register_real(pclass, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, H5F_CRT_FREE_SPACE_THRESHOLD_SIZE, |
287 | 1 | &H5F_def_free_space_threshold_g, NULL, NULL, NULL, |
288 | 1 | H5F_CRT_FREE_SPACE_THRESHOLD_ENC, H5F_CRT_FREE_SPACE_THRESHOLD_DEC, NULL, NULL, |
289 | 1 | NULL, NULL) < 0) |
290 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
291 | | |
292 | | /* Register the file space page size */ |
293 | 1 | if (H5P__register_real(pclass, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, H5F_CRT_FILE_SPACE_PAGE_SIZE_SIZE, |
294 | 1 | &H5F_def_file_space_page_size_g, NULL, NULL, NULL, |
295 | 1 | H5F_CRT_FILE_SPACE_PAGE_SIZE_ENC, H5F_CRT_FILE_SPACE_PAGE_SIZE_DEC, NULL, NULL, |
296 | 1 | NULL, NULL) < 0) |
297 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class"); |
298 | | |
299 | 1 | done: |
300 | 1 | FUNC_LEAVE_NOAPI(ret_value) |
301 | 1 | } /* end H5P__fcrt_reg_prop() */ |
302 | | |
303 | | /*------------------------------------------------------------------------- |
304 | | * Function: H5Pset_userblock |
305 | | * |
306 | | * Purpose: Sets the userblock size field of a file creation property |
307 | | * list. |
308 | | * |
309 | | * Return: Non-negative on success/Negative on failure |
310 | | * |
311 | | *------------------------------------------------------------------------- |
312 | | */ |
313 | | herr_t |
314 | | H5Pset_userblock(hid_t plist_id, hsize_t size) |
315 | 0 | { |
316 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
317 | 0 | herr_t ret_value = SUCCEED; /* return value */ |
318 | |
|
319 | 0 | FUNC_ENTER_API(FAIL) |
320 | | |
321 | | /* Sanity check non-zero userblock sizes */ |
322 | 0 | if (size > 0) { |
323 | | /* Check that the userblock size is >=512 */ |
324 | 0 | if (size < 512) |
325 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is non-zero and less than 512"); |
326 | | |
327 | | /* Check that the userblock size is a power of two */ |
328 | 0 | if (!POWER_OF_TWO(size)) |
329 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "userblock size is non-zero and not a power of two"); |
330 | 0 | } /* end if */ |
331 | | |
332 | | /* Get the plist structure */ |
333 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, false))) |
334 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
335 | | |
336 | | /* Set value */ |
337 | 0 | if (H5P_set(plist, H5F_CRT_USER_BLOCK_NAME, &size) < 0) |
338 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set user block"); |
339 | | |
340 | 0 | done: |
341 | 0 | FUNC_LEAVE_API(ret_value) |
342 | 0 | } /* end H5Pset_userblock() */ |
343 | | |
344 | | /*------------------------------------------------------------------------- |
345 | | * Function: H5Pget_userblock |
346 | | * |
347 | | * Purpose: Queries the size of a user block in a file creation property |
348 | | * list. |
349 | | * |
350 | | * Return: Success: Non-negative, size returned through SIZE argument. |
351 | | * |
352 | | * Failure: Negative |
353 | | * |
354 | | *------------------------------------------------------------------------- |
355 | | */ |
356 | | herr_t |
357 | | H5Pget_userblock(hid_t plist_id, hsize_t *size /*out*/) |
358 | 0 | { |
359 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
360 | 0 | herr_t ret_value = SUCCEED; /* return value */ |
361 | |
|
362 | 0 | FUNC_ENTER_API(FAIL) |
363 | | |
364 | | /* Get the plist structure */ |
365 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, true))) |
366 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
367 | | |
368 | | /* Get value */ |
369 | 0 | if (size) |
370 | 0 | if (H5P_get(plist, H5F_CRT_USER_BLOCK_NAME, size) < 0) |
371 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get user block"); |
372 | | |
373 | 0 | done: |
374 | 0 | FUNC_LEAVE_API(ret_value) |
375 | 0 | } |
376 | | |
377 | | /*------------------------------------------------------------------------- |
378 | | * Function: H5Pset_sizes |
379 | | * |
380 | | * Purpose: Sets file size-of addresses and sizes. PLIST_ID should be a |
381 | | * file creation property list. A value of zero causes the |
382 | | * property to not change. |
383 | | * |
384 | | * Return: Non-negative on success/Negative on failure |
385 | | * |
386 | | *------------------------------------------------------------------------- |
387 | | */ |
388 | | herr_t |
389 | | H5Pset_sizes(hid_t plist_id, size_t sizeof_addr, size_t sizeof_size) |
390 | 0 | { |
391 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
392 | 0 | herr_t ret_value = SUCCEED; /* return value */ |
393 | |
|
394 | 0 | FUNC_ENTER_API(FAIL) |
395 | | |
396 | | /* Check arguments */ |
397 | 0 | if (sizeof_addr) { |
398 | 0 | if (sizeof_addr != 2 && sizeof_addr != 4 && sizeof_addr != 8 && sizeof_addr != 16) |
399 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file haddr_t size is not valid"); |
400 | 0 | } /* end if */ |
401 | 0 | if (sizeof_size) { |
402 | 0 | if (sizeof_size != 2 && sizeof_size != 4 && sizeof_size != 8 && sizeof_size != 16) |
403 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "file size_t size is not valid"); |
404 | 0 | } /* end if */ |
405 | | |
406 | | /* Get the plist structure */ |
407 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, false))) |
408 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
409 | | |
410 | | /* Set value */ |
411 | 0 | if (sizeof_addr) { |
412 | 0 | uint8_t tmp_sizeof_addr = (uint8_t)sizeof_addr; |
413 | |
|
414 | 0 | if (H5P_set(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &tmp_sizeof_addr) < 0) |
415 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for an address"); |
416 | 0 | } /* end if */ |
417 | 0 | if (sizeof_size) { |
418 | 0 | uint8_t tmp_sizeof_size = (uint8_t)sizeof_size; |
419 | |
|
420 | 0 | if (H5P_set(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &tmp_sizeof_size) < 0) |
421 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set byte number for object "); |
422 | 0 | } /* end if */ |
423 | | |
424 | 0 | done: |
425 | 0 | FUNC_LEAVE_API(ret_value) |
426 | 0 | } /* end H5Pset_sizes() */ |
427 | | |
428 | | /*------------------------------------------------------------------------- |
429 | | * Function: H5Pget_sizes |
430 | | * |
431 | | * Purpose: Returns the size of address and size quantities stored in a |
432 | | * file according to a file creation property list. Either (or |
433 | | * even both) SIZEOF_ADDR and SIZEOF_SIZE may be null pointers. |
434 | | * |
435 | | * Return: Success: Non-negative, sizes returned through arguments. |
436 | | * Failure: Negative |
437 | | * |
438 | | *------------------------------------------------------------------------- |
439 | | */ |
440 | | herr_t |
441 | | H5Pget_sizes(hid_t plist_id, size_t *sizeof_addr /*out*/, size_t *sizeof_size /*out*/) |
442 | 0 | { |
443 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
444 | 0 | herr_t ret_value = SUCCEED; /* return value */ |
445 | |
|
446 | 0 | FUNC_ENTER_API(FAIL) |
447 | | |
448 | | /* Get the plist structure */ |
449 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, true))) |
450 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
451 | | |
452 | | /* Get values */ |
453 | 0 | if (sizeof_addr) { |
454 | 0 | uint8_t tmp_sizeof_addr; |
455 | |
|
456 | 0 | if (H5P_get(plist, H5F_CRT_ADDR_BYTE_NUM_NAME, &tmp_sizeof_addr) < 0) |
457 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for an address"); |
458 | 0 | *sizeof_addr = tmp_sizeof_addr; |
459 | 0 | } /* end if */ |
460 | 0 | if (sizeof_size) { |
461 | 0 | uint8_t tmp_sizeof_size; |
462 | |
|
463 | 0 | if (H5P_get(plist, H5F_CRT_OBJ_BYTE_NUM_NAME, &tmp_sizeof_size) < 0) |
464 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get byte number for object "); |
465 | 0 | *sizeof_size = tmp_sizeof_size; |
466 | 0 | } /* end if */ |
467 | | |
468 | 0 | done: |
469 | 0 | FUNC_LEAVE_API(ret_value) |
470 | 0 | } /* end H5Pget_sizes() */ |
471 | | |
472 | | /*------------------------------------------------------------------------- |
473 | | * Function: H5Pset_sym_k |
474 | | * |
475 | | * Purpose: IK is one half the rank of a tree that stores a symbol |
476 | | * table for a group. Internal nodes of the symbol table are on |
477 | | * average 75% full. That is, the average rank of the tree is |
478 | | * 1.5 times the value of IK. |
479 | | * |
480 | | * LK is one half of the number of symbols that can be stored in |
481 | | * a symbol table node. A symbol table node is the leaf of a |
482 | | * symbol table tree which is used to store a group. When |
483 | | * symbols are inserted randomly into a group, the group's |
484 | | * symbol table nodes are 75% full on average. That is, they |
485 | | * contain 1.5 times the number of symbols specified by LK. |
486 | | * |
487 | | * Either (or even both) of IK and LK can be zero in which case |
488 | | * that value is left unchanged. |
489 | | * |
490 | | * Return: Non-negative on success/Negative on failure |
491 | | * |
492 | | *------------------------------------------------------------------------- |
493 | | */ |
494 | | herr_t |
495 | | H5Pset_sym_k(hid_t plist_id, unsigned ik, unsigned lk) |
496 | 0 | { |
497 | 0 | unsigned btree_k[H5B_NUM_BTREE_ID]; |
498 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
499 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
500 | |
|
501 | 0 | FUNC_ENTER_API(FAIL) |
502 | | |
503 | | /* Get the plist structure */ |
504 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, false))) |
505 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
506 | | |
507 | | /* Set values */ |
508 | 0 | if (ik > 0) { |
509 | 0 | if ((ik * 2) >= HDF5_BTREE_IK_MAX_ENTRIES) |
510 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "istore IK value exceeds maximum B-tree entries"); |
511 | | |
512 | 0 | if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) |
513 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree internal nodes"); |
514 | 0 | btree_k[H5B_SNODE_ID] = ik; |
515 | 0 | if (H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) |
516 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for btree nodes"); |
517 | 0 | } |
518 | 0 | if (lk > 0) |
519 | 0 | if (H5P_set(plist, H5F_CRT_SYM_LEAF_NAME, &lk) < 0) |
520 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for symbol table leaf nodes"); |
521 | | |
522 | 0 | done: |
523 | 0 | FUNC_LEAVE_API(ret_value) |
524 | 0 | } |
525 | | |
526 | | /*------------------------------------------------------------------------- |
527 | | * Function: H5Pget_sym_k |
528 | | * |
529 | | * Purpose: Retrieves the symbol table B-tree 1/2 rank (IK) and the |
530 | | * symbol table leaf node 1/2 size (LK). See H5Pset_sym_k() for |
531 | | * details. Either (or even both) IK and LK may be null |
532 | | * pointers. |
533 | | * |
534 | | * Return: Non-negative on success/Negative on failure |
535 | | * |
536 | | *------------------------------------------------------------------------- |
537 | | */ |
538 | | herr_t |
539 | | H5Pget_sym_k(hid_t plist_id, unsigned *ik /*out*/, unsigned *lk /*out*/) |
540 | 0 | { |
541 | 0 | unsigned btree_k[H5B_NUM_BTREE_ID]; |
542 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
543 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
544 | |
|
545 | 0 | FUNC_ENTER_API(FAIL) |
546 | | |
547 | | /* Get the plist structure */ |
548 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, true))) |
549 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
550 | | |
551 | | /* Get values */ |
552 | 0 | if (ik) { |
553 | 0 | if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) |
554 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree nodes"); |
555 | 0 | *ik = btree_k[H5B_SNODE_ID]; |
556 | 0 | } |
557 | 0 | if (lk) |
558 | 0 | if (H5P_get(plist, H5F_CRT_SYM_LEAF_NAME, lk) < 0) |
559 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for symbol table leaf nodes"); |
560 | | |
561 | 0 | done: |
562 | 0 | FUNC_LEAVE_API(ret_value) |
563 | 0 | } |
564 | | |
565 | | /*------------------------------------------------------------------------- |
566 | | * Function: H5Pset_istore_k |
567 | | * |
568 | | * Purpose: IK is one half the rank of a tree that stores chunked raw |
569 | | * data. On average, such a tree will be 75% full, or have an |
570 | | * average rank of 1.5 times the value of IK. |
571 | | * |
572 | | * Return: Non-negative on success/Negative on failure |
573 | | * |
574 | | *------------------------------------------------------------------------- |
575 | | */ |
576 | | herr_t |
577 | | H5Pset_istore_k(hid_t plist_id, unsigned ik) |
578 | 0 | { |
579 | 0 | unsigned btree_k[H5B_NUM_BTREE_ID]; |
580 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
581 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
582 | |
|
583 | 0 | FUNC_ENTER_API(FAIL) |
584 | | |
585 | | /* Check arguments */ |
586 | 0 | if (ik == 0) |
587 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "istore IK value must be positive"); |
588 | | |
589 | 0 | if ((ik * 2) >= HDF5_BTREE_IK_MAX_ENTRIES) |
590 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "istore IK value exceeds maximum B-tree entries"); |
591 | | |
592 | | /* Get the plist structure */ |
593 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, false))) |
594 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
595 | | |
596 | | /* Set value */ |
597 | 0 | if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) |
598 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree internal nodes"); |
599 | 0 | btree_k[H5B_CHUNK_ID] = ik; |
600 | 0 | if (H5P_set(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) |
601 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set rank for btree internal nodes"); |
602 | | |
603 | 0 | done: |
604 | 0 | FUNC_LEAVE_API(ret_value) |
605 | 0 | } |
606 | | |
607 | | /*------------------------------------------------------------------------- |
608 | | * Function: H5Pget_istore_k |
609 | | * |
610 | | * Purpose: Queries the 1/2 rank of an indexed storage B-tree. See |
611 | | * H5Pset_istore_k() for details. The argument IK may be the |
612 | | * null pointer. |
613 | | * |
614 | | * Return: Success: Non-negative, size returned through IK |
615 | | * |
616 | | * Failure: Negative |
617 | | * |
618 | | *------------------------------------------------------------------------- |
619 | | */ |
620 | | herr_t |
621 | | H5Pget_istore_k(hid_t plist_id, unsigned *ik /*out*/) |
622 | 0 | { |
623 | 0 | unsigned btree_k[H5B_NUM_BTREE_ID]; |
624 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
625 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
626 | |
|
627 | 0 | FUNC_ENTER_API(FAIL) |
628 | | |
629 | | /* Get the plist structure */ |
630 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, true))) |
631 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
632 | | |
633 | | /* Get value */ |
634 | 0 | if (ik) { |
635 | 0 | if (H5P_get(plist, H5F_CRT_BTREE_RANK_NAME, btree_k) < 0) |
636 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get rank for btree internal nodes"); |
637 | 0 | *ik = btree_k[H5B_CHUNK_ID]; |
638 | 0 | } /* end if */ |
639 | | |
640 | 0 | done: |
641 | 0 | FUNC_LEAVE_API(ret_value) |
642 | 0 | } /* end H5Pget_istore_k() */ |
643 | | |
644 | | /*------------------------------------------------------------------------- |
645 | | * Function: H5P__fcrt_btree_rank_enc |
646 | | * |
647 | | * Purpose: Callback routine which is called whenever the index storage |
648 | | * btree in a file creation property list is encoded. |
649 | | * |
650 | | * Return: Success: Non-negative |
651 | | * Failure: Negative |
652 | | * |
653 | | *------------------------------------------------------------------------- |
654 | | */ |
655 | | static herr_t |
656 | | H5P__fcrt_btree_rank_enc(const void *value, void **_pp, size_t *size) |
657 | 0 | { |
658 | 0 | const unsigned *btree_k = (const unsigned *)value; /* Create local alias for values */ |
659 | 0 | uint8_t **pp = (uint8_t **)_pp; |
660 | |
|
661 | 0 | FUNC_ENTER_PACKAGE_NOERR |
662 | | |
663 | | /* Sanity check */ |
664 | 0 | assert(btree_k); |
665 | 0 | assert(size); |
666 | |
|
667 | 0 | if (NULL != *pp) { |
668 | 0 | unsigned u; /* Local index variable */ |
669 | | |
670 | | /* Encode the size of an unsigned*/ |
671 | 0 | *(*pp)++ = (uint8_t)sizeof(unsigned); |
672 | | |
673 | | /* Encode all the btree */ |
674 | 0 | for (u = 0; u < H5B_NUM_BTREE_ID; u++) { |
675 | | /* Encode the left split value */ |
676 | 0 | H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)btree_k); |
677 | 0 | btree_k++; |
678 | 0 | } /* end for */ |
679 | 0 | } /* end if */ |
680 | | |
681 | | /* Size of type flags values */ |
682 | 0 | *size += 1 + (H5B_NUM_BTREE_ID * sizeof(unsigned)); |
683 | |
|
684 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
685 | 0 | } /* end H5P__fcrt_btree_rank_enc() */ |
686 | | |
687 | | /*------------------------------------------------------------------------- |
688 | | * Function: H5P__fcrt_btree_rank_dec |
689 | | * |
690 | | * Purpose: Callback routine which is called whenever the index storage |
691 | | * btree in a file creation property list is decoded. |
692 | | * |
693 | | * Return: Success: Non-negative |
694 | | * Failure: Negative |
695 | | * |
696 | | *------------------------------------------------------------------------- |
697 | | */ |
698 | | static herr_t |
699 | | H5P__fcrt_btree_rank_dec(const void **_pp, void *_value) |
700 | 0 | { |
701 | 0 | unsigned *btree_k = (unsigned *)_value; |
702 | 0 | const uint8_t **pp = (const uint8_t **)_pp; |
703 | 0 | unsigned enc_size; /* Size of encoded property */ |
704 | 0 | unsigned u; /* Local index variable */ |
705 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
706 | |
|
707 | 0 | FUNC_ENTER_PACKAGE |
708 | | |
709 | | /* Sanity checks */ |
710 | 0 | assert(pp); |
711 | 0 | assert(*pp); |
712 | 0 | assert(btree_k); |
713 | | |
714 | | /* Decode the size */ |
715 | 0 | enc_size = *(*pp)++; |
716 | 0 | if (enc_size != sizeof(unsigned)) |
717 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded"); |
718 | | |
719 | | /* Decode all the type flags */ |
720 | 0 | for (u = 0; u < H5B_NUM_BTREE_ID; u++) |
721 | 0 | H5_DECODE_UNSIGNED(*pp, btree_k[u]); |
722 | |
|
723 | 0 | done: |
724 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
725 | 0 | } /* end H5P__fcrt_btree_rank_dec() */ |
726 | | |
727 | | /*------------------------------------------------------------------------- |
728 | | * Function: H5Pset_shared_mesg_nindexes |
729 | | * |
730 | | * Purpose: Set the number of Shared Object Header Message (SOHM) |
731 | | * indexes specified in this property list. If this is |
732 | | * zero then shared object header messages are disabled |
733 | | * for this file. |
734 | | * |
735 | | * These indexes can then be configured with |
736 | | * H5Pset_shared_mesg_index. H5Pset_shared_mesg_phase_chage |
737 | | * also controls settings for all indexes. |
738 | | * |
739 | | * Return: Non-negative on success/Negative on failure |
740 | | * |
741 | | *------------------------------------------------------------------------- |
742 | | */ |
743 | | herr_t |
744 | | H5Pset_shared_mesg_nindexes(hid_t plist_id, unsigned nindexes) |
745 | 0 | { |
746 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
747 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
748 | |
|
749 | 0 | FUNC_ENTER_API(FAIL) |
750 | | |
751 | | /* Check argument */ |
752 | 0 | if (nindexes > H5O_SHMESG_MAX_NINDEXES) |
753 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, |
754 | 0 | "number of indexes is greater than H5O_SHMESG_MAX_NINDEXES"); |
755 | | |
756 | | /* Get the plist structure */ |
757 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, false))) |
758 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
759 | | |
760 | 0 | if (H5P_set(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) |
761 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set number of indexes"); |
762 | | |
763 | 0 | done: |
764 | 0 | FUNC_LEAVE_API(ret_value) |
765 | 0 | } /* end H5Pset_shared_mesg_nindexes() */ |
766 | | |
767 | | /*------------------------------------------------------------------------- |
768 | | * Function: H5Pget_shared_mesg_nindexes |
769 | | * |
770 | | * Purpose: Get the number of Shared Object Header Message (SOHM) |
771 | | * indexes specified in this property list. |
772 | | * |
773 | | * Return: Non-negative on success/Negative on failure |
774 | | * |
775 | | *------------------------------------------------------------------------- |
776 | | */ |
777 | | herr_t |
778 | | H5Pget_shared_mesg_nindexes(hid_t plist_id, unsigned *nindexes /*out*/) |
779 | 0 | { |
780 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
781 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
782 | |
|
783 | 0 | FUNC_ENTER_API(FAIL) |
784 | | |
785 | | /* Get the plist structure */ |
786 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, true))) |
787 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
788 | | |
789 | 0 | if (H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, nindexes) < 0) |
790 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of indexes"); |
791 | | |
792 | 0 | done: |
793 | 0 | FUNC_LEAVE_API(ret_value) |
794 | 0 | } /* end H5Pget_shared_mesg_nindexes() */ |
795 | | |
796 | | /*------------------------------------------------------------------------- |
797 | | * Function: H5Pset_shared_mesg_index |
798 | | * |
799 | | * Purpose: Configure a given shared message index. Sets the types of |
800 | | * message that should be stored in this index and the minimum |
801 | | * size of a message in the index. |
802 | | * |
803 | | * INDEX_NUM is zero-indexed (in a file with three indexes, |
804 | | * they are numbered 0, 1, and 2). |
805 | | * |
806 | | * Return: Non-negative on success/Negative on failure |
807 | | * |
808 | | *------------------------------------------------------------------------- |
809 | | */ |
810 | | herr_t |
811 | | H5Pset_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned mesg_type_flags, unsigned min_mesg_size) |
812 | 0 | { |
813 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
814 | 0 | unsigned nindexes; /* Number of SOHM indexes */ |
815 | 0 | unsigned type_flags[H5O_SHMESG_MAX_NINDEXES]; /* Array of mesg_type_flags*/ |
816 | 0 | unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Array of min_mesg_sizes*/ |
817 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
818 | |
|
819 | 0 | FUNC_ENTER_API(FAIL) |
820 | | |
821 | | /* Check arguments */ |
822 | 0 | if (mesg_type_flags > H5O_SHMESG_ALL_FLAG) |
823 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "unrecognized flags in mesg_type_flags"); |
824 | | |
825 | | /* Get the plist structure */ |
826 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, false))) |
827 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
828 | | |
829 | | /* Read the current number of indexes */ |
830 | 0 | if (H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) |
831 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of indexes"); |
832 | | |
833 | | /* Range check */ |
834 | 0 | if (index_num >= nindexes) |
835 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "index_num is too large; no such index"); |
836 | | |
837 | | /* Get arrays of type flags and message sizes */ |
838 | 0 | if (H5P_get(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) |
839 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current index type flags"); |
840 | 0 | if (H5P_get(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) |
841 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current min sizes"); |
842 | | |
843 | | /* Set values in arrays */ |
844 | 0 | type_flags[index_num] = mesg_type_flags; |
845 | 0 | minsizes[index_num] = min_mesg_size; |
846 | | |
847 | | /* Write arrays back to plist */ |
848 | 0 | if (H5P_set(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) |
849 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set index type flags"); |
850 | 0 | if (H5P_set(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) |
851 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set min mesg sizes"); |
852 | | |
853 | 0 | done: |
854 | 0 | FUNC_LEAVE_API(ret_value) |
855 | 0 | } /* end H5Pset_shared_mesg_index() */ |
856 | | |
857 | | /*------------------------------------------------------------------------- |
858 | | * Function: H5Pget_shared_mesg_index |
859 | | * |
860 | | * Purpose: Get information about a given shared message index. Gets |
861 | | * the types of message that are stored in the index and the |
862 | | * minimum size of a message in the index. |
863 | | * |
864 | | * Return: Non-negative on success/Negative on failure |
865 | | * |
866 | | *------------------------------------------------------------------------- |
867 | | */ |
868 | | herr_t |
869 | | H5Pget_shared_mesg_index(hid_t plist_id, unsigned index_num, unsigned *mesg_type_flags /*out*/, |
870 | | unsigned *min_mesg_size /*out*/) |
871 | 0 | { |
872 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
873 | 0 | unsigned nindexes; /* Number of SOHM indexes */ |
874 | 0 | unsigned type_flags[H5O_SHMESG_MAX_NINDEXES]; /* Array of mesg_type_flags*/ |
875 | 0 | unsigned minsizes[H5O_SHMESG_MAX_NINDEXES]; /* Array of min_mesg_sizes*/ |
876 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
877 | |
|
878 | 0 | FUNC_ENTER_API(FAIL) |
879 | | |
880 | | /* Get the plist structure */ |
881 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, true))) |
882 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
883 | | |
884 | | /* Read the current number of indexes */ |
885 | 0 | if (H5P_get(plist, H5F_CRT_SHMSG_NINDEXES_NAME, &nindexes) < 0) |
886 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get number of indexes"); |
887 | | |
888 | 0 | if (index_num >= nindexes) |
889 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, |
890 | 0 | "index_num is greater than number of indexes in property list"); |
891 | | |
892 | | /* Get arrays of type flags and message sizes */ |
893 | 0 | if (H5P_get(plist, H5F_CRT_SHMSG_INDEX_TYPES_NAME, type_flags) < 0) |
894 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current index type flags"); |
895 | 0 | if (H5P_get(plist, H5F_CRT_SHMSG_INDEX_MINSIZE_NAME, minsizes) < 0) |
896 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get current min sizes"); |
897 | | |
898 | | /* Get values from arrays */ |
899 | 0 | if (mesg_type_flags) |
900 | 0 | *mesg_type_flags = type_flags[index_num]; |
901 | 0 | if (min_mesg_size) |
902 | 0 | *min_mesg_size = minsizes[index_num]; |
903 | |
|
904 | 0 | done: |
905 | 0 | FUNC_LEAVE_API(ret_value) |
906 | 0 | } /* end H5Pset_shared_mesg_index() */ |
907 | | |
908 | | /*------------------------------------------------------------------------- |
909 | | * Function: H5P__fcrt_shmsg_index_types_enc |
910 | | * |
911 | | * Purpose: Callback routine which is called whenever the shared |
912 | | * message index types in a file creation property list |
913 | | * are encoded. |
914 | | * |
915 | | * Return: Success: Non-negative |
916 | | * Failure: Negative |
917 | | * |
918 | | *------------------------------------------------------------------------- |
919 | | */ |
920 | | static herr_t |
921 | | H5P__fcrt_shmsg_index_types_enc(const void *value, void **_pp, size_t *size) |
922 | 0 | { |
923 | 0 | const unsigned *type_flags = (const unsigned *)value; /* Create local alias for values */ |
924 | 0 | uint8_t **pp = (uint8_t **)_pp; |
925 | |
|
926 | 0 | FUNC_ENTER_PACKAGE_NOERR |
927 | | |
928 | | /* Sanity check */ |
929 | 0 | assert(type_flags); |
930 | 0 | assert(size); |
931 | |
|
932 | 0 | if (NULL != *pp) { |
933 | 0 | unsigned u; /* Local index variable */ |
934 | | |
935 | | /* Encode the size of a double*/ |
936 | 0 | *(*pp)++ = (uint8_t)sizeof(unsigned); |
937 | | |
938 | | /* Encode all the type flags */ |
939 | 0 | for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) { |
940 | | /* Encode the left split value */ |
941 | 0 | H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)type_flags); |
942 | 0 | type_flags++; |
943 | 0 | } /* end for */ |
944 | 0 | } /* end if */ |
945 | | |
946 | | /* Size of type flags values */ |
947 | 0 | *size += 1 + (H5O_SHMESG_MAX_NINDEXES * sizeof(unsigned)); |
948 | |
|
949 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
950 | 0 | } /* end H5P__fcrt_shmsg_index_types_enc() */ |
951 | | |
952 | | /*------------------------------------------------------------------------- |
953 | | * Function: H5P__fcrt_shmsg_index_types_dec |
954 | | * |
955 | | * Purpose: Callback routine which is called whenever the shared |
956 | | * message index types in a file creation property list |
957 | | * are decoded. |
958 | | * |
959 | | * Return: Success: Non-negative |
960 | | * Failure: Negative |
961 | | * |
962 | | *------------------------------------------------------------------------- |
963 | | */ |
964 | | static herr_t |
965 | | H5P__fcrt_shmsg_index_types_dec(const void **_pp, void *_value) |
966 | 0 | { |
967 | 0 | unsigned *type_flags = (unsigned *)_value; |
968 | 0 | const uint8_t **pp = (const uint8_t **)_pp; |
969 | 0 | unsigned enc_size; /* Size of encoded property */ |
970 | 0 | unsigned u; /* Local index variable */ |
971 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
972 | |
|
973 | 0 | FUNC_ENTER_PACKAGE |
974 | | |
975 | | /* Sanity checks */ |
976 | 0 | assert(pp); |
977 | 0 | assert(*pp); |
978 | 0 | assert(type_flags); |
979 | | |
980 | | /* Decode the size */ |
981 | 0 | enc_size = *(*pp)++; |
982 | 0 | if (enc_size != sizeof(unsigned)) |
983 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded"); |
984 | | |
985 | | /* Decode all the type flags */ |
986 | 0 | for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) |
987 | 0 | H5_DECODE_UNSIGNED(*pp, type_flags[u]); |
988 | |
|
989 | 0 | done: |
990 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
991 | 0 | } /* end H5P__fcrt_shmsg_index_types_dec() */ |
992 | | |
993 | | /*------------------------------------------------------------------------- |
994 | | * Function: H5P__fcrt_shmsg_index_minsize_enc |
995 | | * |
996 | | * Purpose: Callback routine which is called whenever the shared |
997 | | * message index minsize in a file creation property list |
998 | | * is encoded. |
999 | | * |
1000 | | * Return: Success: Non-negative |
1001 | | * Failure: Negative |
1002 | | * |
1003 | | *------------------------------------------------------------------------- |
1004 | | */ |
1005 | | static herr_t |
1006 | | H5P__fcrt_shmsg_index_minsize_enc(const void *value, void **_pp, size_t *size) |
1007 | 0 | { |
1008 | 0 | const unsigned *minsizes = (const unsigned *)value; /* Create local alias for values */ |
1009 | 0 | uint8_t **pp = (uint8_t **)_pp; |
1010 | |
|
1011 | 0 | FUNC_ENTER_PACKAGE_NOERR |
1012 | | |
1013 | | /* Sanity check */ |
1014 | 0 | assert(minsizes); |
1015 | 0 | assert(size); |
1016 | |
|
1017 | 0 | if (NULL != *pp) { |
1018 | 0 | unsigned u; /* Local index variable */ |
1019 | | |
1020 | | /* Encode the size of a double*/ |
1021 | 0 | *(*pp)++ = (uint8_t)sizeof(unsigned); |
1022 | | |
1023 | | /* Encode all the minsize values */ |
1024 | 0 | for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) { |
1025 | | /* Encode the left split value */ |
1026 | 0 | H5_ENCODE_UNSIGNED(*pp, *(const unsigned *)minsizes); |
1027 | 0 | minsizes++; |
1028 | 0 | } /* end for */ |
1029 | 0 | } /* end if */ |
1030 | | |
1031 | | /* Size of type flags values */ |
1032 | 0 | *size += 1 + (H5O_SHMESG_MAX_NINDEXES * sizeof(unsigned)); |
1033 | |
|
1034 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
1035 | 0 | } /* end H5P__fcrt_shmsg_index_minsize_enc() */ |
1036 | | |
1037 | | /*------------------------------------------------------------------------- |
1038 | | * Function: H5P__fcrt_shmsg_index_minsize_dec |
1039 | | * |
1040 | | * Purpose: Callback routine which is called whenever the shared |
1041 | | * message index minsize in a file creation property list |
1042 | | * is decoded. |
1043 | | * |
1044 | | * Return: Success: Non-negative |
1045 | | * Failure: Negative |
1046 | | * |
1047 | | *------------------------------------------------------------------------- |
1048 | | */ |
1049 | | static herr_t |
1050 | | H5P__fcrt_shmsg_index_minsize_dec(const void **_pp, void *_value) |
1051 | 0 | { |
1052 | 0 | unsigned *minsizes = (unsigned *)_value; |
1053 | 0 | const uint8_t **pp = (const uint8_t **)_pp; |
1054 | 0 | unsigned enc_size; /* Size of encoded property */ |
1055 | 0 | unsigned u; /* Local index variable */ |
1056 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1057 | |
|
1058 | 0 | FUNC_ENTER_PACKAGE |
1059 | | |
1060 | | /* Sanity checks */ |
1061 | 0 | assert(pp); |
1062 | 0 | assert(*pp); |
1063 | 0 | assert(minsizes); |
1064 | | |
1065 | | /* Decode the size */ |
1066 | 0 | enc_size = *(*pp)++; |
1067 | 0 | if (enc_size != sizeof(unsigned)) |
1068 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded"); |
1069 | | |
1070 | | /* Decode all the minsize values */ |
1071 | 0 | for (u = 0; u < H5O_SHMESG_MAX_NINDEXES; u++) |
1072 | 0 | H5_DECODE_UNSIGNED(*pp, minsizes[u]); |
1073 | |
|
1074 | 0 | done: |
1075 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
1076 | 0 | } /* end H5P__fcrt_shmsg_index_minsize_dec() */ |
1077 | | |
1078 | | /*------------------------------------------------------------------------- |
1079 | | * Function: H5Pset_shared_mesg_phase_change |
1080 | | * |
1081 | | * Purpose: Sets the cutoff values for indexes storing shared object |
1082 | | * header messages in this file. If more than max_list |
1083 | | * messages are in an index, that index will become a B-tree. |
1084 | | * Likewise, a B-tree index containing fewer than min_btree |
1085 | | * messages will be converted to a list. |
1086 | | * |
1087 | | * If the max_list is zero then SOHM indexes in this file will |
1088 | | * never be lists but will be created as B-trees. |
1089 | | * |
1090 | | * Return: Non-negative on success/Negative on failure |
1091 | | * |
1092 | | *------------------------------------------------------------------------- |
1093 | | */ |
1094 | | herr_t |
1095 | | H5Pset_shared_mesg_phase_change(hid_t plist_id, unsigned max_list, unsigned min_btree) |
1096 | 0 | { |
1097 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
1098 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1099 | |
|
1100 | 0 | FUNC_ENTER_API(FAIL) |
1101 | | |
1102 | | /* Check that values are sensible. The min_btree value must be no greater |
1103 | | * than the max list plus one. |
1104 | | * |
1105 | | * Range check to make certain they will fit into encoded form. |
1106 | | */ |
1107 | 0 | if (max_list + 1 < min_btree) |
1108 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "minimum B-tree value is greater than maximum list value"); |
1109 | 0 | if (max_list > H5O_SHMESG_MAX_LIST_SIZE) |
1110 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "max list value is larger than H5O_SHMESG_MAX_LIST_SIZE"); |
1111 | 0 | if (min_btree > H5O_SHMESG_MAX_LIST_SIZE) |
1112 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "min btree value is larger than H5O_SHMESG_MAX_LIST_SIZE"); |
1113 | | |
1114 | | /* Avoid the strange case where max_list == 0 and min_btree == 1, so deleting the |
1115 | | * last message in a B-tree makes it become an empty list. |
1116 | | */ |
1117 | 0 | if (max_list == 0) |
1118 | 0 | min_btree = 0; |
1119 | | |
1120 | | /* Get the plist structure */ |
1121 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, false))) |
1122 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
1123 | | |
1124 | 0 | if (H5P_set(plist, H5F_CRT_SHMSG_LIST_MAX_NAME, &max_list) < 0) |
1125 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set list maximum in property list"); |
1126 | 0 | if (H5P_set(plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, &min_btree) < 0) |
1127 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set B-tree minimum in property list"); |
1128 | | |
1129 | 0 | done: |
1130 | 0 | FUNC_LEAVE_API(ret_value) |
1131 | 0 | } /* end H5Pset_shared_mesg_phase_change() */ |
1132 | | |
1133 | | /*------------------------------------------------------------------------- |
1134 | | * Function: H5Pget_shared_mesg_phase_change |
1135 | | * |
1136 | | * Purpose: Gets the maximum size of a SOHM list index before it becomes |
1137 | | * a B-tree. |
1138 | | * |
1139 | | * Return: Non-negative on success/Negative on failure |
1140 | | * |
1141 | | *------------------------------------------------------------------------- |
1142 | | */ |
1143 | | herr_t |
1144 | | H5Pget_shared_mesg_phase_change(hid_t plist_id, unsigned *max_list /*out*/, unsigned *min_btree /*out*/) |
1145 | 0 | { |
1146 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
1147 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1148 | |
|
1149 | 0 | FUNC_ENTER_API(FAIL) |
1150 | | |
1151 | | /* Get the plist structure */ |
1152 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, true))) |
1153 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
1154 | | |
1155 | | /* Get value(s) */ |
1156 | 0 | if (max_list) |
1157 | 0 | if (H5P_get(plist, H5F_CRT_SHMSG_LIST_MAX_NAME, max_list) < 0) |
1158 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get list maximum"); |
1159 | 0 | if (min_btree) |
1160 | 0 | if (H5P_get(plist, H5F_CRT_SHMSG_BTREE_MIN_NAME, min_btree) < 0) |
1161 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get SOHM information"); |
1162 | | |
1163 | 0 | done: |
1164 | 0 | FUNC_LEAVE_API(ret_value) |
1165 | 0 | } /* end H5Pget_shared_mesg_phase_change() */ |
1166 | | |
1167 | | /*------------------------------------------------------------------------- |
1168 | | * Function: H5P__set_file_space_strategy |
1169 | | * |
1170 | | * Purpose: Internal routine to set file space strategy properties. |
1171 | | * |
1172 | | * Return: Non-negative on success/Negative on failure |
1173 | | * |
1174 | | *------------------------------------------------------------------------- |
1175 | | */ |
1176 | | herr_t |
1177 | | H5P__set_file_space_strategy(H5P_genplist_t *plist, H5F_fspace_strategy_t strategy, bool persist, |
1178 | | hsize_t threshold) |
1179 | 0 | { |
1180 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1181 | |
|
1182 | 0 | FUNC_ENTER_PACKAGE |
1183 | | |
1184 | | /* Set value(s), if non-zero */ |
1185 | 0 | if (H5P_set(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, &strategy) < 0) |
1186 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file space strategy"); |
1187 | | |
1188 | | /* Ignore persist and threshold settings for strategies that do not use FSM */ |
1189 | 0 | if (strategy == H5F_FSPACE_STRATEGY_FSM_AGGR || strategy == H5F_FSPACE_STRATEGY_PAGE) { |
1190 | 0 | if (H5P_set(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, &persist) < 0) |
1191 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set free-space persisting status"); |
1192 | | |
1193 | 0 | if (H5P_set(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, &threshold) < 0) |
1194 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set free-space threshold"); |
1195 | 0 | } /* end if */ |
1196 | | |
1197 | 0 | done: |
1198 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
1199 | 0 | } /* H5P__set_file_space_strategy() */ |
1200 | | |
1201 | | /*------------------------------------------------------------------------- |
1202 | | * Function: H5Pset_file_space_strategy |
1203 | | * |
1204 | | * Purpose: Sets the "strategy" that the library employs in managing file space |
1205 | | * Sets the "persist" value as to persist free-space or not |
1206 | | * Sets the "threshold" value that the free space manager(s) will |
1207 | | * use to track free space sections. Ignore "persist" and |
1208 | | * "threshold" for strategies that do not use free-space managers. |
1209 | | * |
1210 | | * Return: Non-negative on success/Negative on failure |
1211 | | * |
1212 | | *------------------------------------------------------------------------- |
1213 | | */ |
1214 | | herr_t |
1215 | | H5Pset_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t strategy, bool persist, hsize_t threshold) |
1216 | 0 | { |
1217 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
1218 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1219 | |
|
1220 | 0 | FUNC_ENTER_API(FAIL) |
1221 | | |
1222 | | /* Check arguments */ |
1223 | 0 | if (strategy >= H5F_FSPACE_STRATEGY_NTYPES) |
1224 | 0 | HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid strategy"); |
1225 | | |
1226 | | /* Get the plist structure */ |
1227 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, false))) |
1228 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
1229 | | |
1230 | | /* Set value(s) */ |
1231 | 0 | if (H5P__set_file_space_strategy(plist, strategy, persist, threshold) < 0) |
1232 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file space strategy values"); |
1233 | | |
1234 | 0 | done: |
1235 | 0 | FUNC_LEAVE_API(ret_value) |
1236 | 0 | } /* H5Pset_file_space_strategy() */ |
1237 | | |
1238 | | /*------------------------------------------------------------------------- |
1239 | | * Function: H5P__get_file_space_strategy |
1240 | | * |
1241 | | * Purpose: Retrieves the strategy, persist, and threshold that the library |
1242 | | * uses in managing file space. |
1243 | | * |
1244 | | * Return: Non-negative on success/Negative on failure |
1245 | | * |
1246 | | *------------------------------------------------------------------------- |
1247 | | */ |
1248 | | herr_t |
1249 | | H5P__get_file_space_strategy(H5P_genplist_t *plist, H5F_fspace_strategy_t *strategy /*out*/, |
1250 | | bool *persist /*out*/, hsize_t *threshold /*out*/) |
1251 | 0 | { |
1252 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1253 | |
|
1254 | 0 | FUNC_ENTER_PACKAGE |
1255 | | |
1256 | | /* Get value(s) */ |
1257 | 0 | if (strategy) |
1258 | 0 | if (H5P_get(plist, H5F_CRT_FILE_SPACE_STRATEGY_NAME, strategy) < 0) |
1259 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space strategy"); |
1260 | 0 | if (persist) |
1261 | 0 | if (H5P_get(plist, H5F_CRT_FREE_SPACE_PERSIST_NAME, persist) < 0) |
1262 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space persisting status"); |
1263 | 0 | if (threshold) |
1264 | 0 | if (H5P_get(plist, H5F_CRT_FREE_SPACE_THRESHOLD_NAME, threshold) < 0) |
1265 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get free-space threshold"); |
1266 | | |
1267 | 0 | done: |
1268 | 0 | FUNC_LEAVE_NOAPI(ret_value) |
1269 | 0 | } /* H5P__get_file_space_strategy() */ |
1270 | | |
1271 | | /*------------------------------------------------------------------------- |
1272 | | * Function: H5Pget_file_space_strategy |
1273 | | * |
1274 | | * Purpose: Retrieves the strategy, persist, and threshold that the library |
1275 | | * uses in managing file space. |
1276 | | * |
1277 | | * Return: Non-negative on success/Negative on failure |
1278 | | * |
1279 | | *------------------------------------------------------------------------- |
1280 | | */ |
1281 | | herr_t |
1282 | | H5Pget_file_space_strategy(hid_t plist_id, H5F_fspace_strategy_t *strategy /*out*/, bool *persist /*out*/, |
1283 | | hsize_t *threshold /*out*/) |
1284 | 0 | { |
1285 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
1286 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1287 | |
|
1288 | 0 | FUNC_ENTER_API(FAIL) |
1289 | | |
1290 | | /* Get the plist structure */ |
1291 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, true))) |
1292 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
1293 | | |
1294 | | /* Get value(s) */ |
1295 | 0 | if (H5P__get_file_space_strategy(plist, strategy, persist, threshold) < 0) |
1296 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space strategy values"); |
1297 | | |
1298 | 0 | done: |
1299 | 0 | FUNC_LEAVE_API(ret_value) |
1300 | 0 | } /* H5Pget_file_space_strategy() */ |
1301 | | |
1302 | | /*------------------------------------------------------------------------- |
1303 | | * Function: H5P__fcrt_fspace_strategy_enc |
1304 | | * |
1305 | | * Purpose: Callback routine which is called whenever the free-space |
1306 | | * strategy property in the file creation property list |
1307 | | * is encoded. |
1308 | | * |
1309 | | * Return: Success: Non-negative |
1310 | | * Failure: Negative |
1311 | | * |
1312 | | *------------------------------------------------------------------------- |
1313 | | */ |
1314 | | static herr_t |
1315 | | H5P__fcrt_fspace_strategy_enc(const void *value, void **_pp, size_t *size) |
1316 | 0 | { |
1317 | 0 | const H5F_fspace_strategy_t *strategy = |
1318 | 0 | (const H5F_fspace_strategy_t *)value; /* Create local alias for values */ |
1319 | 0 | uint8_t **pp = (uint8_t **)_pp; |
1320 | |
|
1321 | 0 | FUNC_ENTER_PACKAGE_NOERR |
1322 | | |
1323 | | /* Sanity check */ |
1324 | 0 | assert(strategy); |
1325 | 0 | assert(size); |
1326 | |
|
1327 | 0 | if (NULL != *pp) |
1328 | | /* Encode free-space strategy */ |
1329 | 0 | *(*pp)++ = (uint8_t)*strategy; |
1330 | | |
1331 | | /* Size of free-space strategy */ |
1332 | 0 | (*size)++; |
1333 | |
|
1334 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
1335 | 0 | } /* end H5P__fcrt_fspace_strategy_enc() */ |
1336 | | |
1337 | | /*------------------------------------------------------------------------- |
1338 | | * Function: H5P__fcrt_fspace_strategy_dec |
1339 | | * |
1340 | | * Purpose: Callback routine which is called whenever the free-space |
1341 | | * strategy property in the file creation property list |
1342 | | * is decoded. |
1343 | | * |
1344 | | * Return: Success: Non-negative |
1345 | | * Failure: Negative |
1346 | | * |
1347 | | *------------------------------------------------------------------------- |
1348 | | */ |
1349 | | static herr_t |
1350 | | H5P__fcrt_fspace_strategy_dec(const void **_pp, void *_value) |
1351 | 0 | { |
1352 | 0 | H5F_fspace_strategy_t *strategy = (H5F_fspace_strategy_t *)_value; /* Free-space strategy */ |
1353 | 0 | const uint8_t **pp = (const uint8_t **)_pp; |
1354 | |
|
1355 | 0 | FUNC_ENTER_PACKAGE_NOERR |
1356 | | |
1357 | | /* Sanity checks */ |
1358 | 0 | assert(pp); |
1359 | 0 | assert(*pp); |
1360 | 0 | assert(strategy); |
1361 | | |
1362 | | /* Decode free-space strategy */ |
1363 | 0 | *strategy = (H5F_fspace_strategy_t) * (*pp)++; |
1364 | |
|
1365 | 0 | FUNC_LEAVE_NOAPI(SUCCEED) |
1366 | 0 | } /* end H5P__fcrt_fspace_strategy_dec() */ |
1367 | | |
1368 | | /*------------------------------------------------------------------------- |
1369 | | * Function: H5Pset_file_space_page_size |
1370 | | * |
1371 | | * Purpose: Sets the file space page size for paged aggregation. |
1372 | | * |
1373 | | * Return: Non-negative on success/Negative on failure |
1374 | | * |
1375 | | *------------------------------------------------------------------------- |
1376 | | */ |
1377 | | herr_t |
1378 | | H5Pset_file_space_page_size(hid_t plist_id, hsize_t fsp_size) |
1379 | 0 | { |
1380 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
1381 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1382 | |
|
1383 | 0 | FUNC_ENTER_API(FAIL) |
1384 | | |
1385 | | /* Get the plist structure */ |
1386 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, false))) |
1387 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
1388 | | |
1389 | 0 | if (fsp_size < H5F_FILE_SPACE_PAGE_SIZE_MIN) |
1390 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "cannot set file space page size to less than 512"); |
1391 | | |
1392 | 0 | if (fsp_size > H5F_FILE_SPACE_PAGE_SIZE_MAX) |
1393 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "cannot set file space page size to more than 1GB"); |
1394 | | |
1395 | | /* Set the value*/ |
1396 | 0 | if (H5P_set(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, &fsp_size) < 0) |
1397 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set file space page size"); |
1398 | | |
1399 | 0 | done: |
1400 | 0 | FUNC_LEAVE_API(ret_value) |
1401 | 0 | } /* H5Pset_file_space_page_size() */ |
1402 | | |
1403 | | /*------------------------------------------------------------------------- |
1404 | | * Function: H5Pget_file_space_page_size |
1405 | | * |
1406 | | * Purpose: Retrieves the file space page size for aggregating small metadata |
1407 | | * or raw data in the parameter "fsp_size". |
1408 | | * |
1409 | | * Return: Non-negative on success/Negative on failure |
1410 | | * |
1411 | | *------------------------------------------------------------------------- |
1412 | | */ |
1413 | | herr_t |
1414 | | H5Pget_file_space_page_size(hid_t plist_id, hsize_t *fsp_size /*out*/) |
1415 | 0 | { |
1416 | 0 | H5P_genplist_t *plist; /* Property list pointer */ |
1417 | 0 | herr_t ret_value = SUCCEED; /* Return value */ |
1418 | |
|
1419 | 0 | FUNC_ENTER_API(FAIL) |
1420 | | |
1421 | | /* Get the plist structure */ |
1422 | 0 | if (NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_CREATE, true))) |
1423 | 0 | HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID"); |
1424 | | |
1425 | | /* Get value */ |
1426 | 0 | if (fsp_size) |
1427 | 0 | if (H5P_get(plist, H5F_CRT_FILE_SPACE_PAGE_SIZE_NAME, fsp_size) < 0) |
1428 | 0 | HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file space page size"); |
1429 | | |
1430 | 0 | done: |
1431 | | FUNC_LEAVE_API(ret_value) |
1432 | 0 | } /* H5Pget_file_space_page_size() */ |