Coverage Report

Created: 2025-08-26 06:30

/src/hdf5/src/H5Pdxpl.c
Line
Count
Source (jump to first uncovered line)
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:   H5Pdxpl.c
16
 *
17
 * Purpose:   Data transfer 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 "H5Dprivate.h"  /* Datasets                                 */
33
#include "H5Eprivate.h"  /* Error handling                           */
34
#include "H5FDprivate.h" /* File drivers                             */
35
#include "H5MMprivate.h" /* Memory management                        */
36
#include "H5Ppkg.h"      /* Property lists                           */
37
#include "H5VMprivate.h" /* Vector Functions                         */
38
39
/****************/
40
/* Local Macros */
41
/****************/
42
43
/* ======== Data transfer properties ======== */
44
/* Definitions for maximum temp buffer size property */
45
1
#define H5D_XFER_MAX_TEMP_BUF_SIZE sizeof(size_t)
46
#define H5D_XFER_MAX_TEMP_BUF_DEF  H5D_TEMP_BUF_SIZE
47
1
#define H5D_XFER_MAX_TEMP_BUF_ENC  H5P__encode_size_t
48
1
#define H5D_XFER_MAX_TEMP_BUF_DEC  H5P__decode_size_t
49
/* Definitions for type conversion buffer property */
50
1
#define H5D_XFER_TCONV_BUF_SIZE sizeof(void *)
51
#define H5D_XFER_TCONV_BUF_DEF  NULL
52
/* Definitions for background buffer property */
53
1
#define H5D_XFER_BKGR_BUF_SIZE sizeof(void *)
54
#define H5D_XFER_BKGR_BUF_DEF  NULL
55
/* Definitions for background buffer type property */
56
1
#define H5D_XFER_BKGR_BUF_TYPE_SIZE sizeof(H5T_bkg_t)
57
#define H5D_XFER_BKGR_BUF_TYPE_DEF  H5T_BKG_NO
58
1
#define H5D_XFER_BKGR_BUF_TYPE_ENC  H5P__dxfr_bkgr_buf_type_enc
59
1
#define H5D_XFER_BKGR_BUF_TYPE_DEC  H5P__dxfr_bkgr_buf_type_dec
60
/* Definitions for B-tree node splitting ratio property */
61
/* (These default B-tree node splitting ratios are also used for splitting
62
 * group's B-trees as well as chunked dataset's B-trees - QAK)
63
 */
64
1
#define H5D_XFER_BTREE_SPLIT_RATIO_SIZE sizeof(double[3])
65
#define H5D_XFER_BTREE_SPLIT_RATIO_DEF                                                                       \
66
    {                                                                                                        \
67
        0.1, 0.5, 0.9                                                                                        \
68
    }
69
1
#define H5D_XFER_BTREE_SPLIT_RATIO_ENC H5P__dxfr_btree_split_ratio_enc
70
1
#define H5D_XFER_BTREE_SPLIT_RATIO_DEC H5P__dxfr_btree_split_ratio_dec
71
/* Definitions for vlen allocation function property */
72
1
#define H5D_XFER_VLEN_ALLOC_SIZE sizeof(H5MM_allocate_t)
73
#define H5D_XFER_VLEN_ALLOC_DEF  H5D_VLEN_ALLOC
74
/* Definitions for vlen allocation info property */
75
1
#define H5D_XFER_VLEN_ALLOC_INFO_SIZE sizeof(void *)
76
#define H5D_XFER_VLEN_ALLOC_INFO_DEF  H5D_VLEN_ALLOC_INFO
77
/* Definitions for vlen free function property */
78
1
#define H5D_XFER_VLEN_FREE_SIZE sizeof(H5MM_free_t)
79
#define H5D_XFER_VLEN_FREE_DEF  H5D_VLEN_FREE
80
/* Definitions for vlen free info property */
81
1
#define H5D_XFER_VLEN_FREE_INFO_SIZE sizeof(void *)
82
#define H5D_XFER_VLEN_FREE_INFO_DEF  H5D_VLEN_FREE_INFO
83
/* Definitions for hyperslab vector size property */
84
/* (Be cautious about increasing the default size, there are arrays allocated
85
 *      on the stack which depend on it - QAK)
86
 */
87
1
#define H5D_XFER_HYPER_VECTOR_SIZE_SIZE sizeof(size_t)
88
#define H5D_XFER_HYPER_VECTOR_SIZE_DEF  H5D_IO_VECTOR_SIZE
89
1
#define H5D_XFER_HYPER_VECTOR_SIZE_ENC  H5P__encode_size_t
90
1
#define H5D_XFER_HYPER_VECTOR_SIZE_DEC  H5P__decode_size_t
91
92
/* Parallel I/O properties */
93
/* Note: Some of these are registered with the DXPL class even when parallel
94
 *      is disabled, so that property list comparisons of encoded property
95
 *      lists (between parallel & non-parallel builds) work properly. -QAK
96
 */
97
98
/* Definitions for I/O transfer mode property */
99
1
#define H5D_XFER_IO_XFER_MODE_SIZE sizeof(H5FD_mpio_xfer_t)
100
#define H5D_XFER_IO_XFER_MODE_DEF  H5FD_MPIO_INDEPENDENT
101
1
#define H5D_XFER_IO_XFER_MODE_ENC  H5P__dxfr_io_xfer_mode_enc
102
1
#define H5D_XFER_IO_XFER_MODE_DEC  H5P__dxfr_io_xfer_mode_dec
103
/* Definitions for optimization of MPI-IO transfer mode property */
104
1
#define H5D_XFER_MPIO_COLLECTIVE_OPT_SIZE  sizeof(H5FD_mpio_collective_opt_t)
105
#define H5D_XFER_MPIO_COLLECTIVE_OPT_DEF   H5FD_MPIO_COLLECTIVE_IO
106
1
#define H5D_XFER_MPIO_COLLECTIVE_OPT_ENC   H5P__dxfr_mpio_collective_opt_enc
107
1
#define H5D_XFER_MPIO_COLLECTIVE_OPT_DEC   H5P__dxfr_mpio_collective_opt_dec
108
1
#define H5D_XFER_MPIO_CHUNK_OPT_HARD_SIZE  sizeof(H5FD_mpio_chunk_opt_t)
109
#define H5D_XFER_MPIO_CHUNK_OPT_HARD_DEF   H5FD_MPIO_CHUNK_DEFAULT
110
1
#define H5D_XFER_MPIO_CHUNK_OPT_HARD_ENC   H5P__dxfr_mpio_chunk_opt_hard_enc
111
1
#define H5D_XFER_MPIO_CHUNK_OPT_HARD_DEC   H5P__dxfr_mpio_chunk_opt_hard_dec
112
1
#define H5D_XFER_MPIO_CHUNK_OPT_NUM_SIZE   sizeof(unsigned)
113
#define H5D_XFER_MPIO_CHUNK_OPT_NUM_DEF    H5D_ONE_LINK_CHUNK_IO_THRESHOLD
114
1
#define H5D_XFER_MPIO_CHUNK_OPT_NUM_ENC    H5P__encode_unsigned
115
1
#define H5D_XFER_MPIO_CHUNK_OPT_NUM_DEC    H5P__decode_unsigned
116
1
#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_SIZE sizeof(unsigned)
117
#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEF  H5D_MULTI_CHUNK_IO_COL_THRESHOLD
118
1
#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_ENC  H5P__encode_unsigned
119
1
#define H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEC  H5P__decode_unsigned
120
/* Definitions for chunk opt mode property. */
121
1
#define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_SIZE sizeof(H5D_mpio_actual_chunk_opt_mode_t)
122
#define H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_DEF  H5D_MPIO_NO_CHUNK_OPTIMIZATION
123
/* Definitions for chunk io mode property. */
124
1
#define H5D_MPIO_ACTUAL_IO_MODE_SIZE sizeof(H5D_mpio_actual_io_mode_t)
125
#define H5D_MPIO_ACTUAL_IO_MODE_DEF  H5D_MPIO_NO_COLLECTIVE
126
/* Definitions for cause of broken collective io property */
127
2
#define H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE sizeof(uint32_t)
128
#define H5D_MPIO_NO_COLLECTIVE_CAUSE_DEF  H5D_MPIO_COLLECTIVE
129
130
/* Definitions for EDC property */
131
1
#define H5D_XFER_EDC_SIZE sizeof(H5Z_EDC_t)
132
#define H5D_XFER_EDC_DEF  H5Z_ENABLE_EDC
133
1
#define H5D_XFER_EDC_ENC  H5P__dxfr_edc_enc
134
1
#define H5D_XFER_EDC_DEC  H5P__dxfr_edc_dec
135
/* Definitions for filter callback function property */
136
1
#define H5D_XFER_FILTER_CB_SIZE sizeof(H5Z_cb_t)
137
#define H5D_XFER_FILTER_CB_DEF                                                                               \
138
    {                                                                                                        \
139
        NULL, NULL                                                                                           \
140
    }
141
/* Definitions for type conversion callback function property */
142
1
#define H5D_XFER_CONV_CB_SIZE sizeof(H5T_conv_cb_t)
143
#define H5D_XFER_CONV_CB_DEF                                                                                 \
144
    {                                                                                                        \
145
        NULL, NULL                                                                                           \
146
    }
147
/* Definitions for data transform property */
148
1
#define H5D_XFER_XFORM_SIZE  sizeof(void *)
149
0
#define H5D_XFER_XFORM_DEF   NULL
150
1
#define H5D_XFER_XFORM_SET   H5P__dxfr_xform_set
151
1
#define H5D_XFER_XFORM_GET   H5P__dxfr_xform_get
152
1
#define H5D_XFER_XFORM_ENC   H5P__dxfr_xform_enc
153
1
#define H5D_XFER_XFORM_DEC   H5P__dxfr_xform_dec
154
1
#define H5D_XFER_XFORM_DEL   H5P__dxfr_xform_del
155
1
#define H5D_XFER_XFORM_COPY  H5P__dxfr_xform_copy
156
1
#define H5D_XFER_XFORM_CMP   H5P__dxfr_xform_cmp
157
1
#define H5D_XFER_XFORM_CLOSE H5P__dxfr_xform_close
158
/* Definitions for dataset I/O selection property */
159
1
#define H5D_XFER_DSET_IO_SEL_SIZE  sizeof(H5S_t *)
160
#define H5D_XFER_DSET_IO_SEL_DEF   NULL
161
1
#define H5D_XFER_DSET_IO_SEL_COPY  H5P__dxfr_dset_io_hyp_sel_copy
162
1
#define H5D_XFER_DSET_IO_SEL_CMP   H5P__dxfr_dset_io_hyp_sel_cmp
163
1
#define H5D_XFER_DSET_IO_SEL_CLOSE H5P__dxfr_dset_io_hyp_sel_close
164
#ifdef QAK
165
#define H5D_XFER_DSET_IO_SEL_ENC H5P__dxfr_edc_enc
166
#define H5D_XFER_DSET_IO_SEL_DEC H5P__dxfr_edc_dec
167
#endif /* QAK */
168
/* Definition for selection I/O mode property */
169
1
#define H5D_XFER_SELECTION_IO_MODE_SIZE sizeof(H5D_selection_io_mode_t)
170
#define H5D_XFER_SELECTION_IO_MODE_DEF  H5D_SELECTION_IO_MODE_DEFAULT
171
1
#define H5D_XFER_SELECTION_IO_MODE_ENC  H5P__dxfr_selection_io_mode_enc
172
1
#define H5D_XFER_SELECTION_IO_MODE_DEC  H5P__dxfr_selection_io_mode_dec
173
/* Definitions for cause of no selection I/O property */
174
1
#define H5D_XFER_NO_SELECTION_IO_CAUSE_SIZE sizeof(uint32_t)
175
#define H5D_XFER_NO_SELECTION_IO_CAUSE_DEF  0
176
/* Definitions for actual selection I/O mode property */
177
1
#define H5D_XFER_ACTUAL_SELECTION_IO_MODE_SIZE sizeof(uint32_t)
178
#define H5D_XFER_ACTUAL_SELECTION_IO_MODE_DEF  0
179
/* Definitions for modify write buffer property */
180
1
#define H5D_XFER_MODIFY_WRITE_BUF_SIZE sizeof(bool)
181
#define H5D_XFER_MODIFY_WRITE_BUF_DEF  false
182
1
#define H5D_XFER_MODIFY_WRITE_BUF_ENC  H5P__dxfr_modify_write_buf_enc
183
1
#define H5D_XFER_MODIFY_WRITE_BUF_DEC  H5P__dxfr_modify_write_buf_dec
184
185
/******************/
186
/* Local Typedefs */
187
/******************/
188
189
/********************/
190
/* Package Typedefs */
191
/********************/
192
193
/********************/
194
/* Local Prototypes */
195
/********************/
196
197
/* Property class callbacks */
198
static herr_t H5P__dxfr_reg_prop(H5P_genclass_t *pclass);
199
200
/* Property list callbacks */
201
static herr_t H5P__dxfr_bkgr_buf_type_enc(const void *value, void **pp, size_t *size);
202
static herr_t H5P__dxfr_bkgr_buf_type_dec(const void **pp, void *value);
203
static herr_t H5P__dxfr_btree_split_ratio_enc(const void *value, void **pp, size_t *size);
204
static herr_t H5P__dxfr_btree_split_ratio_dec(const void **pp, void *value);
205
static herr_t H5P__dxfr_io_xfer_mode_enc(const void *value, void **pp, size_t *size);
206
static herr_t H5P__dxfr_io_xfer_mode_dec(const void **pp, void *value);
207
static herr_t H5P__dxfr_mpio_collective_opt_enc(const void *value, void **pp, size_t *size);
208
static herr_t H5P__dxfr_mpio_collective_opt_dec(const void **pp, void *value);
209
static herr_t H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **pp, size_t *size);
210
static herr_t H5P__dxfr_mpio_chunk_opt_hard_dec(const void **pp, void *value);
211
static herr_t H5P__dxfr_edc_enc(const void *value, void **pp, size_t *size);
212
static herr_t H5P__dxfr_edc_dec(const void **pp, void *value);
213
static herr_t H5P__dxfr_xform_set(hid_t prop_id, const char *name, size_t size, void *value);
214
static herr_t H5P__dxfr_xform_get(hid_t prop_id, const char *name, size_t size, void *value);
215
static herr_t H5P__dxfr_xform_enc(const void *value, void **pp, size_t *size);
216
static herr_t H5P__dxfr_xform_dec(const void **pp, void *value);
217
static herr_t H5P__dxfr_xform_del(hid_t prop_id, const char *name, size_t size, void *value);
218
static herr_t H5P__dxfr_xform_copy(const char *name, size_t size, void *value);
219
static int    H5P__dxfr_xform_cmp(const void *value1, const void *value2, size_t size);
220
static herr_t H5P__dxfr_xform_close(const char *name, size_t size, void *value);
221
static herr_t H5P__dxfr_dset_io_hyp_sel_copy(const char *name, size_t size, void *value);
222
static int    H5P__dxfr_dset_io_hyp_sel_cmp(const void *value1, const void *value2, size_t size);
223
static herr_t H5P__dxfr_dset_io_hyp_sel_close(const char *name, size_t size, void *value);
224
static herr_t H5P__dxfr_selection_io_mode_enc(const void *value, void **pp, size_t *size);
225
static herr_t H5P__dxfr_selection_io_mode_dec(const void **pp, void *value);
226
static herr_t H5P__dxfr_modify_write_buf_enc(const void *value, void **pp, size_t *size);
227
static herr_t H5P__dxfr_modify_write_buf_dec(const void **pp, void *value);
228
229
/*********************/
230
/* Package Variables */
231
/*********************/
232
233
/* Data transfer property list class library initialization object */
234
const H5P_libclass_t H5P_CLS_DXFR[1] = {{
235
    "data transfer",       /* Class name for debugging     */
236
    H5P_TYPE_DATASET_XFER, /* Class type                   */
237
238
    &H5P_CLS_ROOT_g,            /* Parent class                 */
239
    &H5P_CLS_DATASET_XFER_g,    /* Pointer to class             */
240
    &H5P_CLS_DATASET_XFER_ID_g, /* Pointer to class ID          */
241
    &H5P_LST_DATASET_XFER_ID_g, /* Pointer to default property list ID */
242
    H5P__dxfr_reg_prop,         /* Default property registration routine */
243
244
    NULL, /* Class creation callback      */
245
    NULL, /* Class creation callback info */
246
    NULL, /* Class copy callback          */
247
    NULL, /* Class copy callback info     */
248
    NULL, /* Class close callback         */
249
    NULL  /* Class close callback info    */
250
}};
251
252
/*****************************/
253
/* Library Private Variables */
254
/*****************************/
255
256
/***************************/
257
/* Local Private Variables */
258
/***************************/
259
260
/* Property value defaults */
261
static const size_t H5D_def_max_temp_buf_g =
262
    H5D_XFER_MAX_TEMP_BUF_DEF; /* Default value for maximum temp buffer size */
