-
Notifications
You must be signed in to change notification settings - Fork 5
/
new_h5api.c
289 lines (241 loc) · 10.3 KB
/
new_h5api.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
* the COPYING file, which can be found at the root of the source code *
* distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. *
* If you do not have access to either file, you may request a copy from *
* [email protected]. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Purpose: The new public API routines, dynamically registered by VOL
* connector.
*/
/* Headers needed */
#include "assert.h"
/* Define macro that can be check in header file, to disable "user" macros" */
#define NEW_H5API_IMPL
/* Public prototypes for the new API routines, etc. */
#include "new_h5api.h"
/* This connector's private header */
#include "H5VLpassthru_ext_private.h"
/* Operation values for new "API" routines */
/* These are initialized in the VOL connector's 'init' callback at runtime.
* It's good practice to reset them back to -1 in the 'atclose' callback.
*/
static int H5VL_new_api_dataset_foo_op_g = -1;
static int H5VL_new_api_dataset_bar_op_g = -1;
static int H5VL_new_api_group_fiddle_op_g = -1;
static void
ext_passthru_reset(void *_ctx)
{
/* Reset the operation IDs, just for completeness */
H5VL_new_api_dataset_foo_op_g = -1;
H5VL_new_api_dataset_bar_op_g = -1;
H5VL_new_api_group_fiddle_op_g = -1;
}
static int
ext_passthru_setup(void)
{
/* Look up all the operation values */
if(H5VLfind_opt_operation(H5VL_SUBCLS_DATASET, H5VL_PASSTHRU_EXT_DYN_FOO, &H5VL_new_api_dataset_foo_op_g) < 0)
return(-1);
if(H5VLfind_opt_operation(H5VL_SUBCLS_DATASET, H5VL_PASSTHRU_EXT_DYN_BAR, &H5VL_new_api_dataset_bar_op_g) < 0)
return(-1);
if(H5VLfind_opt_operation(H5VL_SUBCLS_GROUP, H5VL_PASSTHRU_EXT_DYN_FIDDLE, &H5VL_new_api_group_fiddle_op_g) < 0)
return(-1);
/* Register callback for library shutdown, to release resources */
if (H5atclose(ext_passthru_reset, NULL) < 0) {
fprintf(stderr, "H5atclose failed\n");
return(-1);
}
return 0;
}
/*-------------------------------------------------------------------------
* Function: H5Dfoo
*
* Purpose: Performs the 'foo' operation on a dataset, using the
* dataset 'optional' VOL callback.
*
* Return: Success: 0
* Failure: -1
*
*-------------------------------------------------------------------------
*/
herr_t
H5Dfoo(const char *app_file, const char *app_func, unsigned app_line,
hid_t dset_id, hid_t dxpl_id, int i, double d)
{
H5VL_optional_args_t vol_cb_args; /* Wrapper for invoking optional operation */
H5VL_passthru_ext_dataset_foo_args_t foo_args; /* Parameters for 'foo' operation */
/* Set up the operation value, if it hasn't already been retrieved */
if(-1 == H5VL_new_api_dataset_foo_op_g)
if(ext_passthru_setup() < 0)
return(-1);
assert(H5VL_new_api_dataset_foo_op_g > 0);
/* Set up args for invoking optional callback */
foo_args.i = i;
foo_args.d = d;
vol_cb_args.op_type = H5VL_new_api_dataset_foo_op_g;
vol_cb_args.args = &foo_args;
/* Call the VOL dataset optional routine, requesting 'foo' occur */
if(H5VLdataset_optional_op_wrap(app_file, app_func, app_line, dset_id, &vol_cb_args, dxpl_id, H5ES_NONE) < 0)
return(-1);
return 0;
} /* end H5Dfoo() */
/*-------------------------------------------------------------------------
* Function: H5Dfoo_async
*
* Purpose: Asynchronously performs the 'foo' operation on a dataset, using
* the dataset 'optional' VOL callback.
*
* Return: Success: 0
* Failure: -1
*
*-------------------------------------------------------------------------
*/
herr_t
H5Dfoo_async(const char *app_file, const char *app_func, unsigned app_line,
hid_t dset_id, hid_t dxpl_id, int i, double d, hid_t es_id)
{
H5VL_optional_args_t vol_cb_args; /* Wrapper for invoking optional operation */
H5VL_passthru_ext_dataset_foo_args_t foo_args; /* Parameters for 'foo' operation */
/* Set up the operation value, if it hasn't already been retrieved */
if(-1 == H5VL_new_api_dataset_foo_op_g)
if(ext_passthru_setup() < 0)
return(-1);
assert(H5VL_new_api_dataset_foo_op_g > 0);
/* Set up args for invoking optional callback */
foo_args.i = i;
foo_args.d = d;
vol_cb_args.op_type = H5VL_new_api_dataset_foo_op_g;
vol_cb_args.args = &foo_args;
/* Call the VOL dataset optional routine, requesting 'foo' occur */
if(H5VLdataset_optional_op_wrap(app_file, app_func, app_line, dset_id, &vol_cb_args, dxpl_id, es_id) < 0)
return(-1);
return 0;
} /* end H5Dfoo() */
/*-------------------------------------------------------------------------
* Function: H5Dbar
*
* Purpose: Performs the 'bar' operation on a dataset, using the
* dataset 'optional' VOL callback.
*
* Return: Success: 0
* Failure: -1
*
*-------------------------------------------------------------------------
*/
herr_t
H5Dbar(const char *app_file, const char *app_func, unsigned app_line,
hid_t dset_id, hid_t dxpl_id, double *dp, unsigned *up)
{
H5VL_optional_args_t vol_cb_args; /* Wrapper for invoking optional operation */
H5VL_passthru_ext_dataset_bar_args_t bar_args; /* Parameters for 'bar' operation */
/* Set up the operation value, if it hasn't already been retrieved */
if(-1 == H5VL_new_api_dataset_bar_op_g)
if(ext_passthru_setup() < 0)
return(-1);
assert(H5VL_new_api_dataset_bar_op_g > 0);
/* Set up args for invoking optional callback */
bar_args.dp = dp;
bar_args.up = up;
vol_cb_args.op_type = H5VL_new_api_dataset_bar_op_g;
vol_cb_args.args = &bar_args;
/* Call the VOL dataset optional routine, requesting 'bar' occur */
if(H5VLdataset_optional_op_wrap(app_file, app_func, app_line, dset_id, &vol_cb_args, dxpl_id, H5ES_NONE) < 0)
return(-1);
return 0;
} /* end H5Dbar() */
/*-------------------------------------------------------------------------
* Function: H5Dbar_async
*
* Purpose: Asynchronously performs the 'bar' operation on a dataset, using
* the dataset 'optional' VOL callback.
*
* Return: Success: 0
* Failure: -1
*
*-------------------------------------------------------------------------
*/
herr_t
H5Dbar_async(const char *app_file, const char *app_func, unsigned app_line,
hid_t dset_id, hid_t dxpl_id, double *dp, unsigned *up, hid_t es_id)
{
H5VL_optional_args_t vol_cb_args; /* Wrapper for invoking optional operation */
H5VL_passthru_ext_dataset_bar_args_t bar_args; /* Parameters for 'bar' operation */
/* Set up the operation value, if it hasn't already been retrieved */
if(-1 == H5VL_new_api_dataset_bar_op_g)
if(ext_passthru_setup() < 0)
return(-1);
assert(H5VL_new_api_dataset_bar_op_g > 0);
/* Set up args for invoking optional callback */
bar_args.dp = dp;
bar_args.up = up;
vol_cb_args.op_type = H5VL_new_api_dataset_bar_op_g;
vol_cb_args.args = &bar_args;
/* Call the VOL dataset optional routine, requesting 'bar' occur */
if(H5VLdataset_optional_op_wrap(app_file, app_func, app_line, dset_id, &vol_cb_args, dxpl_id, es_id) < 0)
return(-1);
return 0;
} /* end H5Dbar() */
/*-------------------------------------------------------------------------
* Function: H5Gfiddle
*
* Purpose: Performs the 'fiddle' operation on a group, using the
* group 'optional' VOL callback.
*
* Return: Success: 0
* Failure: -1
*
*-------------------------------------------------------------------------
*/
herr_t
H5Gfiddle(const char *app_file, const char *app_func, unsigned app_line,
hid_t group_id, hid_t dxpl_id)
{
H5VL_optional_args_t vol_cb_args; /* Wrapper for invoking optional operation */
/* Set up the operation value, if it hasn't already been retrieved */
if(-1 == H5VL_new_api_group_fiddle_op_g)
if(ext_passthru_setup() < 0)
return(-1);
assert(H5VL_new_api_group_fiddle_op_g > 0);
/* Set up args for invoking optional callback */
vol_cb_args.op_type = H5VL_new_api_group_fiddle_op_g;
vol_cb_args.args = NULL;
/* Call the VOL group optional routine, requesting 'fiddle' occur */
if(H5VLgroup_optional_op_wrap(app_file, app_func, app_line, group_id, &vol_cb_args, dxpl_id, H5ES_NONE) < 0)
return(-1);
return 0;
} /* end H5Gfiddle() */
/*-------------------------------------------------------------------------
* Function: H5Gfiddle_async
*
* Purpose: Asynchronously ePrforms the 'fiddle' operation on a group, using
* the group 'optional' VOL callback.
*
* Return: Success: 0
* Failure: -1
*
*-------------------------------------------------------------------------
*/
herr_t
H5Gfiddle_async(const char *app_file, const char *app_func, unsigned app_line,
hid_t group_id, hid_t dxpl_id, hid_t es_id)
{
H5VL_optional_args_t vol_cb_args; /* Wrapper for invoking optional operation */
/* Set up the operation value, if it hasn't already been retrieved */
if(-1 == H5VL_new_api_group_fiddle_op_g)
if(ext_passthru_setup() < 0)
return(-1);
assert(H5VL_new_api_group_fiddle_op_g > 0);
/* Set up args for invoking optional callback */
vol_cb_args.op_type = H5VL_new_api_group_fiddle_op_g;
vol_cb_args.args = NULL;
/* Call the VOL group optional routine, requesting 'fiddle' occur */
if(H5VLgroup_optional_op_wrap(app_file, app_func, app_line, group_id, &vol_cb_args, dxpl_id, es_id) < 0)
return(-1);
return 0;
} /* end H5Gfiddle() */