263
static const void *H5D_def_tconv_buf_g =
264
    H5D_XFER_TCONV_BUF_DEF; /* Default value for type conversion buffer */
265
static const void     *H5D_def_bkgr_buf_g = H5D_XFER_BKGR_BUF_DEF; /* Default value for background buffer */
266
static const H5T_bkg_t H5D_def_bkgr_buf_type_g = H5D_XFER_BKGR_BUF_TYPE_DEF;
267
static const double    H5D_def_btree_split_ratio_g[3] =
268
    H5D_XFER_BTREE_SPLIT_RATIO_DEF; /* Default value for B-tree node split ratios */
269
static const H5MM_allocate_t H5D_def_vlen_alloc_g =
270
    H5D_XFER_VLEN_ALLOC_DEF; /* Default value for vlen allocation function */
271
static const void *H5D_def_vlen_alloc_info_g =
272
    H5D_XFER_VLEN_ALLOC_INFO_DEF; /* Default value for vlen allocation information */
273
static const H5MM_free_t H5D_def_vlen_free_g =
274
    H5D_XFER_VLEN_FREE_DEF; /* Default value for vlen free function */
275
static const void *H5D_def_vlen_free_info_g =
276
    H5D_XFER_VLEN_FREE_INFO_DEF; /* Default value for vlen free information */
277
static const size_t H5D_def_hyp_vec_size_g =
278
    H5D_XFER_HYPER_VECTOR_SIZE_DEF; /* Default value for vector size */
279
static const H5FD_mpio_xfer_t H5D_def_io_xfer_mode_g =
280
    H5D_XFER_IO_XFER_MODE_DEF; /* Default value for I/O transfer mode */
281
static const H5FD_mpio_chunk_opt_t      H5D_def_mpio_chunk_opt_mode_g      = H5D_XFER_MPIO_CHUNK_OPT_HARD_DEF;
282
static const H5FD_mpio_collective_opt_t H5D_def_mpio_collective_opt_mode_g = H5D_XFER_MPIO_COLLECTIVE_OPT_DEF;
283
static const unsigned                   H5D_def_mpio_chunk_opt_num_g       = H5D_XFER_MPIO_CHUNK_OPT_NUM_DEF;
284
static const unsigned                   H5D_def_mpio_chunk_opt_ratio_g = H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEF;
285
static const H5D_mpio_actual_chunk_opt_mode_t H5D_def_mpio_actual_chunk_opt_mode_g =
286
    H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_DEF;
287
static const H5D_mpio_actual_io_mode_t      H5D_def_mpio_actual_io_mode_g = H5D_MPIO_ACTUAL_IO_MODE_DEF;
288
static const H5D_mpio_no_collective_cause_t H5D_def_mpio_no_collective_cause_g =
289
    H5D_MPIO_NO_COLLECTIVE_CAUSE_DEF;
290
static const H5Z_EDC_t H5D_def_enable_edc_g = H5D_XFER_EDC_DEF;       /* Default value for EDC property */
291
static const H5Z_cb_t  H5D_def_filter_cb_g  = H5D_XFER_FILTER_CB_DEF; /* Default value for filter callback */
292
static const H5T_conv_cb_t H5D_def_conv_cb_g =
293
    H5D_XFER_CONV_CB_DEF; /* Default value for datatype conversion callback */
294
static const void  *H5D_def_xfer_xform_g = H5D_XFER_XFORM_DEF; /* Default value for data transform */
295
static const H5S_t *H5D_def_dset_io_sel_g =
296
    H5D_XFER_DSET_IO_SEL_DEF; /* Default value for dataset I/O selection */
297
static const H5D_selection_io_mode_t H5D_def_selection_io_mode_g     = H5D_XFER_SELECTION_IO_MODE_DEF;
298
static const uint32_t                H5D_def_no_selection_io_cause_g = H5D_XFER_NO_SELECTION_IO_CAUSE_DEF;
299
static const uint32_t H5D_def_actual_selection_io_mode_g             = H5D_XFER_ACTUAL_SELECTION_IO_MODE_DEF;
300
static const bool     H5D_def_modify_write_buf_g                     = H5D_XFER_MODIFY_WRITE_BUF_DEF;
301
302
/*-------------------------------------------------------------------------
303
 * Function:    H5P__dxfr_reg_prop
304
 *
305
 * Purpose:     Register the data transfer property list class's properties
306
 *
307
 * Return:      Non-negative on success/Negative on failure
308
 *
309
 *-------------------------------------------------------------------------
310
 */
311
static herr_t
312
H5P__dxfr_reg_prop(H5P_genclass_t *pclass)
313
1
{
314
1
    herr_t ret_value = SUCCEED; /* Return value */
315
316
1
    FUNC_ENTER_PACKAGE
317
318
    /* Register the max. temp buffer size property */
319
1
    if (H5P__register_real(pclass, H5D_XFER_MAX_TEMP_BUF_NAME, H5D_XFER_MAX_TEMP_BUF_SIZE,
320
1
                           &H5D_def_max_temp_buf_g, NULL, NULL, NULL, H5D_XFER_MAX_TEMP_BUF_ENC,
321
1
                           H5D_XFER_MAX_TEMP_BUF_DEC, NULL, NULL, NULL, NULL) < 0)
322
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
323
324
    /* Register the type conversion buffer property */
325
    /* (Note: this property should not have an encode/decode callback -QAK) */
326
1
    if (H5P__register_real(pclass, H5D_XFER_TCONV_BUF_NAME, H5D_XFER_TCONV_BUF_SIZE, &H5D_def_tconv_buf_g,
327
1
                           NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
328
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
329
330
    /* Register the background buffer property */
331
    /* (Note: this property should not have an encode/decode callback -QAK) */
332
1
    if (H5P__register_real(pclass, H5D_XFER_BKGR_BUF_NAME, H5D_XFER_BKGR_BUF_SIZE, &H5D_def_bkgr_buf_g, NULL,
333
1
                           NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
334
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
335
336
    /* Register the background buffer type property */
337
1
    if (H5P__register_real(pclass, H5D_XFER_BKGR_BUF_TYPE_NAME, H5D_XFER_BKGR_BUF_TYPE_SIZE,
338
1
                           &H5D_def_bkgr_buf_type_g, NULL, NULL, NULL, H5D_XFER_BKGR_BUF_TYPE_ENC,
339
1
                           H5D_XFER_BKGR_BUF_TYPE_DEC, NULL, NULL, NULL, NULL) < 0)
340
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
341
342
    /* Register the B-Tree node splitting ratios property */
343
1
    if (H5P__register_real(pclass, H5D_XFER_BTREE_SPLIT_RATIO_NAME, H5D_XFER_BTREE_SPLIT_RATIO_SIZE,
344
1
                           H5D_def_btree_split_ratio_g, NULL, NULL, NULL, H5D_XFER_BTREE_SPLIT_RATIO_ENC,
345
1
                           H5D_XFER_BTREE_SPLIT_RATIO_DEC, NULL, NULL, NULL, NULL) < 0)
346
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
347
348
    /* Register the vlen allocation function property */
349
    /* (Note: this property should not have an encode/decode callback -QAK) */
350
1
    if (H5P__register_real(pclass, H5D_XFER_VLEN_ALLOC_NAME, H5D_XFER_VLEN_ALLOC_SIZE, &H5D_def_vlen_alloc_g,
351
1
                           NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
352
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
353
354
    /* Register the vlen allocation information property */
355
    /* (Note: this property should not have an encode/decode callback -QAK) */
356
1
    if (H5P__register_real(pclass, H5D_XFER_VLEN_ALLOC_INFO_NAME, H5D_XFER_VLEN_ALLOC_INFO_SIZE,
357
1
                           &H5D_def_vlen_alloc_info_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
358
1
                           NULL) < 0)
359
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
360
361
    /* Register the vlen free function property */
362
    /* (Note: this property should not have an encode/decode callback -QAK) */
363
1
    if (H5P__register_real(pclass, H5D_XFER_VLEN_FREE_NAME, H5D_XFER_VLEN_FREE_SIZE, &H5D_def_vlen_free_g,
364
1
                           NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
365
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
366
367
    /* Register the vlen free information property */
368
    /* (Note: this property should not have an encode/decode callback -QAK) */
369
1
    if (H5P__register_real(pclass, H5D_XFER_VLEN_FREE_INFO_NAME, H5D_XFER_VLEN_FREE_INFO_SIZE,
370
1
                           &H5D_def_vlen_free_info_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
371
1
                           NULL) < 0)
372
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
373
374
    /* Register the vector size property */
375
1
    if (H5P__register_real(pclass, H5D_XFER_HYPER_VECTOR_SIZE_NAME, H5D_XFER_HYPER_VECTOR_SIZE_SIZE,
376
1
                           &H5D_def_hyp_vec_size_g, NULL, NULL, NULL, H5D_XFER_HYPER_VECTOR_SIZE_ENC,
377
1
                           H5D_XFER_HYPER_VECTOR_SIZE_DEC, NULL, NULL, NULL, NULL) < 0)
378
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
379
380
    /* Register the I/O transfer mode properties */
381
1
    if (H5P__register_real(pclass, H5D_XFER_IO_XFER_MODE_NAME, H5D_XFER_IO_XFER_MODE_SIZE,
382
1
                           &H5D_def_io_xfer_mode_g, NULL, NULL, NULL, H5D_XFER_IO_XFER_MODE_ENC,
383
1
                           H5D_XFER_IO_XFER_MODE_DEC, NULL, NULL, NULL, NULL) < 0)
384
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
385
1
    if (H5P__register_real(pclass, H5D_XFER_MPIO_COLLECTIVE_OPT_NAME, H5D_XFER_MPIO_COLLECTIVE_OPT_SIZE,
386
1
                           &H5D_def_mpio_collective_opt_mode_g, NULL, NULL, NULL,
387
1
                           H5D_XFER_MPIO_COLLECTIVE_OPT_ENC, H5D_XFER_MPIO_COLLECTIVE_OPT_DEC, NULL, NULL,
388
1
                           NULL, NULL) < 0)
389
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
390
1
    if (H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_HARD_NAME, H5D_XFER_MPIO_CHUNK_OPT_HARD_SIZE,
391
1
                           &H5D_def_mpio_chunk_opt_mode_g, NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_HARD_ENC,
392
1
                           H5D_XFER_MPIO_CHUNK_OPT_HARD_DEC, NULL, NULL, NULL, NULL) < 0)
393
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
394
1
    if (H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_NUM_NAME, H5D_XFER_MPIO_CHUNK_OPT_NUM_SIZE,
395
1
                           &H5D_def_mpio_chunk_opt_num_g, NULL, NULL, NULL, H5D_XFER_MPIO_CHUNK_OPT_NUM_ENC,
396
1
                           H5D_XFER_MPIO_CHUNK_OPT_NUM_DEC, NULL, NULL, NULL, NULL) < 0)
397
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
398
1
    if (H5P__register_real(pclass, H5D_XFER_MPIO_CHUNK_OPT_RATIO_NAME, H5D_XFER_MPIO_CHUNK_OPT_RATIO_SIZE,
399
1
                           &H5D_def_mpio_chunk_opt_ratio_g, NULL, NULL, NULL,
400
1
                           H5D_XFER_MPIO_CHUNK_OPT_RATIO_ENC, H5D_XFER_MPIO_CHUNK_OPT_RATIO_DEC, NULL, NULL,
401
1
                           NULL, NULL) < 0)
402
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
403
404
    /* Register the chunk optimization mode property. */
405
    /* (Note: this property should not have an encode/decode callback -QAK) */
406
1
    if (H5P__register_real(pclass, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_SIZE,
407
1
                           &H5D_def_mpio_actual_chunk_opt_mode_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
408
1
                           NULL, NULL) < 0)
409
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
410
411
    /* Register the actual I/O mode property. */
412
    /* (Note: this property should not have an encode/decode callback -QAK) */
413
1
    if (H5P__register_real(pclass, H5D_MPIO_ACTUAL_IO_MODE_NAME, H5D_MPIO_ACTUAL_IO_MODE_SIZE,
414
1
                           &H5D_def_mpio_actual_io_mode_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
415
1
                           NULL) < 0)
416
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
417
418
    /* Register the local cause of broken collective I/O */
419
    /* (Note: this property should not have an encode/decode callback -QAK) */
420
1
    if (H5P__register_real(pclass, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE,
421
1
                           &H5D_def_mpio_no_collective_cause_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
422
1
                           NULL, NULL) < 0)
423
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
424
425
    /* Register the global cause of broken collective I/O */
426
    /* (Note: this property should not have an encode/decode callback -QAK) */
427
1
    if (H5P__register_real(pclass, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME,
428
1
                           H5D_MPIO_NO_COLLECTIVE_CAUSE_SIZE, &H5D_def_mpio_no_collective_cause_g, NULL, NULL,
429
1
                           NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
430
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
431
432
    /* Register the EDC property */
433
1
    if (H5P__register_real(pclass, H5D_XFER_EDC_NAME, H5D_XFER_EDC_SIZE, &H5D_def_enable_edc_g, NULL, NULL,
434
1
                           NULL, H5D_XFER_EDC_ENC, H5D_XFER_EDC_DEC, NULL, NULL, NULL, NULL) < 0)
435
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
436
437
    /* Register the filter callback property */
438
    /* (Note: this property should not have an encode/decode callback -QAK) */
439
1
    if (H5P__register_real(pclass, H5D_XFER_FILTER_CB_NAME, H5D_XFER_FILTER_CB_SIZE, &H5D_def_filter_cb_g,
440
1
                           NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
441
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
442
443
    /* Register the type conversion callback property */
444
    /* (Note: this property should not have an encode/decode callback -QAK) */
445
1
    if (H5P__register_real(pclass, H5D_XFER_CONV_CB_NAME, H5D_XFER_CONV_CB_SIZE, &H5D_def_conv_cb_g, NULL,
446
1
                           NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
447
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
448
449
    /* Register the data transform property */
450
1
    if (H5P__register_real(pclass, H5D_XFER_XFORM_NAME, H5D_XFER_XFORM_SIZE, &H5D_def_xfer_xform_g, NULL,
451
1
                           H5D_XFER_XFORM_SET, H5D_XFER_XFORM_GET, H5D_XFER_XFORM_ENC, H5D_XFER_XFORM_DEC,
452
1
                           H5D_XFER_XFORM_DEL, H5D_XFER_XFORM_COPY, H5D_XFER_XFORM_CMP,
453
1
                           H5D_XFER_XFORM_CLOSE) < 0)
454
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
455
456
    /* Register the dataset I/O selection property */
457
1
    if (H5P__register_real(pclass, H5D_XFER_DSET_IO_SEL_NAME, H5D_XFER_DSET_IO_SEL_SIZE,
458
1
                           &H5D_def_dset_io_sel_g, NULL, NULL, NULL, NULL, NULL, NULL,
459
1
                           H5D_XFER_DSET_IO_SEL_COPY, H5D_XFER_DSET_IO_SEL_CMP,
460
1
                           H5D_XFER_DSET_IO_SEL_CLOSE) < 0)
461
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
462
463
1
    if (H5P__register_real(pclass, H5D_XFER_SELECTION_IO_MODE_NAME, H5D_XFER_SELECTION_IO_MODE_SIZE,
464
1
                           &H5D_def_selection_io_mode_g, NULL, NULL, NULL, H5D_XFER_SELECTION_IO_MODE_ENC,
465
1
                           H5D_XFER_SELECTION_IO_MODE_DEC, NULL, NULL, NULL, NULL) < 0)
466
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
467
468
    /* Register the cause of no selection I/O property */
469
    /* (Note: this property should not have an encode/decode callback) */
470
1
    if (H5P__register_real(pclass, H5D_XFER_NO_SELECTION_IO_CAUSE_NAME, H5D_XFER_NO_SELECTION_IO_CAUSE_SIZE,
471
1
                           &H5D_def_no_selection_io_cause_g, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
472
1
                           NULL) < 0)
473
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
474
475
    /* Register the actual selection I/O mode property */
476
    /* (Note: this property should not have an encode/decode callback) */
477
1
    if (H5P__register_real(pclass, H5D_XFER_ACTUAL_SELECTION_IO_MODE_NAME,
478
1
                           H5D_XFER_ACTUAL_SELECTION_IO_MODE_SIZE, &H5D_def_actual_selection_io_mode_g, NULL,
479
1
                           NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
480
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
481
482
    /* Register the modify write buffer property */
483
1
    if (H5P__register_real(pclass, H5D_XFER_MODIFY_WRITE_BUF_NAME, H5D_XFER_MODIFY_WRITE_BUF_SIZE,
484
1
                           &H5D_def_modify_write_buf_g, NULL, NULL, NULL, H5D_XFER_MODIFY_WRITE_BUF_ENC,
485
1
                           H5D_XFER_MODIFY_WRITE_BUF_DEC, NULL, NULL, NULL, NULL) < 0)
486
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class");
487
488
1
done:
489
1
    FUNC_LEAVE_NOAPI(ret_value)
490
1
} /* end H5P__dxfr_reg_prop() */
491
492
/*-------------------------------------------------------------------------
493
 * Function:       H5P__dxfr_bkgr_buf_type_enc
494
 *
495
 * Purpose:        Callback routine which is called whenever the background
496
 *                 buffer type property in the dataset transfer property list
497
 *                 is encoded.
498
 *
499
 * Return:     Success: Non-negative
500
 *       Failure: Negative
501
 *
502
 *-------------------------------------------------------------------------
503
 */
504
static herr_t
505
H5P__dxfr_bkgr_buf_type_enc(const void *value, void **_pp, size_t *size)
506
0
{
507
0
    const H5T_bkg_t *bkgr_buf_type = (const H5T_bkg_t *)value; /* Create local alias for values */
508
0
    uint8_t        **pp            = (uint8_t **)_pp;
509
510
0
    FUNC_ENTER_PACKAGE_NOERR
511
512
    /* Sanity check */
513
0
    assert(bkgr_buf_type);
514
0
    assert(size);
515
516
0
    if (NULL != *pp)
517
        /* Encode background buffer type */
518
0
        *(*pp)++ = (uint8_t)*bkgr_buf_type;
519
520
    /* Size of background buffer type */
521
0
    (*size)++;
522
523
0
    FUNC_LEAVE_NOAPI(SUCCEED)
524
0
} /* end H5P__dxfr_bkgr_buf_type_enc() */
525
526
/*-------------------------------------------------------------------------
527
 * Function:       H5P__dxfr_bkgr_buf_type_dec
528
 *
529
 * Purpose:        Callback routine which is called whenever the background
530
 *                 buffer type property in the dataset transfer property list
531
 *                 is decoded.
532
 *
533
 * Return:     Success: Non-negative
534
 *       Failure: Negative
535
 *
536
 *-------------------------------------------------------------------------
537
 */
538
static herr_t
539
H5P__dxfr_bkgr_buf_type_dec(const void **_pp, void *_value)
540
0
{
541
0
    H5T_bkg_t      *bkgr_buf_type = (H5T_bkg_t *)_value; /* Background buffer type */
542
0
    const uint8_t **pp            = (const uint8_t **)_pp;
543
544
0
    FUNC_ENTER_PACKAGE_NOERR
545
546
    /* Sanity checks */
547
0
    assert(pp);
548
0
    assert(*pp);
549
0
    assert(bkgr_buf_type);
550
551
    /* Decode background buffer type */
552
0
    *bkgr_buf_type = (H5T_bkg_t) * (*pp)++;
553
554
0
    FUNC_LEAVE_NOAPI(SUCCEED)
555
0
} /* end H5P__dxfr_bkgr_buf_type_dec() */
556
557
/*-------------------------------------------------------------------------
558
 * Function:       H5P__dxfr_btree_split_ratio_enc
559
 *
560
 * Purpose:        Callback routine which is called whenever the B-tree split
561
 *                 ratio property in the dataset transfer property list
562
 *                 is encoded.
563
 *
564
 * Return:     Success: Non-negative
565
 *       Failure: Negative
566
 *
567
 *-------------------------------------------------------------------------
568
 */
569
static herr_t
570
H5P__dxfr_btree_split_ratio_enc(const void *value, void **_pp, size_t *size)
571
0
{
572
0
    const double *btree_split_ratio = (const double *)value; /* Create local alias for values */
573
0
    uint8_t     **pp                = (uint8_t **)_pp;
574
575
0
    FUNC_ENTER_PACKAGE_NOERR
576
577
    /* Sanity check */
578
0
    assert(btree_split_ratio);
579
0
    assert(size);
580
581
0
    if (NULL != *pp) {
582
        /* Encode the size of a double*/
583
0
        *(*pp)++ = (uint8_t)sizeof(double);
584
585
        /* Encode the left split value */
586
0
        H5_ENCODE_DOUBLE(*pp, *(const double *)btree_split_ratio);
587
0
        btree_split_ratio++;
588
589
        /* Encode the middle split value */
590
0
        H5_ENCODE_DOUBLE(*pp, *(const double *)btree_split_ratio);
591
0
        btree_split_ratio++;
592
593
        /* Encode the right split value */
594
0
        H5_ENCODE_DOUBLE(*pp, *(const double *)btree_split_ratio);
595
0
    } /* end if */
596
597
    /* Size of B-tree split ratio values */
598
0
    *size += 1 + (3 * sizeof(double));
599
600
0
    FUNC_LEAVE_NOAPI(SUCCEED)
601
0
} /* end H5P__dxfr_btree_split_ratio_enc() */
602
603
/*-------------------------------------------------------------------------
604
 * Function:       H5P__dxfr_btree_split_ratio_dec
605
 *
606
 * Purpose:        Callback routine which is called whenever the B-tree split
607
 *                 ratio property in the dataset transfer property list
608
 *                 is decoded.
609
 *
610
 * Return:     Success: Non-negative
611
 *       Failure: Negative
612
 *
613
 *-------------------------------------------------------------------------
614
 */
615
static herr_t
616
H5P__dxfr_btree_split_ratio_dec(const void **_pp, void *_value)
617
0
{
618
0
    double         *btree_split_ratio = (double *)_value; /* B-tree split ratio */
619
0
    unsigned        enc_size;                             /* Size of encoded property */
620
0
    const uint8_t **pp        = (const uint8_t **)_pp;
621
0
    herr_t          ret_value = SUCCEED; /* Return value */
622
623
0
    FUNC_ENTER_PACKAGE
624
625
    /* Sanity checks */
626
0
    assert(pp);
627
0
    assert(*pp);
628
0
    assert(btree_split_ratio);
629
630
    /* Decode the size */
631
0
    enc_size = *(*pp)++;
632
0
    if (enc_size != sizeof(double))
633
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "double value can't be decoded");
634
635
    /* Decode the left, middle & left B-tree split ratios */
636
0
    H5_DECODE_DOUBLE(*pp, btree_split_ratio[0]);
637
0
    H5_DECODE_DOUBLE(*pp, btree_split_ratio[1]);
638
0
    H5_DECODE_DOUBLE(*pp, btree_split_ratio[2]);
639
640
0
done:
641
0
    FUNC_LEAVE_NOAPI(ret_value)
642
0
} /* end H5P__dxfr_btree_split_ratio_dec() */
643
644
/*-------------------------------------------------------------------------
645
 * Function:    H5P__dxfr_xform_set
646
 *
647
 * Purpose:     Copies a data transform property when it's set for a property list
648
 *
649
 * Return:      Success:        Non-negative
650
 *              Failure:        Negative
651
 *
652
 *-------------------------------------------------------------------------
653
 */
654
static herr_t
655
H5P__dxfr_xform_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size,
656
                    void *value)
657
0
{
658
0
    herr_t ret_value = SUCCEED; /* Return value */
659
660
0
    FUNC_ENTER_PACKAGE
661
662
    /* Sanity check */
663
0
    assert(value);
664
665
    /* Make copy of data transform */
666
0
    if (H5Z_xform_copy((H5Z_data_xform_t **)value) < 0)
667
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info");
668
669
0
done:
670
0
    FUNC_LEAVE_NOAPI(ret_value)
671
0
} /* end H5P__dxfr_xform_set() */
672
673
/*-------------------------------------------------------------------------
674
 * Function:    H5P__dxfr_xform_get
675
 *
676
 * Purpose:     Copies a data transform property when it's retrieved for a property list
677
 *
678
 * Return:      Success:        Non-negative
679
 *              Failure:        Negative
680
 *
681
 *-------------------------------------------------------------------------
682
 */
683
static herr_t
684
H5P__dxfr_xform_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size,
685
                    void *value)
686
0
{
687
0
    herr_t ret_value = SUCCEED; /* Return value */
688
689
0
    FUNC_ENTER_PACKAGE
690
691
    /* Sanity check */
692
0
    assert(value);
693
694
    /* Make copy of data transform */
695
0
    if (H5Z_xform_copy((H5Z_data_xform_t **)value) < 0)
696
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info");
697
698
0
done:
699
0
    FUNC_LEAVE_NOAPI(ret_value)
700
0
} /* end H5P__dxfr_xform_get() */
701
702
/*-------------------------------------------------------------------------
703
 * Function:       H5P__dxfr_xform_enc
704
 *
705
 * Purpose:        Callback routine which is called whenever the data transform
706
 *                 property in the dataset transfer property list
707
 *                 is encoded.
708
 *
709
 * Return:     Success: Non-negative
710
 *       Failure: Negative
711
 *
712
 *-------------------------------------------------------------------------
713
 */
714
static herr_t
715
H5P__dxfr_xform_enc(const void *value, void **_pp, size_t *size)
716
0
{
717
0
    const H5Z_data_xform_t *data_xform_prop =
718
0
        *(const H5Z_data_xform_t *const *)value; /* Create local alias for values */
719
0
    const char *pexp      = NULL;                /* Pointer to transform expression */
720
0
    size_t      len       = 0;                   /* Length of transform expression */
721
0
    uint8_t   **pp        = (uint8_t **)_pp;
722
0
    herr_t      ret_value = SUCCEED; /* Return value */
723
724
0
    FUNC_ENTER_PACKAGE
725
726
    /* Sanity check */
727
0
    HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
728
0
    assert(size);
729
730
    /* Check for data transform set */
731
0
    if (NULL != data_xform_prop) {
732
        /* Get the transform expression */
733
0
        if (NULL == (pexp = H5Z_xform_extract_xform_str(data_xform_prop)))
734
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "failed to retrieve transform expression");
735
736
        /* Get the transform string expression size */
737
0
        len = strlen(pexp) + 1;
738
0
    } /* end if */
739
740
0
    if (NULL != *pp) {
741
0
        uint64_t enc_value;
742
0
        unsigned enc_size;
743
744
        /* encode the length of the prefix */
745
0
        enc_value = (uint64_t)len;
746
0
        enc_size  = H5VM_limit_enc_size(enc_value);
747
0
        assert(enc_size < 256);
748
0
        *(*pp)++ = (uint8_t)enc_size;
749
0
        UINT64ENCODE_VAR(*pp, enc_value, enc_size);
750
751
0
        if (NULL != data_xform_prop) {
752
            /* Sanity check */
753
0
            assert(pexp);
754
755
            /* Copy the expression into the buffer */
756
0
            H5MM_memcpy(*pp, (const uint8_t *)pexp, len);
757
0
            *pp += len;
758
0
            *pp[0] = '\0';
759
0
        } /* end if */
760
0
    }     /* end if */
761
762
    /* Size of encoded data transform */
763
0
    *size += (1 + H5VM_limit_enc_size((uint64_t)len));
764
0
    if (NULL != pexp)
765
0
        *size += len;
766
767
0
done:
768
0
    FUNC_LEAVE_NOAPI(ret_value)
769
0
} /* end H5P__dxfr_xform_enc() */
770
771
/*-------------------------------------------------------------------------
772
 * Function:       H5P__dxfr_xform_dec
773
 *
774
 * Purpose:        Callback routine which is called whenever the data transform
775
 *                 property in the dataset transfer property list
776
 *                 is decoded.
777
 *
778
 * Return:     Success: Non-negative
779
 *       Failure: Negative
780
 *
781
 *-------------------------------------------------------------------------
782
 */
783
static herr_t
784
H5P__dxfr_xform_dec(const void **_pp, void *_value)
785
0
{
786
0
    H5Z_data_xform_t **data_xform_prop = (H5Z_data_xform_t **)_value; /* New data xform property */
787
0
    size_t             len;                                           /* Length of encoded string */
788
0
    const uint8_t    **pp = (const uint8_t **)_pp;
789
0
    unsigned           enc_size;
790
0
    uint64_t           enc_value;
791
0
    herr_t             ret_value = SUCCEED; /* Return value */
792
793
0
    FUNC_ENTER_PACKAGE
794
795
    /* Sanity checks */
796
0
    assert(pp);
797
0
    assert(*pp);
798
0
    assert(data_xform_prop);
799
0
    HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
800
801
    /* Decode the length of xform expression */
802
0
    enc_size = *(*pp)++;
803
0
    assert(enc_size < 256);
804
0
    UINT64DECODE_VAR(*pp, enc_value, enc_size);
805
0
    len = (size_t)enc_value;
806
807
0
    if (0 != len) {
808
0
        if (NULL == (*data_xform_prop = H5Z_xform_create((const char *)*pp)))
809
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create data transform info");
810
0
        *pp += len;
811
0
    } /* end if */
812
0
    else
813
0
        *data_xform_prop = H5D_XFER_XFORM_DEF;
814
815
0
done:
816
0
    FUNC_LEAVE_NOAPI(ret_value)
817
0
} /* end H5P__dxfr_xform_dec() */
818
819
/*-------------------------------------------------------------------------
820
 * Function: H5P__dxfr_xform_del
821
 *
822
 * Purpose: Frees memory allocated by H5P_dxfr_xform_set
823
 *
824
 * Return: Success: SUCCEED, Failure: FAIL
825
 *
826
 *-------------------------------------------------------------------------
827
 */
828
static herr_t
829
H5P__dxfr_xform_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size,
830
                    void *value)
831
0
{
832
0
    herr_t ret_value = SUCCEED; /* Return value */
833
834
0
    FUNC_ENTER_PACKAGE
835
836
0
    assert(value);
837
838
0
    if (H5Z_xform_destroy(*(H5Z_data_xform_t **)value) < 0)
839
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing the parse tree");
840
841
0
done:
842
0
    FUNC_LEAVE_NOAPI(ret_value)
843
0
} /* end H5P__dxfr_xform_del() */
844
845
/*-------------------------------------------------------------------------
846
 * Function: H5P__dxfr_xform_copy
847
 *
848
 * Purpose: Creates a copy of the user's data transform string and its
849
 *              associated parse tree.
850
 *
851
 * Return: Success: SUCCEED, Failure: FAIL
852
 *
853
 *-------------------------------------------------------------------------
854
 */
855
static herr_t
856
H5P__dxfr_xform_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
857
0
{
858
0
    herr_t ret_value = SUCCEED; /* Return value */
859
860
0
    FUNC_ENTER_PACKAGE
861
862
    /* Sanity check */
863
0
    assert(value);
864
865
    /* Make copy of data transform */
866
0
    if (H5Z_xform_copy((H5Z_data_xform_t **)value) < 0)
867
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the data transform info");
868
869
0
done:
870
0
    FUNC_LEAVE_NOAPI(ret_value)
871
0
} /* end H5P__dxfr_xform_copy() */
872
873
/*-------------------------------------------------------------------------
874
 * Function: H5P__dxfr_xform_cmp
875
 *
876
 * Purpose: Compare two data transforms.
877
 *
878
 * Return: positive if VALUE1 is greater than VALUE2, negative if VALUE2 is
879
 *    greater than VALUE1 and zero if VALUE1 and VALUE2 are equal.
880
 *
881
 *-------------------------------------------------------------------------
882
 */
883
static int
884
H5P__dxfr_xform_cmp(const void *_xform1, const void *_xform2, size_t H5_ATTR_UNUSED size)
885
0
{
886
0
    const H5Z_data_xform_t *const *xform1 =
887
0
        (const H5Z_data_xform_t *const *)_xform1; /* Create local aliases for values */
888
0
    const H5Z_data_xform_t *const *xform2 =
889
0
        (const H5Z_data_xform_t *const *)_xform2; /* Create local aliases for values */
890
0
    const char *pexp1, *pexp2;                    /* Pointers to transform expressions */
891
0
    herr_t      ret_value = 0;                    /* Return value */
892
893
0
    FUNC_ENTER_PACKAGE_NOERR
894
895
    /* Sanity check */
896
0
    assert(xform1);
897
0
    assert(xform2);
898
0
    assert(size == sizeof(H5Z_data_xform_t *));
899
900
    /* Check for a property being set */
901
0
    if (*xform1 == NULL && *xform2 != NULL)
902
0
        HGOTO_DONE(-1);
903
0
    if (*xform1 != NULL && *xform2 == NULL)
904
0
        HGOTO_DONE(1);
905
906
0
    if (*xform1) {
907
0
        assert(*xform2);
908
909
        /* Get the transform expressions */
910
0
        pexp1 = H5Z_xform_extract_xform_str(*xform1);
911
0
        pexp2 = H5Z_xform_extract_xform_str(*xform2);
912
913
        /* Check for property expressions */
914
0
        if (pexp1 == NULL && pexp2 != NULL)
915
0
            HGOTO_DONE(-1);
916
0
        if (pexp1 != NULL && pexp2 == NULL)
917
0
            HGOTO_DONE(1);
918
919
0
        if (pexp1) {
920
0
            assert(pexp2);
921
0
            ret_value = strcmp(pexp1, pexp2);
922
0
        } /* end if */
923
0
    }     /* end if */
924
925
0
done:
926
0
    FUNC_LEAVE_NOAPI(ret_value)
927
0
} /* end H5P__dxfr_xform_cmp() */
928
929
/*-------------------------------------------------------------------------
930
 * Function: H5P__dxfr_xform_close
931
 *
932
 * Purpose: Frees memory allocated by H5P_dxfr_xform_set
933
 *
934
 * Return: Success: SUCCEED, Failure: FAIL
935
 *
936
 *-------------------------------------------------------------------------
937
 */
938
static herr_t
939
H5P__dxfr_xform_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
940
1
{
941
1
    herr_t ret_value = SUCCEED; /* Return value */
942
943
1
    FUNC_ENTER_PACKAGE
944
945
1
    assert(value);
946
947
1
    if (H5Z_xform_destroy(*(H5Z_data_xform_t **)value) < 0)
948
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing the parse tree");
949
950
1
done:
951
1
    FUNC_LEAVE_NOAPI(ret_value)
952
1
} /* end H5P__dxfr_xform_close() */
953
954
/*-------------------------------------------------------------------------
955
 * Function:  H5Pset_data_transform
956
 *
957
 * Purpose: Sets data transform expression.
958
 *
959
 * Return:  Non-negative on success/Negative on failure
960
 *
961
 *-------------------------------------------------------------------------
962
 */
963
herr_t
964
H5Pset_data_transform(hid_t plist_id, const char *expression)
965
0
{
966
0
    H5P_genplist_t   *plist;                     /* Property list pointer */
967
0
    H5Z_data_xform_t *data_xform_prop = NULL;    /* New data xform property */
968
0
    herr_t            ret_value       = SUCCEED; /* return value */
969
970
0
    FUNC_ENTER_API(FAIL)
971
972
    /* Check arguments */
973
0
    if (expression == NULL)
974
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "expression cannot be NULL");
975
976
    /* Get the plist structure */
977
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, false)))
978
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
979
980
    /* See if a data transform is already set, and free it if it is */
981
0
    if (H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0)
982
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting data transform expression");
983
984
    /* Destroy previous data transform property */
985
0
    if (H5Z_xform_destroy(data_xform_prop) < 0)
986
0
        HGOTO_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release data transform expression");
987
988
    /* Create data transform info from expression */
989
0
    if (NULL == (data_xform_prop = H5Z_xform_create(expression)))
990
0
        HGOTO_ERROR(H5E_PLIST, H5E_NOSPACE, FAIL, "unable to create data transform info");
991
992
    /* Update property list (takes ownership of transform) */
993
0
    if (H5P_poke(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0)
994
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Error setting data transform expression");
995
996
0
done:
997
0
    if (ret_value < 0)
998
0
        if (data_xform_prop && H5Z_xform_destroy(data_xform_prop) < 0)
999
0
            HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release data transform expression");
1000
1001
0
    FUNC_LEAVE_API(ret_value)
1002
0
} /* end H5Pset_data_transform() */
1003
1004
/*-------------------------------------------------------------------------
1005
 * Function:  H5Pget_data_transform
1006
 *
1007
 * Purpose: Gets data transform expression.
1008
 *
1009
 * Return:  Non-negative on success/Negative on failure
1010
 *
1011
 * Comments:
1012
 *  If `expression' is non-NULL then write up to `size' bytes into that
1013
 *  buffer and always return the length of the transform name.
1014
 *  Otherwise `size' is ignored and the function does not store the expression,
1015
 *  just returning the number of characters required to store the expression.
1016
 *  If an error occurs then the buffer pointed to by `expression' (NULL or non-NULL)
1017
 *  is unchanged and the function returns a negative value.
1018
 *  If a zero is returned for the name's length, then there is no name
1019
 *  associated with the ID.
1020
 *
1021
 *-------------------------------------------------------------------------
1022
 */
1023
ssize_t
1024
H5Pget_data_transform(hid_t plist_id, char *expression /*out*/, size_t size)
1025
0
{
1026
0
    H5P_genplist_t   *plist;                  /* Property list pointer */
1027
0
    H5Z_data_xform_t *data_xform_prop = NULL; /* New data xform property */
1028
0
    size_t            len;
1029
0
    const char       *pexp;
1030
0
    ssize_t           ret_value; /* return value */
1031
1032
0
    FUNC_ENTER_API(FAIL)
1033
1034
    /* Get the plist structure */
1035
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
1036
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1037
1038
0
    if (H5P_peek(plist, H5D_XFER_XFORM_NAME, &data_xform_prop) < 0)
1039
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting data transform expression");
1040
1041
0
    if (NULL == data_xform_prop)
1042
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "data transform has not been set");
1043
1044
    /* Get the data transform string */
1045
0
    if (NULL == (pexp = H5Z_xform_extract_xform_str(data_xform_prop)))
1046
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "failed to retrieve transform expression");
1047
1048
    /* Copy into application buffer */
1049
0
    len = strlen(pexp);
1050
0
    if (expression) {
1051
0
        strncpy(expression, pexp, size);
1052
0
        if (len >= size)
1053
0
            expression[size - 1] = '\0';
1054
0
    } /* end if */
1055
1056
0
    ret_value = (ssize_t)len;
1057
1058
0
done:
1059
0
    FUNC_LEAVE_API(ret_value)
1060
0
} /* end H5Pget_data_transform() */
1061
1062
/*-------------------------------------------------------------------------
1063
 * Function:  H5Pset_buffer
1064
 *
1065
 * Purpose: Given a dataset transfer property list, set the maximum size
1066
 *    for the type conversion buffer and background buffer and
1067
 *    optionally supply pointers to application-allocated buffers.
1068
 *    If the buffer size is smaller than the entire amount of data
1069
 *    being transferred between application and file, and a type
1070
 *    conversion buffer or background buffer is required then
1071
 *    strip mining will be used.
1072
 *
1073
 *    If TCONV and/or BKG are null pointers then buffers will be
1074
 *    allocated and freed during the data transfer.
1075
 *
1076
 * Return:  Non-negative on success/Negative on failure
1077
 *
1078
 *-------------------------------------------------------------------------
1079
 */
1080
herr_t
1081
H5Pset_buffer(hid_t plist_id, size_t size, void *tconv, void *bkg)
1082
0
{
1083
0
    H5P_genplist_t *plist;               /* Property list pointer */
1084
0
    herr_t          ret_value = SUCCEED; /* return value */
1085
1086
0
    FUNC_ENTER_API(FAIL)
1087
1088
    /* Check arguments */
1089
0
    if (size == 0)
1090
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buffer size must not be zero");
1091
1092
    /* Get the plist structure */
1093
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, false)))
1094
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1095
1096
    /* Update property list */
1097
0
    if (H5P_set(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size) < 0)
1098
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Can't set transfer buffer size");
1099
0
    if (H5P_set(plist, H5D_XFER_TCONV_BUF_NAME, &tconv) < 0)
1100
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Can't set transfer type conversion buffer");
1101
0
    if (H5P_set(plist, H5D_XFER_BKGR_BUF_NAME, &bkg) < 0)
1102
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "Can't set background type conversion buffer");
1103
1104
0
done:
1105
0
    FUNC_LEAVE_API(ret_value)
1106
0
} /* end H5Pset_buffer() */
1107
1108
/*-------------------------------------------------------------------------
1109
 * Function:  H5Pget_buffer
1110
 *
1111
 * Purpose: Reads values previously set with H5Pset_buffer().
1112
 *
1113
 * Return:  Success:  Buffer size.
1114
 *
1115
 *    Failure:  0
1116
 *
1117
 *-------------------------------------------------------------------------
1118
 */
1119
size_t
1120
H5Pget_buffer(hid_t plist_id, void **tconv /*out*/, void **bkg /*out*/)
1121
0
{
1122
0
    H5P_genplist_t *plist;     /* Property list pointer */
1123
0
    size_t          size;      /* Type conversion buffer size */
1124
0
    size_t          ret_value; /* Return value */
1125
1126
0
    FUNC_ENTER_API(0)
1127
1128
    /* Get the plist structure */
1129
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
1130
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, 0, "can't find object for ID");
1131
1132
    /* Return values */
1133
0
    if (tconv)
1134
0
        if (H5P_get(plist, H5D_XFER_TCONV_BUF_NAME, tconv) < 0)
1135
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "Can't get transfer type conversion buffer");
1136
0
    if (bkg)
1137
0
        if (H5P_get(plist, H5D_XFER_BKGR_BUF_NAME, bkg) < 0)
1138
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, 0, "Can't get background type conversion buffer");
1139
1140
    /* Get the size */
1141
0
    if (H5P_get(plist, H5D_XFER_MAX_TEMP_BUF_NAME, &size) < 0)
1142
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, 0, "Can't set transfer buffer size");
1143
1144
    /* Set the return value */
1145
0
    ret_value = size;
1146
1147
0
done:
1148
0
    FUNC_LEAVE_API(ret_value)
1149
0
} /* end H5Pget_buffer() */
1150
1151
/*-------------------------------------------------------------------------
1152
 * Function:  H5Pset_preserve
1153
 *
1154
 * Purpose: When reading or writing compound data types and the
1155
 *    destination is partially initialized and the read/write is
1156
 *    intended to initialize the other members, one must set this
1157
 *    property to true.  Otherwise the I/O pipeline treats the
1158
 *    destination datapoints as completely uninitialized.
1159
 *
1160
 * Return:  Non-negative on success/Negative on failure
1161
 *
1162
 *-------------------------------------------------------------------------
1163
 */
1164
herr_t
1165
H5Pset_preserve(hid_t plist_id, hbool_t status)
1166
0
{
1167
0
    H5P_genplist_t *plist;               /* Property list pointer */
1168
0
    H5T_bkg_t       need_bkg;            /* Value for background buffer type */
1169
0
    herr_t          ret_value = SUCCEED; /* return value */
1170
1171
0
    FUNC_ENTER_API(FAIL)
1172
1173
    /* Get the plist structure */
1174
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, false)))
1175
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1176
1177
    /* Update property list */
1178
0
    need_bkg = status ? H5T_BKG_YES : H5T_BKG_NO;
1179
0
    if (H5P_set(plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &need_bkg) < 0)
1180
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
1181
1182
0
done:
1183
0
    FUNC_LEAVE_API(ret_value)
1184
0
} /* end H5Pset_preserve() */
1185
1186
/*-------------------------------------------------------------------------
1187
 * Function:  H5Pget_preserve
1188
 *
1189
 * Purpose: The inverse of H5Pset_preserve()
1190
 *
1191
 * Return:  Success:  true or false
1192
 *
1193
 *    Failure:  Negative
1194
 *
1195
 *-------------------------------------------------------------------------
1196
 */
1197
int
1198
H5Pget_preserve(hid_t plist_id)
1199
0
{
1200
0
    H5T_bkg_t       need_bkg;  /* Background value */
1201
0
    H5P_genplist_t *plist;     /* Property list pointer */
1202
0
    int             ret_value; /* return value */
1203
1204
0
    FUNC_ENTER_API(FAIL)
1205
1206
    /* Get the plist structure */
1207
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
1208
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1209
1210
    /* Get value */
1211
0
    if (H5P_get(plist, H5D_XFER_BKGR_BUF_TYPE_NAME, &need_bkg) < 0)
1212
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
1213
1214
    /* Set return value */
1215
0
    ret_value = need_bkg ? true : false;
1216
1217
0
done:
1218
0
    FUNC_LEAVE_API(ret_value)
1219
0
} /* end H5Pget_preserve() */
1220
1221
/*-------------------------------------------------------------------------
1222
 * Function:  H5Pset_edc_check
1223
 *
1224
 * Purpose:     Enable or disable error-detecting for a dataset reading
1225
 *              process.  This error-detecting algorithm is whichever
1226
 *              user chooses earlier.  This function cannot control
1227
 *              writing process.
1228
 *
1229
 * Return:  Non-negative on success/Negative on failure
1230
 *
1231
 *-------------------------------------------------------------------------
1232
 */
1233
herr_t
1234
H5Pset_edc_check(hid_t plist_id, H5Z_EDC_t check)
1235
0
{
1236
0
    H5P_genplist_t *plist;               /* Property list pointer */
1237
0
    herr_t          ret_value = SUCCEED; /* return value */
1238
1239
0
    FUNC_ENTER_API(FAIL)
1240
1241
    /* Check argument */
1242
0
    if (check != H5Z_ENABLE_EDC && check != H5Z_DISABLE_EDC)
1243
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid value");
1244
1245
    /* Get the plist structure */
1246
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, false)))
1247
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1248
1249
    /* Update property list */
1250
0
    if (H5P_set(plist, H5D_XFER_EDC_NAME, &check) < 0)
1251
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
1252
1253
0
done:
1254
0
    FUNC_LEAVE_API(ret_value)
1255
0
} /* end H5Pset_edc_check() */
1256
1257
/*-------------------------------------------------------------------------
1258
 * Function:  H5Pget_edc_check
1259
 *
1260
 * Purpose:     Enable or disable error-detecting for a dataset reading
1261
 *              process.  This error-detecting algorithm is whichever
1262
 *              user chooses earlier.  This function cannot control
1263
 *              writing process.
1264
 *
1265
 * Return:  Non-negative on success/Negative on failure
1266
 *
1267
 *-------------------------------------------------------------------------
1268
 */
1269
H5Z_EDC_t
1270
H5Pget_edc_check(hid_t plist_id)
1271
0
{
1272
0
    H5P_genplist_t *plist;     /* Property list pointer */
1273
0
    H5Z_EDC_t       ret_value; /* Return value */
1274
1275
0
    FUNC_ENTER_API(H5Z_ERROR_EDC)
1276
1277
    /* Get the plist structure */
1278
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
1279
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, H5Z_ERROR_EDC, "can't find object for ID");
1280
1281
    /* Update property list */
1282
0
    if (H5P_get(plist, H5D_XFER_EDC_NAME, &ret_value) < 0)
1283
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5Z_ERROR_EDC, "unable to set value");
1284
1285
0
done:
1286
0
    FUNC_LEAVE_API(ret_value)
1287
0
} /* end H5Pget_edc_check() */
1288
1289
/*-------------------------------------------------------------------------
1290
 * Function:  H5Pset_filter_callback
1291
 *
1292
 * Purpose:     Sets user's callback function for dataset transfer property
1293
 *              list.  This callback function defines what user wants to do
1294
 *              if certain filter fails.
1295
 *
1296
 * Return:  Non-negative on success/Negative on failure
1297
 *
1298
 *-------------------------------------------------------------------------
1299
 */
1300
herr_t
1301
H5Pset_filter_callback(hid_t plist_id, H5Z_filter_func_t func, void *op_data)
1302
0
{
1303
0
    H5P_genplist_t *plist;               /* Property list pointer */
1304
0
    herr_t          ret_value = SUCCEED; /* return value */
1305
0
    H5Z_cb_t        cb_struct;
1306
1307
0
    FUNC_ENTER_API(FAIL)
1308
1309
    /* Get the plist structure */
1310
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, false)))
1311
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1312
1313
    /* Update property list */
1314
0
    cb_struct.func    = func;
1315
0
    cb_struct.op_data = op_data;
1316
1317
0
    if (H5P_set(plist, H5D_XFER_FILTER_CB_NAME, &cb_struct) < 0)
1318
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
1319
1320
0
done:
1321
0
    FUNC_LEAVE_API(ret_value)
1322
0
}
1323
1324
/*-------------------------------------------------------------------------
1325
 * Function:  H5Pset_type_conv_cb
1326
 *
1327
 * Purpose:     Sets user's callback function for dataset transfer property
1328
 *              list.  This callback function defines what user wants to do
1329
 *              if there's exception during datatype conversion.
1330
 *
1331
 * Return:  Non-negative on success/Negative on failure
1332
 *
1333
 *-------------------------------------------------------------------------
1334
 */
1335
herr_t
1336
H5Pset_type_conv_cb(hid_t plist_id, H5T_conv_except_func_t op, void *operate_data)
1337
0
{
1338
0
    H5P_genplist_t *plist;               /* Property list pointer */
1339
0
    herr_t          ret_value = SUCCEED; /* return value */
1340
0
    H5T_conv_cb_t   cb_struct;
1341
1342
0
    FUNC_ENTER_API(FAIL)
1343
1344
    /* Get the plist structure */
1345
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, false)))
1346
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1347
1348
    /* Update property list */
1349
0
    cb_struct.func      = op;
1350
0
    cb_struct.user_data = operate_data;
1351
1352
0
    if (H5P_set(plist, H5D_XFER_CONV_CB_NAME, &cb_struct) < 0)
1353
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
1354
1355
0
done:
1356
0
    FUNC_LEAVE_API(ret_value)
1357
0
}
1358
1359
/*-------------------------------------------------------------------------
1360
 * Function:  H5Pget_type_conv_cb
1361
 *
1362
 * Purpose:     Gets callback function for dataset transfer property
1363
 *              list.  This callback function defines what user wants to do
1364
 *              if there's exception during datatype conversion.
1365
 *
1366
 * Return:  Non-negative on success/Negative on failure
1367
 *
1368
 *-------------------------------------------------------------------------
1369
 */
1370
herr_t
1371
H5Pget_type_conv_cb(hid_t plist_id, H5T_conv_except_func_t *op /*out*/, void **operate_data /*out*/)
1372
0
{
1373
0
    H5P_genplist_t *plist; /* Property list pointer */
1374
0
    H5T_conv_cb_t   cb_struct;
1375
0
    herr_t          ret_value = SUCCEED; /* return value */
1376
1377
0
    FUNC_ENTER_API(FAIL)
1378
1379
    /* Get the plist structure */
1380
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
1381
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1382
1383
    /* Get property */
1384
0
    if (H5P_get(plist, H5D_XFER_CONV_CB_NAME, &cb_struct) < 0)
1385
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
1386
1387
    /* Assign return value */
1388
0
    *op           = cb_struct.func;
1389
0
    *operate_data = cb_struct.user_data;
1390
1391
0
done:
1392
0
    FUNC_LEAVE_API(ret_value)
1393
0
}
1394
1395
/*-------------------------------------------------------------------------
1396
 * Function:  H5Pget_btree_ratios
1397
 *
1398
 * Purpose: Queries B-tree split ratios.  See H5Pset_btree_ratios().
1399
 *
1400
 * Return:  Success:  Non-negative with split ratios returned through
1401
 *        the non-null arguments.
1402
 *
1403
 *    Failure:  Negative
1404
 *
1405
 *-------------------------------------------------------------------------
1406
 */
1407
herr_t
1408
H5Pget_btree_ratios(hid_t plist_id, double *left /*out*/, double *middle /*out*/, double *right /*out*/)
1409
0
{
1410
0
    H5P_genplist_t *plist;                /* Property list pointer */
1411
0
    double          btree_split_ratio[3]; /* B-tree node split ratios */
1412
0
    herr_t          ret_value = SUCCEED;  /* Return value */
1413
1414
0
    FUNC_ENTER_API(FAIL)
1415
1416
    /* Get the plist structure */
1417
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
1418
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1419
1420
    /* Get the split ratios */
1421
0
    if (H5P_get(plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &btree_split_ratio) < 0)
1422
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
1423
1424
    /* Get values */
1425
0
    if (left)
1426
0
        *left = btree_split_ratio[0];
1427
0
    if (middle)
1428
0
        *middle = btree_split_ratio[1];
1429
0
    if (right)
1430
0
        *right = btree_split_ratio[2];
1431
1432
0
done:
1433
0
    FUNC_LEAVE_API(ret_value)
1434
0
} /* end H5Pget_btree_ratios() */
1435
1436
/*-------------------------------------------------------------------------
1437
 * Function:  H5Pset_btree_ratios
1438
 *
1439
 * Purpose: Sets B-tree split ratios for a dataset transfer property
1440
 *    list. The split ratios determine what percent of children go
1441
 *    in the first node when a node splits.  The LEFT ratio is
1442
 *    used when the splitting node is the left-most node at its
1443
 *    level in the tree; the RIGHT ratio is when the splitting node
1444
 *    is the right-most node at its level; and the MIDDLE ratio for
1445
 *    all other cases.  A node which is the only node at its level
1446
 *    in the tree uses the RIGHT ratio when it splits.  All ratios
1447
 *    are real numbers between 0 and 1, inclusive.
1448
 *
1449
 * Return:  Non-negative on success/Negative on failure
1450
 *
1451
 *-------------------------------------------------------------------------
1452
 */
1453
herr_t
1454
H5Pset_btree_ratios(hid_t plist_id, double left, double middle, double right)
1455
0
{
1456
0
    H5P_genplist_t *plist;               /* Property list pointer */
1457
0
    double          split_ratio[3];      /* B-tree node split ratios */
1458
0
    herr_t          ret_value = SUCCEED; /* Return value */
1459
1460
0
    FUNC_ENTER_API(FAIL)
1461
1462
    /* Check arguments */
1463
0
    if (left < 0.0 || left > 1.0 || middle < 0.0 || middle > 1.0 || right < 0.0 || right > 1.0)
1464
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "split ratio must satisfy 0.0 <= X <= 1.0");
1465
1466
    /* Get the plist structure */
1467
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, false)))
1468
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1469
1470
    /* Set values */
1471
0
    split_ratio[0] = left;
1472
0
    split_ratio[1] = middle;
1473
0
    split_ratio[2] = right;
1474
1475
    /* Set the split ratios */
1476
0
    if (H5P_set(plist, H5D_XFER_BTREE_SPLIT_RATIO_NAME, &split_ratio) < 0)
1477
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
1478
1479
0
done:
1480
0
    FUNC_LEAVE_API(ret_value)
1481
0
} /* end H5Pset_btree_ratios() */
1482
1483
/*-------------------------------------------------------------------------
1484
 * Function:  H5P_set_vlen_mem_manager
1485
 *
1486
 * Purpose: Sets the memory allocate/free pair for VL datatypes.  The
1487
 *    allocation routine is called when data is read into a new
1488
 *    array and the free routine is called when H5Treclaim is
1489
 *    called.  The alloc_info and free_info are user parameters
1490
 *    which are passed to the allocation and freeing functions
1491
 *    respectively.  To reset the allocate/free functions to the
1492
 *    default setting of using the system's malloc/free functions,
1493
 *    call this routine with alloc_func and free_func set to NULL.
1494
 *
1495
 * Return:  Non-negative on success/Negative on failure
1496
 *
1497
 *-------------------------------------------------------------------------
1498
 */
1499
herr_t
1500
H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info,
1501
                         H5MM_free_t free_func, void *free_info)
1502
0
{
1503
0
    herr_t ret_value = SUCCEED; /* Return value */
1504
1505
0
    FUNC_ENTER_NOAPI(FAIL)
1506
1507
0
    assert(plist);
1508
1509
    /* Update property list */
1510
0
    if (H5P_set(plist, H5D_XFER_VLEN_ALLOC_NAME, &alloc_func) < 0)
1511
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
1512
0
    if (H5P_set(plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, &alloc_info) < 0)
1513
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
1514
0
    if (H5P_set(plist, H5D_XFER_VLEN_FREE_NAME, &free_func) < 0)
1515
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
1516
0
    if (H5P_set(plist, H5D_XFER_VLEN_FREE_INFO_NAME, &free_info) < 0)
1517
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
1518
1519
0
done:
1520
0
    FUNC_LEAVE_NOAPI(ret_value)
1521
0
} /* end H5P_set_vlen_mem_manager() */
1522
1523
/*-------------------------------------------------------------------------
1524
 * Function:  H5Pset_vlen_mem_manager
1525
 *
1526
 * Purpose: Sets the memory allocate/free pair for VL datatypes.  The
1527
 *    allocation routine is called when data is read into a new
1528
 *    array and the free routine is called when H5Treclaim is
1529
 *    called.  The alloc_info and free_info are user parameters
1530
 *    which are passed to the allocation and freeing functions
1531
 *    respectively.  To reset the allocate/free functions to the
1532
 *    default setting of using the system's malloc/free functions,
1533
 *    call this routine with alloc_func and free_func set to NULL.
1534
 *
1535
 * Return:  Non-negative on success/Negative on failure
1536
 *
1537
 *-------------------------------------------------------------------------
1538
 */
1539
herr_t
1540
H5Pset_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func,
1541
                        void *free_info)
1542
0
{
1543
0
    H5P_genplist_t *plist;               /* Property list pointer */
1544
0
    herr_t          ret_value = SUCCEED; /* Return value */
1545
1546
0
    FUNC_ENTER_API(FAIL)
1547
1548
    /* Check arguments */
1549
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, false)))
1550
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list");
1551
1552
    /* Update property list */
1553
0
    if (H5P_set_vlen_mem_manager(plist, alloc_func, alloc_info, free_func, free_info) < 0)
1554
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set values");
1555
1556
0
done:
1557
0
    FUNC_LEAVE_API(ret_value)
1558
0
} /* end H5Pset_vlen_mem_manager() */
1559
1560
/*-------------------------------------------------------------------------
1561
 * Function:  H5Pget_vlen_mem_manager
1562
 *
1563
 * Purpose: The inverse of H5Pset_vlen_mem_manager()
1564
 *
1565
 * Return:  Non-negative on success/Negative on failure
1566
 *
1567
 *-------------------------------------------------------------------------
1568
 */
1569
herr_t
1570
H5Pget_vlen_mem_manager(hid_t plist_id, H5MM_allocate_t *alloc_func /*out*/, void **alloc_info /*out*/,
1571
                        H5MM_free_t *free_func /*out*/, void **free_info /*out*/)
1572
0
{
1573
0
    H5P_genplist_t *plist;               /* Property list pointer */
1574
0
    herr_t          ret_value = SUCCEED; /* Return value */
1575
1576
0
    FUNC_ENTER_API(FAIL)
1577
1578
    /* Get the plist structure */
1579
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
1580
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1581
1582
0
    if (alloc_func)
1583
0
        if (H5P_get(plist, H5D_XFER_VLEN_ALLOC_NAME, alloc_func) < 0)
1584
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
1585
0
    if (alloc_info)
1586
0
        if (H5P_get(plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, alloc_info) < 0)
1587
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
1588
0
    if (free_func)
1589
0
        if (H5P_get(plist, H5D_XFER_VLEN_FREE_NAME, free_func) < 0)
1590
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
1591
0
    if (free_info)
1592
0
        if (H5P_get(plist, H5D_XFER_VLEN_FREE_INFO_NAME, free_info) < 0)
1593
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
1594
1595
0
done:
1596
0
    FUNC_LEAVE_API(ret_value)
1597
0
} /* end H5Pget_vlen_mem_manager() */
1598
1599
/*-------------------------------------------------------------------------
1600
 * Function:  H5Pset_hyper_vector_size
1601
 *
1602
 * Purpose: Given a dataset transfer property list, set the number of
1603
 *              "I/O vectors" (offset and length pairs) which are to be
1604
 *              accumulated in memory before being issued to the lower levels
1605
 *              of the library for reading or writing the actual data.
1606
 *              Increasing the number should give better performance, but use
1607
 *              more memory during hyperslab I/O.  The vector size must be
1608
 *              greater than 1.
1609
 *
1610
 *    The default is to use 1024 vectors for I/O during hyperslab
1611
 *              reading/writing.
1612
 *
1613
 * Return:  Non-negative on success/Negative on failure
1614
 *
1615
 *-------------------------------------------------------------------------
1616
 */
1617
herr_t
1618
H5Pset_hyper_vector_size(hid_t plist_id, size_t vector_size)
1619
0
{
1620
0
    H5P_genplist_t *plist;               /* Property list pointer */
1621
0
    herr_t          ret_value = SUCCEED; /* Return value */
1622
1623
0
    FUNC_ENTER_API(FAIL)
1624
1625
    /* Check arguments */
1626
0
    if (vector_size < 1)
1627
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "vector size too small");
1628
1629
    /* Get the plist structure */
1630
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, false)))
1631
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1632
1633
    /* Update property list */
1634
0
    if (H5P_set(plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, &vector_size) < 0)
1635
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
1636
1637
0
done:
1638
0
    FUNC_LEAVE_API(ret_value)
1639
0
} /* end H5Pset_hyper_vector_size() */
1640
1641
/*-------------------------------------------------------------------------
1642
 * Function:  H5Pget_hyper_vector_size
1643
 *
1644
 * Purpose: Reads values previously set with H5Pset_hyper_vector_size().
1645
 *
1646
 * Return:  Non-negative on success/Negative on failure
1647
 *
1648
 *-------------------------------------------------------------------------
1649
 */
1650
herr_t
1651
H5Pget_hyper_vector_size(hid_t plist_id, size_t *vector_size /*out*/)
1652
0
{
1653
0
    H5P_genplist_t *plist;               /* Property list pointer */
1654
0
    herr_t          ret_value = SUCCEED; /* Return value */
1655
1656
0
    FUNC_ENTER_API(FAIL)
1657
1658
    /* Get the plist structure */
1659
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
1660
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1661
1662
    /* Return values */
1663
0
    if (vector_size)
1664
0
        if (H5P_get(plist, H5D_XFER_HYPER_VECTOR_SIZE_NAME, vector_size) < 0)
1665
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
1666
1667
0
done:
1668
0
    FUNC_LEAVE_API(ret_value)
1669
0
} /* end H5Pget_hyper_vector_size() */
1670
1671
/*-------------------------------------------------------------------------
1672
 * Function:       H5P__dxfr_io_xfer_mode_enc
1673
 *
1674
 * Purpose:        Callback routine which is called whenever the I/O transfer
1675
 *                 mode property in the dataset transfer property list
1676
 *                 is encoded.
1677
 *
1678
 * Return:     Success: Non-negative
1679
 *       Failure: Negative
1680
 *
1681
 *-------------------------------------------------------------------------
1682
 */
1683
static herr_t
1684
H5P__dxfr_io_xfer_mode_enc(const void *value, void **_pp, size_t *size)
1685
0
{
1686
0
    const H5FD_mpio_xfer_t *xfer_mode = (const H5FD_mpio_xfer_t *)value; /* Create local alias for values */
1687
0
    uint8_t               **pp        = (uint8_t **)_pp;
1688
1689
0
    FUNC_ENTER_PACKAGE_NOERR
1690
1691
    /* Sanity check */
1692
0
    assert(xfer_mode);
1693
0
    assert(size);
1694
1695
0
    if (NULL != *pp)
1696
        /* Encode I/O transfer mode */
1697
0
        *(*pp)++ = (uint8_t)*xfer_mode;
1698
1699
    /* Size of I/O transfer mode */
1700
0
    (*size)++;
1701
1702
0
    FUNC_LEAVE_NOAPI(SUCCEED)
1703
0
} /* end H5P__dxfr_io_xfer_mode_enc() */
1704
1705
/*-------------------------------------------------------------------------
1706
 * Function:       H5P__dxfr_io_xfer_mode_dec
1707
 *
1708
 * Purpose:        Callback routine which is called whenever the I/O transfer
1709
 *                 mode property in the dataset transfer property list
1710
 *                 is decoded.
1711
 *
1712
 * Return:     Success: Non-negative
1713
 *       Failure: Negative
1714
 *
1715
 *-------------------------------------------------------------------------
1716
 */
1717
static herr_t
1718
H5P__dxfr_io_xfer_mode_dec(const void **_pp, void *_value)
1719
0
{
1720
0
    H5FD_mpio_xfer_t *xfer_mode = (H5FD_mpio_xfer_t *)_value; /* I/O transfer mode */
1721
0
    const uint8_t   **pp        = (const uint8_t **)_pp;
1722
1723
0
    FUNC_ENTER_PACKAGE_NOERR
1724
1725
    /* Sanity checks */
1726
0
    assert(pp);
1727
0
    assert(*pp);
1728
0
    assert(xfer_mode);
1729
1730
    /* Decode I/O transfer mode */
1731
0
    *xfer_mode = (H5FD_mpio_xfer_t) * (*pp)++;
1732
1733
0
    FUNC_LEAVE_NOAPI(SUCCEED)
1734
0
} /* end H5P__dxfr_io_xfer_mode_dec() */
1735
1736
/*-------------------------------------------------------------------------
1737
 * Function:       H5P__dxfr_mpio_collective_opt_enc
1738
 *
1739
 * Purpose:        Callback routine which is called whenever the MPI-I/O
1740
 *                 collective optimization property in the dataset transfer
1741
 *       property list is encoded.
1742
 *
1743
 * Return:     Success: Non-negative
1744
 *       Failure: Negative
1745
 *
1746
 *-------------------------------------------------------------------------
1747
 */
1748
static herr_t
1749
H5P__dxfr_mpio_collective_opt_enc(const void *value, void **_pp, size_t *size)
1750
0
{
1751
0
    const H5FD_mpio_collective_opt_t *coll_opt =
1752
0
        (const H5FD_mpio_collective_opt_t *)value; /* Create local alias for values */
1753
0
    uint8_t **pp = (uint8_t **)_pp;
1754
1755
0
    FUNC_ENTER_PACKAGE_NOERR
1756
1757
    /* Sanity check */
1758
0
    assert(coll_opt);
1759
0
    assert(size);
1760
1761
0
    if (NULL != *pp)
1762
        /* Encode MPI-I/O collective optimization property */
1763
0
        *(*pp)++ = (uint8_t)*coll_opt;
1764
1765
    /* Size of MPI-I/O collective optimization property */
1766
0
    (*size)++;
1767
1768
0
    FUNC_LEAVE_NOAPI(SUCCEED)
1769
0
} /* end H5P__dxfr_mpio_collective_opt_enc() */
1770
1771
/*-------------------------------------------------------------------------
1772
 * Function:       H5P__dxfr_mpio_collective_opt_dec
1773
 *
1774
 * Purpose:        Callback routine which is called whenever the MPI-I/O
1775
 *                 collective optimization property in the dataset transfer
1776
 *       property list is decoded.
1777
 *
1778
 * Return:     Success: Non-negative
1779
 *       Failure: Negative
1780
 *
1781
 *-------------------------------------------------------------------------
1782
 */
1783
static herr_t
1784
H5P__dxfr_mpio_collective_opt_dec(const void **_pp, void *_value)
1785
0
{
1786
0
    H5FD_mpio_collective_opt_t *coll_opt =
1787
0
        (H5FD_mpio_collective_opt_t *)_value; /* MPI-I/O collective optimization mode */
1788
0
    const uint8_t **pp = (const uint8_t **)_pp;
1789
1790
0
    FUNC_ENTER_PACKAGE_NOERR
1791
1792
    /* Sanity checks */
1793
0
    assert(pp);
1794
0
    assert(*pp);
1795
0
    assert(coll_opt);
1796
1797
    /* Decode MPI-I/O collective optimization mode */
1798
0
    *coll_opt = (H5FD_mpio_collective_opt_t) * (*pp)++;
1799
1800
0
    FUNC_LEAVE_NOAPI(SUCCEED)
1801
0
} /* end H5P__dxfr_mpio_collective_opt_dec() */
1802
1803
/*-------------------------------------------------------------------------
1804
 * Function:       H5P__dxfr_mpio_chunk_opt_hard_enc
1805
 *
1806
 * Purpose:        Callback routine which is called whenever the MPI-I/O
1807
 *                 chunk optimization property in the dataset transfer
1808
 *       property list is encoded.
1809
 *
1810
 * Return:     Success: Non-negative
1811
 *       Failure: Negative
1812
 *
1813
 *-------------------------------------------------------------------------
1814
 */
1815
static herr_t
1816
H5P__dxfr_mpio_chunk_opt_hard_enc(const void *value, void **_pp, size_t *size)
1817
0
{
1818
0
    const H5FD_mpio_chunk_opt_t *chunk_opt =
1819
0
        (const H5FD_mpio_chunk_opt_t *)value; /* Create local alias for values */
1820
0
    uint8_t **pp = (uint8_t **)_pp;
1821
1822
0
    FUNC_ENTER_PACKAGE_NOERR
1823
1824
    /* Sanity check */
1825
0
    assert(chunk_opt);
1826
0
    assert(size);
1827
1828
0
    if (NULL != *pp)
1829
        /* Encode MPI-I/O chunk optimization property */
1830
0
        *(*pp)++ = (uint8_t)*chunk_opt;
1831
1832
    /* Size of MPI-I/O chunk optimization property */
1833
0
    (*size)++;
1834
1835
0
    FUNC_LEAVE_NOAPI(SUCCEED)
1836
0
} /* end H5P__dxfr_mpio_chunk_opt_hard_enc() */
1837
1838
/*-------------------------------------------------------------------------
1839
 * Function:       H5P__dxfr_mpio_chunk_opt_hard_enc
1840
 *
1841
 * Purpose:        Callback routine which is called whenever the MPI-I/O
1842
 *                 chunk collective optimization property in the dataset transfer
1843
 *       property list is decoded.
1844
 *
1845
 * Return:     Success: Non-negative
1846
 *       Failure: Negative
1847
 *
1848
 *-------------------------------------------------------------------------
1849
 */
1850
static herr_t
1851
H5P__dxfr_mpio_chunk_opt_hard_dec(const void **_pp, void *_value)
1852
0
{
1853
0
    H5FD_mpio_chunk_opt_t *chunk_opt = (H5FD_mpio_chunk_opt_t *)_value; /* MPI-I/O chunk optimization mode */
1854
0
    const uint8_t        **pp        = (const uint8_t **)_pp;
1855
1856
0
    FUNC_ENTER_PACKAGE_NOERR
1857
1858
    /* Sanity checks */
1859
0
    assert(pp);
1860
0
    assert(*pp);
1861
0
    assert(chunk_opt);
1862
1863
    /* Decode MPI-I/O chunk optimization mode */
1864
0
    *chunk_opt = (H5FD_mpio_chunk_opt_t) * (*pp)++;
1865
1866
0
    FUNC_LEAVE_NOAPI(SUCCEED)
1867
0
} /* end H5P__dxfr_mpio_chunk_opt_hard_dec() */
1868
1869
#ifdef H5_HAVE_PARALLEL
1870
1871
/*-------------------------------------------------------------------------
1872
 * Function:  H5Pget_mpio_actual_chunk_opt_mode
1873
 *
1874
 * Purpose: Retrieves the chunked io optimization scheme that library chose
1875
 *
1876
 * Return:  Non-negative on success/Negative on failure
1877
 *
1878
 *-------------------------------------------------------------------------
1879
 */
1880
herr_t
1881
H5Pget_mpio_actual_chunk_opt_mode(hid_t                             plist_id,
1882
                                  H5D_mpio_actual_chunk_opt_mode_t *actual_chunk_opt_mode /*out*/)
1883
{
1884
    H5P_genplist_t *plist;
1885
    herr_t          ret_value = SUCCEED; /* return value */
1886
1887
    FUNC_ENTER_API(FAIL)
1888
1889
    /* Get the plist structure */
1890
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
1891
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1892
1893
    /* Return values */
1894
    if (actual_chunk_opt_mode)
1895
        if (H5P_get(plist, H5D_MPIO_ACTUAL_CHUNK_OPT_MODE_NAME, actual_chunk_opt_mode) < 0)
1896
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
1897
1898
done:
1899
    FUNC_LEAVE_API(ret_value)
1900
} /* end H5Pget_mpio_actual_chunk_opt_mode() */
1901
1902
/*-------------------------------------------------------------------------
1903
 * Function:  H5Pget_mpio_actual_io_mode
1904
 *
1905
 * Purpose: Retrieves the type of I/O actually performed when collective I/O
1906
 *    is requested.
1907
 *
1908
 * Return:  Non-negative on success/Negative on failure
1909
 *
1910
 *-------------------------------------------------------------------------
1911
 */
1912
herr_t
1913
H5Pget_mpio_actual_io_mode(hid_t plist_id, H5D_mpio_actual_io_mode_t *actual_io_mode /*out*/)
1914
{
1915
    H5P_genplist_t *plist;
1916
    herr_t          ret_value = SUCCEED; /* return value */
1917
1918
    FUNC_ENTER_API(FAIL)
1919
1920
    /* Get the plist structure */
1921
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
1922
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1923
1924
    /* Return values */
1925
    if (actual_io_mode)
1926
        if (H5P_get(plist, H5D_MPIO_ACTUAL_IO_MODE_NAME, actual_io_mode) < 0)
1927
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
1928
1929
done:
1930
    FUNC_LEAVE_API(ret_value)
1931
} /* end H5Pget_mpio_actual_io_mode() */
1932
1933
/*-------------------------------------------------------------------------
1934
 * Function:  H5Pget_mpio_no_collective_cause
1935
 *
1936
 * Purpose: Retrieves cause for the broke collective I/O
1937
 *
1938
 * Return:  Non-negative on success/Negative on failure
1939
 *
1940
 *-------------------------------------------------------------------------
1941
 */
1942
herr_t
1943
H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause /*out*/,
1944
                                uint32_t *global_no_collective_cause /*out*/)
1945
{
1946
    H5P_genplist_t *plist;
1947
    herr_t          ret_value = SUCCEED; /* return value */
1948
1949
    FUNC_ENTER_API(FAIL)
1950
1951
    /* Get the plist structure */
1952
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
1953
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
1954
1955
    /* Return values */
1956
    if (local_no_collective_cause)
1957
        if (H5P_get(plist, H5D_MPIO_LOCAL_NO_COLLECTIVE_CAUSE_NAME, local_no_collective_cause) < 0)
1958
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get local value");
1959
    if (global_no_collective_cause)
1960
        if (H5P_get(plist, H5D_MPIO_GLOBAL_NO_COLLECTIVE_CAUSE_NAME, global_no_collective_cause) < 0)
1961
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get global value");
1962
1963
done:
1964
    FUNC_LEAVE_API(ret_value)
1965
} /* end H5Pget_mpio_no_collective_cause() */
1966
#endif /* H5_HAVE_PARALLEL */
1967
1968
/*-------------------------------------------------------------------------
1969
 * Function:       H5P__dxfr_edc_enc
1970
 *
1971
 * Purpose:        Callback routine which is called whenever the error detect
1972
 *                 property in the dataset transfer property list
1973
 *                 is encoded.
1974
 *
1975
 * Return:     Success: Non-negative
1976
 *       Failure: Negative
1977
 *
1978
 *-------------------------------------------------------------------------
1979
 */
1980
static herr_t
1981
H5P__dxfr_edc_enc(const void *value, void **_pp, size_t *size)
1982
0
{
1983
0
    const H5Z_EDC_t *check = (const H5Z_EDC_t *)value; /* Create local alias for values */
1984
0
    uint8_t        **pp    = (uint8_t **)_pp;
1985
1986
0
    FUNC_ENTER_PACKAGE_NOERR
1987
1988
    /* Sanity check */
1989
0
    assert(check);
1990
0
    assert(size);
1991
1992
0
    if (NULL != *pp)
1993
        /* Encode EDC property */
1994
0
        *(*pp)++ = (uint8_t)*check;
1995
1996
    /* Size of EDC property */
1997
0
    (*size)++;
1998
1999
0
    FUNC_LEAVE_NOAPI(SUCCEED)
2000
0
} /* end H5P__dxfr_edc_enc() */
2001
2002
/*-------------------------------------------------------------------------
2003
 * Function:       H5P__dxfr_edc_dec
2004
 *
2005
 * Purpose:        Callback routine which is called whenever the error detect
2006
 *                 property in the dataset transfer property list
2007
 *                 is decoded.
2008
 *
2009
 * Return:     Success: Non-negative
2010
 *       Failure: Negative
2011
 *
2012
 *-------------------------------------------------------------------------
2013
 */
2014
static herr_t
2015
H5P__dxfr_edc_dec(const void **_pp, void *_value)
2016
0
{
2017
0
    H5Z_EDC_t      *check = (H5Z_EDC_t *)_value; /* EDC property */
2018
0
    const uint8_t **pp    = (const uint8_t **)_pp;
2019
2020
0
    FUNC_ENTER_PACKAGE_NOERR
2021
2022
    /* Sanity checks */
2023
0
    assert(pp);
2024
0
    assert(*pp);
2025
0
    assert(check);
2026
2027
    /* Decode EDC property */
2028
0
    *check = (H5Z_EDC_t) * (*pp)++;
2029
2030
0
    FUNC_LEAVE_NOAPI(SUCCEED)
2031
0
} /* end H5P__dxfr_edc_dec() */
2032
2033
/*-------------------------------------------------------------------------
2034
 * Function:    H5P__dxfr_dset_io_hyp_sel_copy
2035
 *
2036
 * Purpose:     Creates a copy of the dataset I/O selection.
2037
 *
2038
 * Return:  Non-negative on success/Negative on failure
2039
 *
2040
 *-------------------------------------------------------------------------
2041
 */
2042
static herr_t
2043
H5P__dxfr_dset_io_hyp_sel_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value)
2044
0
{
2045
0
    H5S_t *orig_space = *(H5S_t **)value; /* Original dataspace for property */
2046
0
    H5S_t *new_space  = NULL;             /* New dataspace for property */
2047
0
    herr_t ret_value  = SUCCEED;          /* Return value */
2048
2049
0
    FUNC_ENTER_PACKAGE
2050
2051
    /* If there's a dataspace I/O selection set, copy it */
2052
0
    if (orig_space) {
2053
        /* Make copy of dataspace */
2054
0
        if (NULL == (new_space = H5S_copy(orig_space, false, true)))
2055
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "error copying the dataset I/O selection");
2056
2057
        /* Set new value for property */
2058
0
        *(void **)value = new_space;
2059
0
    } /* end if */
2060
2061
0
done:
2062
    /* Cleanup on error */
2063
0
    if (ret_value < 0)
2064
0
        if (new_space && H5S_close(new_space) < 0)
2065
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing dataset I/O selection dataspace");
2066
2067
0
    FUNC_LEAVE_NOAPI(ret_value)
2068
0
} /* end H5P__dxfr_dset_io_hyp_sel_copy() */
2069
2070
/*-------------------------------------------------------------------------
2071
 * Function:    H5P__dxfr_dset_io_hyp_sel_cmp
2072
 *
2073
 * Purpose:     Compare two dataset I/O selections.
2074
 *
2075
 * Return:      positive if VALUE1 is greater than VALUE2, negative if VALUE2 is
2076
 *    greater than VALUE1 and zero if VALUE1 and VALUE2 are equal.
2077
 *
2078
 *-------------------------------------------------------------------------
2079
 */
2080
static int
2081
H5P__dxfr_dset_io_hyp_sel_cmp(const void *_space1, const void *_space2, size_t H5_ATTR_UNUSED size)
2082
0
{
2083
0
    const H5S_t *const *space1    = (const H5S_t *const *)_space1; /* Create local aliases for values */
2084
0
    const H5S_t *const *space2    = (const H5S_t *const *)_space2; /* Create local aliases for values */
2085
0
    herr_t              ret_value = 0;                             /* Return value */
2086
2087
0
    FUNC_ENTER_PACKAGE_NOERR
2088
2089
    /* Sanity check */
2090
0
    assert(space1);
2091
0
    assert(space1);
2092
0
    assert(size == sizeof(H5S_t *));
2093
2094
    /* Check for a property being set */
2095
0
    if (*space1 == NULL && *space2 != NULL)
2096
0
        HGOTO_DONE(-1);
2097
0
    if (*space1 != NULL && *space2 == NULL)
2098
0
        HGOTO_DONE(1);
2099
2100
0
    if (*space1) {
2101
0
        assert(*space2);
2102
2103
        /* Compare the extents of the dataspaces */
2104
        /* (Error & not-equal count the same) */
2105
0
        if (true != H5S_extent_equal(*space1, *space2))
2106
0
            HGOTO_DONE(-1);
2107
2108
        /* Compare the selection "shape" of the dataspaces
2109
         * (Error & not-equal count the same)
2110
         *
2111
         * Since H5S_select_shape_same() can result in the dataspaces being
2112
         * rebuilt, the parameters are not const which makes it impossible
2113
         * to match the cmp prototype. Since we need to compare them,
2114
         * we quiet the const warning.
2115
         */
2116
0
        H5_WARN_CAST_AWAY_CONST_OFF
2117
0
        if (true != H5S_select_shape_same((H5S_t *)*space1, (H5S_t *)*space2))
2118
0
            HGOTO_DONE(-1);
2119
0
        H5_WARN_CAST_AWAY_CONST_ON
2120
0
    } /* end if */
2121
2122
0
done:
2123
0
    FUNC_LEAVE_NOAPI(ret_value)
2124
0
} /* end H5P__dxfr_dset_io_hyp_sel_cmp() */
2125
2126
/*-------------------------------------------------------------------------
2127
 * Function:    H5P__dxfr_dset_io_hyp_sel_close
2128
 *
2129
 * Purpose:     Frees resources for dataset I/O selection
2130
 *
2131
 * Return:  Non-negative on success/Negative on failure
2132
 *
2133
 *-------------------------------------------------------------------------
2134
 */
2135
static herr_t
2136
H5P__dxfr_dset_io_hyp_sel_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *_value)
2137
1
{
2138
1
    H5S_t *space     = *(H5S_t **)_value; /* Dataspace for property */
2139
1
    herr_t ret_value = SUCCEED;           /* Return value */
2140
2141
1
    FUNC_ENTER_PACKAGE
2142
2143
    /* Release any dataspace */
2144
1
    if (space && H5S_close(space) < 0)
2145
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTCLOSEOBJ, FAIL, "error closing dataset I/O selection dataspace");
2146
2147
1
done:
2148
1
    FUNC_LEAVE_NOAPI(ret_value)
2149
1
} /* end H5P__dxfr_dset_io_hyp_sel_close() */
2150
2151
/*-------------------------------------------------------------------------
2152
 * Function:    H5P__dxfr_selection_io_mode_enc
2153
 *
2154
 * Purpose:     Callback routine which is called whenever the selection
2155
 *              I/O mode property in the dataset transfer property list
2156
 *              is encoded.
2157
 *
2158
 * Return:      Success:  Non-negative
2159
 *            Failure:  Negative
2160
 *
2161
 *-------------------------------------------------------------------------
2162
 */
2163
static herr_t
2164
H5P__dxfr_selection_io_mode_enc(const void *value, void **_pp, size_t *size)
2165
0
{
2166
0
    const H5D_selection_io_mode_t *select_io_mode =
2167
0
        (const H5D_selection_io_mode_t *)value; /* Create local alias for values */
2168
0
    uint8_t **pp = (uint8_t **)_pp;
2169
2170
0
    FUNC_ENTER_PACKAGE_NOERR
2171
2172
    /* Sanity check */
2173
0
    assert(select_io_mode);
2174
0
    assert(size);
2175
2176
0
    if (NULL != *pp)
2177
        /* Encode selection I/O mode property */
2178
0
        *(*pp)++ = (uint8_t)*select_io_mode;
2179
2180
    /* Size of selection I/O mode property */
2181
0
    (*size)++;
2182
2183
0
    FUNC_LEAVE_NOAPI(SUCCEED)
2184
0
} /* end H5P__dxfr_selection_io_mode_enc() */
2185
2186
/*-------------------------------------------------------------------------
2187
 * Function:    H5P__dxfr_selection_io_mode_dec
2188
 *
2189
 * Purpose:     Callback routine which is called whenever the selection
2190
 *              I/O mode property in the dataset transfer property list
2191
 *              is decoded.
2192
 *
2193
 * Return:      Success:  Non-negative
2194
 *            Failure:  Negative
2195
 *
2196
 *-------------------------------------------------------------------------
2197
 */
2198
static herr_t
2199
H5P__dxfr_selection_io_mode_dec(const void **_pp, void *_value)
2200
0
{
2201
0
    H5D_selection_io_mode_t *select_io_mode = (H5D_selection_io_mode_t *)_value; /* Selection I/O mode */
2202
0
    const uint8_t          **pp             = (const uint8_t **)_pp;
2203
2204
0
    FUNC_ENTER_PACKAGE_NOERR
2205
2206
    /* Sanity checks */
2207
0
    assert(pp);
2208
0
    assert(*pp);
2209
0
    assert(select_io_mode);
2210
2211
    /* Decode selection I/O mode property */
2212
0
    *select_io_mode = (H5D_selection_io_mode_t) * (*pp)++;
2213
2214
0
    FUNC_LEAVE_NOAPI(SUCCEED)
2215
0
} /* end H5P__dxfr_selection_io_dec() */
2216
2217
/*-------------------------------------------------------------------------
2218
 * Function:  H5Pset_dataset_io_hyperslab_selection
2219
 *
2220
 * Purpose: H5Pset_dataset_io_hyperslab_selection() is designed to be used
2221
 *              in conjunction with using H5S_PLIST for the file dataspace
2222
 *              ID when making a call to H5Dread() or H5Dwrite().  When used
2223
 *              with H5S_PLIST, the selection created by one or more calls to
2224
 *              this routine is used for determining which dataset elements to
2225
 *              access.
2226
 *
2227
 *              'rank' is the dimensionality of the selection and determines
2228
 *              the size of the 'start', 'stride', 'count', and 'block' arrays.
2229
 *              'rank' must be between 1 and H5S_MAX_RANK, inclusive.
2230
 *
2231
 *              The 'op', 'start', 'stride', 'count', and 'block' parameters
2232
 *              behave identically to their behavior for H5Sselect_hyperslab(),
2233
 *              please see the documentation for that routine for details about
2234
 *              their use.
2235
 *
2236
 * Return:  Non-negative on success/Negative on failure
2237
 *
2238
 *-------------------------------------------------------------------------
2239
 */
2240
herr_t
2241
H5Pset_dataset_io_hyperslab_selection(hid_t plist_id, unsigned rank, H5S_seloper_t op, const hsize_t start[],
2242
                                      const hsize_t stride[], const hsize_t count[], const hsize_t block[])
2243
0
{
2244
0
    H5P_genplist_t *plist               = NULL;    /* Property list pointer */
2245
0
    H5S_t          *space               = NULL;    /* Dataspace to hold selection */
2246
0
    bool            space_created       = false;   /* Whether a new dataspace has been created */
2247
0
    bool            reset_prop_on_error = false;   /* Whether to reset the property on failure */
2248
0
    herr_t          ret_value           = SUCCEED; /* return value */
2249
2250
0
    FUNC_ENTER_API(FAIL)
2251
2252
    /* Check arguments */
2253
0
    if (rank < 1 || rank > H5S_MAX_RANK)
2254
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank value: %u", rank);
2255
0
    if (!(op > H5S_SELECT_NOOP && op < H5S_SELECT_INVALID))
2256
0
        HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
2257
0
    if (start == NULL)
2258
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "'count' pointer is NULL");
2259
0
    if (stride != NULL) {
2260
0
        unsigned u; /* Local index variable */
2261
2262
        /* Check for 0-sized strides */
2263
0
        for (u = 0; u < rank; u++)
2264
0
            if (stride[u] == 0)
2265
0
                HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid value - stride[%u]==0", u);
2266
0
    } /* end if */
2267
0
    if (count == NULL)
2268
0
        HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "'start' pointer is NULL");
2269
    /* block is allowed to be NULL, and will be assumed to be all '1's when NULL */
2270
2271
    /* Get the plist structure */
2272
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, false)))
2273
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2274
2275
    /* See if a dataset I/O selection is already set, and free it if it is */
2276
0
    if (H5P_peek(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0)
2277
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting dataset I/O selection");
2278
2279
    /* Check for operation on existing dataspace selection */
2280
0
    if (NULL != space) {
2281
0
        int sndims; /* Rank of existing dataspace */
2282
2283
        /* Get dimensions from current dataspace for selection */
2284
0
        if ((sndims = H5S_GET_EXTENT_NDIMS(space)) < 0)
2285
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get selection's dataspace rank");
2286
2287
        /* Check for different # of dimensions */
2288
0
        if ((unsigned)sndims != rank) {
2289
            /* Set up new dataspace for 'set' operation, otherwise fail */
2290
0
            if (op == H5S_SELECT_SET) {
2291
                /* Close previous dataspace */
2292
0
                if (H5S_close(space) < 0)
2293
0
                    HGOTO_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release dataspace");
2294
2295
                /* Reset 'space' pointer, so it's re-created */
2296
0
                space = NULL;
2297
2298
                /* Set flag to reset property list on error */
2299
0
                reset_prop_on_error = true;
2300
0
            } /* end if */
2301
0
            else
2302
0
                HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "different rank for previous and new selections");
2303
0
        } /* end if */
2304
0
    }     /* end if */
2305
2306
    /* Check for first time called */
2307
0
    if (NULL == space) {
2308
0
        hsize_t  dims[H5S_MAX_RANK]; /* Dimensions for new dataspace */
2309
0
        unsigned u;                  /* Local index variable */
2310
2311
        /* Initialize dimensions to largest possible actual size */
2312
0
        for (u = 0; u < rank; u++)
2313
0
            dims[u] = (H5S_UNLIMITED - 1);
2314
2315
        /* Create dataspace of the correct dimensionality, with maximum dimensions */
2316
0
        if (NULL == (space = H5S_create_simple(rank, dims, NULL)))
2317
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTCREATE, FAIL, "unable to create dataspace for selection");
2318
0
        space_created = true;
2319
0
    } /* end if */
2320
2321
    /* Set selection for dataspace */
2322
0
    if (H5S_select_hyperslab(space, op, start, stride, count, block) < 0)
2323
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSELECT, FAIL, "can't create selection");
2324
2325
    /* Update property list (takes ownership of dataspace, if new) */
2326
0
    if (H5P_poke(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0)
2327
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "error setting dataset I/O selection");
2328
0
    space_created = false; /* Reset now that property owns the dataspace */
2329
2330
0
done:
2331
    /* Cleanup on failure */
2332
0
    if (ret_value < 0) {
2333
0
        if (reset_prop_on_error && plist && H5P_poke(plist, H5D_XFER_DSET_IO_SEL_NAME, &space) < 0)
2334
0
            HDONE_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "error setting dataset I/O selection");
2335
0
        if (space_created && H5S_close(space) < 0)
2336
0
            HDONE_ERROR(H5E_PLIST, H5E_CLOSEERROR, FAIL, "unable to release dataspace");
2337
0
    } /* end if */
2338
2339
0
    FUNC_LEAVE_API(ret_value)
2340
0
} /* end H5Pset_dataset_io_hyperslab_selection() */
2341
2342
/*-------------------------------------------------------------------------
2343
 * Function:    H5Pset_selection_io
2344
 *
2345
 * Purpose:     To set the selection I/O mode in the dataset
2346
 *              transfer property list.
2347
 *
2348
 * Note:        The library may not perform selection I/O as it asks for if
2349
 *              the layout callback determines that it is not feasible to do so.
2350
 *
2351
 * Return:      Success:    Non-negative
2352
 *              Failure:    Negative
2353
 *
2354
 *-------------------------------------------------------------------------
2355
 */
2356
herr_t
2357
H5Pset_selection_io(hid_t plist_id, H5D_selection_io_mode_t selection_io_mode)
2358
0
{
2359
0
    H5P_genplist_t *plist;               /* Property list pointer */
2360
0
    herr_t          ret_value = SUCCEED; /* Return value */
2361
2362
0
    FUNC_ENTER_API(FAIL)
2363
2364
    /* Check arguments */
2365
0
    if (plist_id == H5P_DEFAULT)
2366
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list");
2367
2368
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, false)))
2369
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl");
2370
2371
    /* Set the selection I/O mode */
2372
0
    if (H5P_set(plist, H5D_XFER_SELECTION_IO_MODE_NAME, &selection_io_mode) < 0)
2373
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
2374
2375
0
done:
2376
0
    FUNC_LEAVE_API(ret_value)
2377
0
} /* end H5Pset_selection_io() */
2378
2379
/*-------------------------------------------------------------------------
2380
 * Function:    H5Pget_selection_io
2381
 *
2382
 * Purpose:     To retrieve the selection I/O mode that is set in
2383
 *              the dataset transfer property list.
2384
 *
2385
 * Note:        The library may not perform selection I/O as it asks for if
2386
 *              the layout callback determines that it is not feasible to do so.
2387
 *
2388
 * Return:      Success:    Non-negative
2389
 *              Failure:    Negative
2390
 *
2391
 *-------------------------------------------------------------------------
2392
 */
2393
herr_t
2394
H5Pget_selection_io(hid_t plist_id, H5D_selection_io_mode_t *selection_io_mode /*out*/)
2395
0
{
2396
0
    H5P_genplist_t *plist;               /* Property list pointer */
2397
0
    herr_t          ret_value = SUCCEED; /* Return value */
2398
2399
0
    FUNC_ENTER_API(FAIL)
2400
2401
    /* Check arguments */
2402
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
2403
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl");
2404
2405
    /* Get the selection I/O mode */
2406
0
    if (selection_io_mode)
2407
0
        if (H5P_get(plist, H5D_XFER_SELECTION_IO_MODE_NAME, selection_io_mode) < 0)
2408
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
2409
2410
0
done:
2411
0
    FUNC_LEAVE_API(ret_value)
2412
0
} /* end H5Pget_selection_io() */
2413
2414
/*-------------------------------------------------------------------------
2415
 * Function:  H5Pget_no_selection_io_cause
2416
 *
2417
 * Purpose:     Retrieves causes for not performing selection I/O
2418
 *
2419
 * Return:      Non-negative on success/Negative on failure
2420
 *
2421
 *-------------------------------------------------------------------------
2422
 */
2423
herr_t
2424
H5Pget_no_selection_io_cause(hid_t plist_id, uint32_t *no_selection_io_cause /*out*/)
2425
0
{
2426
0
    H5P_genplist_t *plist;
2427
0
    herr_t          ret_value = SUCCEED; /* return value */
2428
2429
0
    FUNC_ENTER_API(FAIL)
2430
2431
    /* Get the plist structure */
2432
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
2433
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2434
2435
    /* Return values */
2436
0
    if (no_selection_io_cause)
2437
0
        if (H5P_get(plist, H5D_XFER_NO_SELECTION_IO_CAUSE_NAME, no_selection_io_cause) < 0)
2438
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get no_selection_io_cause value");
2439
2440
0
done:
2441
0
    FUNC_LEAVE_API(ret_value)
2442
0
} /* end H5Pget_no_selection_io_cause() */
2443
2444
/*-------------------------------------------------------------------------
2445
 * Function:  H5Pget_actual_selection_io_mode
2446
 *
2447
 * Purpose:     Retrieves actual selection I/O mode
2448
 *
2449
 * Return:      Non-negative on success/Negative on failure
2450
 *
2451
 * Programmer:  Vailin Choi
2452
 *              April 27, 2023
2453
 *-------------------------------------------------------------------------
2454
 */
2455
herr_t
2456
H5Pget_actual_selection_io_mode(hid_t plist_id, uint32_t *actual_selection_io_mode /*out*/)
2457
0
{
2458
0
    H5P_genplist_t *plist;
2459
0
    herr_t          ret_value = SUCCEED; /* return value */
2460
2461
0
    FUNC_ENTER_API(FAIL)
2462
2463
    /* Get the plist structure */
2464
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
2465
0
        HGOTO_ERROR(H5E_ID, H5E_BADID, FAIL, "can't find object for ID");
2466
2467
    /* Return values */
2468
0
    if (actual_selection_io_mode)
2469
0
        if (H5P_get(plist, H5D_XFER_ACTUAL_SELECTION_IO_MODE_NAME, actual_selection_io_mode) < 0)
2470
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get actual_selection_io_mode value");
2471
2472
0
done:
2473
0
    FUNC_LEAVE_API(ret_value)
2474
0
} /* end H5Pget_actual_selection_io_mode() */
2475
2476
/*-------------------------------------------------------------------------
2477
 * Function:    H5P__dxfr_modify_write_buf_enc
2478
 *
2479
 * Purpose:     Callback routine which is called whenever the modify write
2480
 *              buffer property in the dataset transfer property list is
2481
 *              encoded.
2482
 *
2483
 * Return:      Success:        Non-negative
2484
 *              Failure:        Negative
2485
 *
2486
 *-------------------------------------------------------------------------
2487
 */
2488
static herr_t
2489
H5P__dxfr_modify_write_buf_enc(const void *value, void **_pp /*out*/, size_t *size /*out*/)
2490
0
{
2491
0
    const bool *modify_write_buf = (const bool *)value; /* Create local alias for values */
2492
0
    uint8_t   **pp               = (uint8_t **)_pp;
2493
2494
0
    FUNC_ENTER_PACKAGE_NOERR
2495
2496
    /* Sanity check */
2497
0
    assert(modify_write_buf);
2498
0
    assert(size);
2499
2500
0
    if (NULL != *pp)
2501
        /* Encode modify write buf property.  Use "!!" so we always get 0 or 1 */
2502
0
        *(*pp)++ = (uint8_t)(!!(*modify_write_buf));
2503
2504
    /* Size of modify write buf property */
2505
0
    (*size)++;
2506
2507
0
    FUNC_LEAVE_NOAPI(SUCCEED)
2508
0
} /* end H5P__dxfr_modify_write_buf_enc() */
2509
2510
/*-------------------------------------------------------------------------
2511
 * Function:    H5P__dxfr_modify_write_buf_dec
2512
 *
2513
 * Purpose:     Callback routine which is called whenever the modify write
2514
 *              buffer property in the dataset transfer property list is
2515
 *              decoded.
2516
 *
2517
 * Return:      Success:        Non-negative
2518
 *              Failure:        Negative
2519
 *
2520
 *-------------------------------------------------------------------------
2521
 */
2522
static herr_t
2523
H5P__dxfr_modify_write_buf_dec(const void **_pp, void *_value /*out*/)
2524
0
{
2525
0
    bool           *modify_write_buf = (bool *)_value; /* Modify write buffer */
2526
0
    const uint8_t **pp               = (const uint8_t **)_pp;
2527
2528
0
    FUNC_ENTER_PACKAGE_NOERR
2529
2530
    /* Sanity checks */
2531
0
    assert(pp);
2532
0
    assert(*pp);
2533
0
    assert(modify_write_buf);
2534
2535
    /* Decode selection I/O mode property */
2536
0
    *modify_write_buf = (bool)*(*pp)++;
2537
2538
0
    FUNC_LEAVE_NOAPI(SUCCEED)
2539
0
} /* end H5P__dxfr_modify_write_buf_dec() */
2540
2541
/*-------------------------------------------------------------------------
2542
 * Function:    H5Pset_modify_write_buf
2543
 *
2544
 * Purpose:     Allows the library to modify the contents of the write
2545
 *              buffer
2546
 *
2547
 * Return:      Success:    Non-negative
2548
 *              Failure:    Negative
2549
 *
2550
 *-------------------------------------------------------------------------
2551
 */
2552
herr_t
2553
H5Pset_modify_write_buf(hid_t plist_id, hbool_t modify_write_buf)
2554
0
{
2555
0
    H5P_genplist_t *plist;               /* Property list pointer */
2556
0
    herr_t          ret_value = SUCCEED; /* Return value */
2557
2558
0
    FUNC_ENTER_API(FAIL)
2559
2560
    /* Check arguments */
2561
0
    if (plist_id == H5P_DEFAULT)
2562
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "can't set values in default property list");
2563
2564
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, false)))
2565
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl");
2566
2567
    /* Set the selection I/O mode */
2568
0
    if (H5P_set(plist, H5D_XFER_MODIFY_WRITE_BUF_NAME, &modify_write_buf) < 0)
2569
0
        HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value");
2570
2571
0
done:
2572
0
    FUNC_LEAVE_API(ret_value)
2573
0
} /* end H5Pset_modify_write_buf() */
2574
2575
/*-------------------------------------------------------------------------
2576
 * Function:    H5Pget_modify_write_buf
2577
 *
2578
 * Purpose:     Retrieves the "modify write buffer" property
2579
 *
2580
 * Return:      Success:    Non-negative
2581
 *              Failure:    Negative
2582
 *
2583
 *-------------------------------------------------------------------------
2584
 */
2585
herr_t
2586
H5Pget_modify_write_buf(hid_t plist_id, hbool_t *modify_write_buf /*out*/)
2587
0
{
2588
0
    H5P_genplist_t *plist;               /* Property list pointer */
2589
0
    herr_t          ret_value = SUCCEED; /* Return value */
2590
2591
0
    FUNC_ENTER_API(FAIL)
2592
2593
    /* Check arguments */
2594
0
    if (NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_XFER, true)))
2595
0
        HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a dxpl");
2596
2597
    /* Get the selection I/O mode */
2598
0
    if (modify_write_buf)
2599
0
        if (H5P_get(plist, H5D_XFER_MODIFY_WRITE_BUF_NAME, modify_write_buf) < 0)
2600
0
            HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value");
2601
2602
0
done:
2603
0
    FUNC_LEAVE_API(ret_value)
2604
0
} /* end H5Pget_modify_write_buf() */