This source file includes following definitions.
- init
- finalize
- pmix21_pack
- pmix21_unpack
- pmix21_copy
- pmix21_print
- register_type
- data_type_string
- pmix21_bfrop_pack_array
- pmix21_bfrop_pack_modex
- pmix21_bfrop_unpack_array
- pmix21_bfrop_unpack_modex
- pmix21_bfrop_copy_array
- pmix21_bfrop_copy_modex
- pmix21_bfrop_print_array
- pmix21_bfrop_print_modex
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 #include <src/include/pmix_config.h>
28
29 #include "src/mca/bfrops/base/base.h"
30 #include "bfrop_pmix21.h"
31
32 static pmix_status_t init(void);
33 static void finalize(void);
34 static pmix_status_t pmix21_pack(pmix_buffer_t *buffer,
35 const void *src, int num_vals,
36 pmix_data_type_t type);
37 static pmix_status_t pmix21_unpack(pmix_buffer_t *buffer, void *dest,
38 int32_t *num_vals, pmix_data_type_t type);
39 static pmix_status_t pmix21_copy(void **dest, void *src,
40 pmix_data_type_t type);
41 static pmix_status_t pmix21_print(char **output, char *prefix,
42 void *src, pmix_data_type_t type);
43 static pmix_status_t register_type(const char *name,
44 pmix_data_type_t type,
45 pmix_bfrop_pack_fn_t pack,
46 pmix_bfrop_unpack_fn_t unpack,
47 pmix_bfrop_copy_fn_t copy,
48 pmix_bfrop_print_fn_t print);
49 static const char* data_type_string(pmix_data_type_t type);
50
51 pmix_bfrops_module_t pmix_bfrops_pmix21_module = {
52 .version = "v21",
53 .init = init,
54 .finalize = finalize,
55 .pack = pmix21_pack,
56 .unpack = pmix21_unpack,
57 .copy = pmix21_copy,
58 .print = pmix21_print,
59 .copy_payload = pmix_bfrops_base_copy_payload,
60 .value_xfer = pmix_bfrops_base_value_xfer,
61 .value_load = pmix_bfrops_base_value_load,
62 .value_unload = pmix_bfrops_base_value_unload,
63 .value_cmp = pmix_bfrops_base_value_cmp,
64 .register_type = register_type,
65 .data_type_string = data_type_string
66 };
67
68
69 #define PMIX_MODEX 29
70 #define PMIX_INFO_ARRAY 44
71
72
73 typedef struct pmix_modex_data {
74 char nspace[PMIX_MAX_NSLEN+1];
75 int rank;
76 uint8_t *blob;
77 size_t size;
78 } pmix_modex_data_t;
79
80 static pmix_status_t pmix21_bfrop_pack_array(pmix_pointer_array_t *regtypes,
81 pmix_buffer_t *buffer, const void *src,
82 int32_t num_vals, pmix_data_type_t type);
83 static pmix_status_t pmix21_bfrop_pack_modex(pmix_pointer_array_t *regtypes,
84 pmix_buffer_t *buffer, const void *src,
85 int32_t num_vals, pmix_data_type_t type);
86 static pmix_status_t pmix21_bfrop_unpack_array(pmix_pointer_array_t *regtypes,
87 pmix_buffer_t *buffer, void *dest,
88 int32_t *num_vals, pmix_data_type_t type);
89 static pmix_status_t pmix21_bfrop_unpack_modex(pmix_pointer_array_t *regtypes,
90 pmix_buffer_t *buffer, void *dest,
91 int32_t *num_vals, pmix_data_type_t type);
92 static pmix_status_t pmix21_bfrop_copy_array(pmix_info_array_t **dest,
93 pmix_info_array_t *src,
94 pmix_data_type_t type);
95 static pmix_status_t pmix21_bfrop_copy_modex(pmix_modex_data_t **dest, pmix_modex_data_t *src,
96 pmix_data_type_t type);
97 static pmix_status_t pmix21_bfrop_print_array(char **output, char *prefix,
98 pmix_info_array_t *src, pmix_data_type_t type);
99 static pmix_status_t pmix21_bfrop_print_modex(char **output, char *prefix,
100 pmix_modex_data_t *src, pmix_data_type_t type);
101
102
103 static pmix_status_t init(void)
104 {
105
106 PMIX_REGISTER_TYPE("PMIX_BOOL", PMIX_BOOL,
107 pmix_bfrops_base_pack_bool,
108 pmix_bfrops_base_unpack_bool,
109 pmix_bfrops_base_std_copy,
110 pmix_bfrops_base_print_bool,
111 &mca_bfrops_v21_component.types);
112
113 PMIX_REGISTER_TYPE("PMIX_BYTE", PMIX_BYTE,
114 pmix_bfrops_base_pack_byte,
115 pmix_bfrops_base_unpack_byte,
116 pmix_bfrops_base_std_copy,
117 pmix_bfrops_base_print_byte,
118 &mca_bfrops_v21_component.types);
119
120 PMIX_REGISTER_TYPE("PMIX_STRING", PMIX_STRING,
121 pmix_bfrops_base_pack_string,
122 pmix_bfrops_base_unpack_string,
123 pmix_bfrops_base_copy_string,
124 pmix_bfrops_base_print_string,
125 &mca_bfrops_v21_component.types);
126
127
128 PMIX_REGISTER_TYPE("PMIX_SIZE", PMIX_SIZE,
129 pmix_bfrops_base_pack_sizet,
130 pmix_bfrops_base_unpack_sizet,
131 pmix_bfrops_base_std_copy,
132 pmix_bfrops_base_print_size,
133 &mca_bfrops_v21_component.types);
134
135 PMIX_REGISTER_TYPE("PMIX_PID", PMIX_PID,
136 pmix_bfrops_base_pack_pid,
137 pmix_bfrops_base_unpack_pid,
138 pmix_bfrops_base_std_copy,
139 pmix_bfrops_base_print_pid,
140 &mca_bfrops_v21_component.types);
141
142 PMIX_REGISTER_TYPE("PMIX_INT", PMIX_INT,
143 pmix_bfrops_base_pack_int,
144 pmix_bfrops_base_unpack_int,
145 pmix_bfrops_base_std_copy,
146 pmix_bfrops_base_print_int,
147 &mca_bfrops_v21_component.types);
148
149
150 PMIX_REGISTER_TYPE("PMIX_INT8", PMIX_INT8,
151 pmix_bfrops_base_pack_byte,
152 pmix_bfrops_base_unpack_byte,
153 pmix_bfrops_base_std_copy,
154 pmix_bfrops_base_print_int8,
155 &mca_bfrops_v21_component.types);
156
157 PMIX_REGISTER_TYPE("PMIX_INT16", PMIX_INT16,
158 pmix_bfrops_base_pack_int16,
159 pmix_bfrops_base_unpack_int16,
160 pmix_bfrops_base_std_copy,
161 pmix_bfrops_base_print_int16,
162 &mca_bfrops_v21_component.types);
163
164 PMIX_REGISTER_TYPE("PMIX_INT32", PMIX_INT32,
165 pmix_bfrops_base_pack_int32,
166 pmix_bfrops_base_unpack_int32,
167 pmix_bfrops_base_std_copy,
168 pmix_bfrops_base_print_int32,
169 &mca_bfrops_v21_component.types);
170
171 PMIX_REGISTER_TYPE("PMIX_INT64", PMIX_INT64,
172 pmix_bfrops_base_pack_int64,
173 pmix_bfrops_base_unpack_int64,
174 pmix_bfrops_base_std_copy,
175 pmix_bfrops_base_print_int64,
176 &mca_bfrops_v21_component.types);
177
178 PMIX_REGISTER_TYPE("PMIX_UINT", PMIX_UINT,
179 pmix_bfrops_base_pack_int,
180 pmix_bfrops_base_unpack_int,
181 pmix_bfrops_base_std_copy,
182 pmix_bfrops_base_print_uint,
183 &mca_bfrops_v21_component.types);
184
185 PMIX_REGISTER_TYPE("PMIX_UINT8", PMIX_UINT8,
186 pmix_bfrops_base_pack_byte,
187 pmix_bfrops_base_unpack_byte,
188 pmix_bfrops_base_std_copy,
189 pmix_bfrops_base_print_uint8,
190 &mca_bfrops_v21_component.types);
191
192 PMIX_REGISTER_TYPE("PMIX_UINT16", PMIX_UINT16,
193 pmix_bfrops_base_pack_int16,
194 pmix_bfrops_base_unpack_int16,
195 pmix_bfrops_base_std_copy,
196 pmix_bfrops_base_print_uint16,
197 &mca_bfrops_v21_component.types);
198
199 PMIX_REGISTER_TYPE("PMIX_UINT32", PMIX_UINT32,
200 pmix_bfrops_base_pack_int32,
201 pmix_bfrops_base_unpack_int32,
202 pmix_bfrops_base_std_copy,
203 pmix_bfrops_base_print_uint32,
204 &mca_bfrops_v21_component.types);
205
206 PMIX_REGISTER_TYPE("PMIX_UINT64", PMIX_UINT64,
207 pmix_bfrops_base_pack_int64,
208 pmix_bfrops_base_unpack_int64,
209 pmix_bfrops_base_std_copy,
210 pmix_bfrops_base_print_uint64,
211 &mca_bfrops_v21_component.types);
212
213 PMIX_REGISTER_TYPE("PMIX_FLOAT", PMIX_FLOAT,
214 pmix_bfrops_base_pack_float,
215 pmix_bfrops_base_unpack_float,
216 pmix_bfrops_base_std_copy,
217 pmix_bfrops_base_print_float,
218 &mca_bfrops_v21_component.types);
219
220 PMIX_REGISTER_TYPE("PMIX_DOUBLE", PMIX_DOUBLE,
221 pmix_bfrops_base_pack_double,
222 pmix_bfrops_base_unpack_double,
223 pmix_bfrops_base_std_copy,
224 pmix_bfrops_base_print_double,
225 &mca_bfrops_v21_component.types);
226
227 PMIX_REGISTER_TYPE("PMIX_TIMEVAL", PMIX_TIMEVAL,
228 pmix_bfrops_base_pack_timeval,
229 pmix_bfrops_base_unpack_timeval,
230 pmix_bfrops_base_std_copy,
231 pmix_bfrops_base_print_timeval,
232 &mca_bfrops_v21_component.types);
233
234 PMIX_REGISTER_TYPE("PMIX_TIME", PMIX_TIME,
235 pmix_bfrops_base_pack_time,
236 pmix_bfrops_base_unpack_time,
237 pmix_bfrops_base_std_copy,
238 pmix_bfrops_base_print_time,
239 &mca_bfrops_v21_component.types);
240
241 PMIX_REGISTER_TYPE("PMIX_STATUS", PMIX_STATUS,
242 pmix_bfrops_base_pack_status,
243 pmix_bfrops_base_unpack_status,
244 pmix_bfrops_base_std_copy,
245 pmix_bfrops_base_print_status,
246 &mca_bfrops_v21_component.types);
247
248 PMIX_REGISTER_TYPE("PMIX_VALUE", PMIX_VALUE,
249 pmix_bfrops_base_pack_value,
250 pmix_bfrops_base_unpack_value,
251 pmix_bfrops_base_copy_value,
252 pmix_bfrops_base_print_value,
253 &mca_bfrops_v21_component.types);
254
255 PMIX_REGISTER_TYPE("PMIX_PROC", PMIX_PROC,
256 pmix_bfrops_base_pack_proc,
257 pmix_bfrops_base_unpack_proc,
258 pmix_bfrops_base_copy_proc,
259 pmix_bfrops_base_print_proc,
260 &mca_bfrops_v21_component.types);
261
262 PMIX_REGISTER_TYPE("PMIX_APP", PMIX_APP,
263 pmix_bfrops_base_pack_app,
264 pmix_bfrops_base_unpack_app,
265 pmix_bfrops_base_copy_app,
266 pmix_bfrops_base_print_app,
267 &mca_bfrops_v21_component.types);
268
269 PMIX_REGISTER_TYPE("PMIX_INFO", PMIX_INFO,
270 pmix_bfrops_base_pack_info,
271 pmix_bfrops_base_unpack_info,
272 pmix_bfrops_base_copy_info,
273 pmix_bfrops_base_print_info,
274 &mca_bfrops_v21_component.types);
275
276 PMIX_REGISTER_TYPE("PMIX_PDATA", PMIX_PDATA,
277 pmix_bfrops_base_pack_pdata,
278 pmix_bfrops_base_unpack_pdata,
279 pmix_bfrops_base_copy_pdata,
280 pmix_bfrops_base_print_pdata,
281 &mca_bfrops_v21_component.types);
282
283 PMIX_REGISTER_TYPE("PMIX_BUFFER", PMIX_BUFFER,
284 pmix_bfrops_base_pack_buf,
285 pmix_bfrops_base_unpack_buf,
286 pmix_bfrops_base_copy_buf,
287 pmix_bfrops_base_print_buf,
288 &mca_bfrops_v21_component.types);
289
290 PMIX_REGISTER_TYPE("PMIX_BYTE_OBJECT", PMIX_BYTE_OBJECT,
291 pmix_bfrops_base_pack_bo,
292 pmix_bfrops_base_unpack_bo,
293 pmix_bfrops_base_copy_bo,
294 pmix_bfrops_base_print_bo,
295 &mca_bfrops_v21_component.types);
296
297 PMIX_REGISTER_TYPE("PMIX_KVAL", PMIX_KVAL,
298 pmix_bfrops_base_pack_kval,
299 pmix_bfrops_base_unpack_kval,
300 pmix_bfrops_base_copy_kval,
301 pmix_bfrops_base_print_kval,
302 &mca_bfrops_v21_component.types);
303
304 PMIX_REGISTER_TYPE("PMIX_MODEX", PMIX_MODEX,
305 pmix21_bfrop_pack_modex,
306 pmix21_bfrop_unpack_modex,
307 pmix21_bfrop_copy_modex,
308 pmix21_bfrop_print_modex,
309 &mca_bfrops_v21_component.types);
310
311
312 PMIX_REGISTER_TYPE("PMIX_PERSIST", PMIX_PERSIST,
313 pmix_bfrops_base_pack_persist,
314 pmix_bfrops_base_unpack_persist,
315 pmix_bfrops_base_std_copy,
316 pmix_bfrops_base_print_persist,
317 &mca_bfrops_v21_component.types);
318
319 PMIX_REGISTER_TYPE("PMIX_POINTER", PMIX_POINTER,
320 pmix_bfrops_base_pack_ptr,
321 pmix_bfrops_base_unpack_ptr,
322 pmix_bfrops_base_std_copy,
323 pmix_bfrops_base_print_ptr,
324 &mca_bfrops_v21_component.types);
325
326 PMIX_REGISTER_TYPE("PMIX_SCOPE", PMIX_SCOPE,
327 pmix_bfrops_base_pack_scope,
328 pmix_bfrops_base_unpack_scope,
329 pmix_bfrops_base_std_copy,
330 pmix_bfrops_base_std_copy,
331 &mca_bfrops_v21_component.types);
332
333 PMIX_REGISTER_TYPE("PMIX_DATA_RANGE", PMIX_DATA_RANGE,
334 pmix_bfrops_base_pack_range,
335 pmix_bfrops_base_unpack_range,
336 pmix_bfrops_base_std_copy,
337 pmix_bfrops_base_print_ptr,
338 &mca_bfrops_v21_component.types);
339
340 PMIX_REGISTER_TYPE("PMIX_COMMAND", PMIX_COMMAND,
341 pmix_bfrops_base_pack_cmd,
342 pmix_bfrops_base_unpack_cmd,
343 pmix_bfrops_base_std_copy,
344 pmix_bfrops_base_print_cmd,
345 &mca_bfrops_v21_component.types);
346
347 PMIX_REGISTER_TYPE("PMIX_INFO_DIRECTIVES", PMIX_INFO_DIRECTIVES,
348 pmix_bfrops_base_pack_info_directives,
349 pmix_bfrops_base_unpack_info_directives,
350 pmix_bfrops_base_std_copy,
351 pmix_bfrops_base_print_info_directives,
352 &mca_bfrops_v21_component.types);
353
354 PMIX_REGISTER_TYPE("PMIX_DATA_TYPE", PMIX_DATA_TYPE,
355 pmix_bfrops_base_pack_datatype,
356 pmix_bfrops_base_unpack_datatype,
357 pmix_bfrops_base_std_copy,
358 pmix_bfrops_base_print_datatype,
359 &mca_bfrops_v21_component.types);
360
361 PMIX_REGISTER_TYPE("PMIX_PROC_STATE", PMIX_PROC_STATE,
362 pmix_bfrops_base_pack_pstate,
363 pmix_bfrops_base_unpack_pstate,
364 pmix_bfrops_base_std_copy,
365 pmix_bfrops_base_print_pstate,
366 &mca_bfrops_v21_component.types);
367
368 PMIX_REGISTER_TYPE("PMIX_PROC_INFO", PMIX_PROC_INFO,
369 pmix_bfrops_base_pack_pinfo,
370 pmix_bfrops_base_unpack_pinfo,
371 pmix_bfrops_base_copy_pinfo,
372 pmix_bfrops_base_print_pinfo,
373 &mca_bfrops_v21_component.types);
374
375 PMIX_REGISTER_TYPE("PMIX_DATA_ARRAY", PMIX_DATA_ARRAY,
376 pmix_bfrops_base_pack_darray,
377 pmix_bfrops_base_unpack_darray,
378 pmix_bfrops_base_copy_darray,
379 pmix_bfrops_base_print_darray,
380 &mca_bfrops_v21_component.types);
381
382 PMIX_REGISTER_TYPE("PMIX_PROC_RANK", PMIX_PROC_RANK,
383 pmix_bfrops_base_pack_rank,
384 pmix_bfrops_base_unpack_rank,
385 pmix_bfrops_base_std_copy,
386 pmix_bfrops_base_print_rank,
387 &mca_bfrops_v21_component.types);
388
389 PMIX_REGISTER_TYPE("PMIX_QUERY", PMIX_QUERY,
390 pmix_bfrops_base_pack_query,
391 pmix_bfrops_base_unpack_query,
392 pmix_bfrops_base_copy_query,
393 pmix_bfrops_base_print_query,
394 &mca_bfrops_v21_component.types);
395
396 PMIX_REGISTER_TYPE("PMIX_COMPRESSED_STRING",
397 PMIX_COMPRESSED_STRING,
398 pmix_bfrops_base_pack_bo,
399 pmix_bfrops_base_unpack_bo,
400 pmix_bfrops_base_copy_bo,
401 pmix_bfrops_base_print_bo,
402 &mca_bfrops_v21_component.types);
403
404 PMIX_REGISTER_TYPE("PMIX_ALLOC_DIRECTIVE",
405 PMIX_ALLOC_DIRECTIVE,
406 pmix_bfrops_base_pack_alloc_directive,
407 pmix_bfrops_base_unpack_alloc_directive,
408 pmix_bfrops_base_std_copy,
409 pmix_bfrops_base_print_alloc_directive,
410 &mca_bfrops_v21_component.types);
411
412
413 PMIX_REGISTER_TYPE("PMIX_INFO_ARRAY", PMIX_INFO_ARRAY,
414 pmix21_bfrop_pack_array,
415 pmix21_bfrop_unpack_array,
416 pmix21_bfrop_copy_array,
417 pmix21_bfrop_print_array,
418 &mca_bfrops_v21_component.types);
419
420
421
422 return PMIX_SUCCESS;
423 }
424
425 static void finalize(void)
426 {
427 int n;
428 pmix_bfrop_type_info_t *info;
429
430 for (n=0; n < mca_bfrops_v21_component.types.size; n++) {
431 if (NULL != (info = (pmix_bfrop_type_info_t*)pmix_pointer_array_get_item(&mca_bfrops_v21_component.types, n))) {
432 PMIX_RELEASE(info);
433 pmix_pointer_array_set_item(&mca_bfrops_v21_component.types, n, NULL);
434 }
435 }
436 }
437
438 static pmix_status_t pmix21_pack(pmix_buffer_t *buffer,
439 const void *src, int num_vals,
440 pmix_data_type_t type)
441 {
442
443 return pmix_bfrops_base_pack(&mca_bfrops_v21_component.types,
444 buffer, src, num_vals, type);
445 }
446
447 static pmix_status_t pmix21_unpack(pmix_buffer_t *buffer, void *dest,
448 int32_t *num_vals, pmix_data_type_t type)
449 {
450
451 return pmix_bfrops_base_unpack(&mca_bfrops_v21_component.types,
452 buffer, dest, num_vals, type);
453 }
454
455 static pmix_status_t pmix21_copy(void **dest, void *src,
456 pmix_data_type_t type)
457 {
458 return pmix_bfrops_base_copy(&mca_bfrops_v21_component.types,
459 dest, src, type);
460 }
461
462 static pmix_status_t pmix21_print(char **output, char *prefix,
463 void *src, pmix_data_type_t type)
464 {
465 return pmix_bfrops_base_print(&mca_bfrops_v21_component.types,
466 output, prefix, src, type);
467 }
468
469 static pmix_status_t register_type(const char *name, pmix_data_type_t type,
470 pmix_bfrop_pack_fn_t pack,
471 pmix_bfrop_unpack_fn_t unpack,
472 pmix_bfrop_copy_fn_t copy,
473 pmix_bfrop_print_fn_t print)
474 {
475 PMIX_REGISTER_TYPE(name, type,
476 pack, unpack,
477 copy, print,
478 &mca_bfrops_v21_component.types);
479 return PMIX_SUCCESS;
480 }
481
482 static const char* data_type_string(pmix_data_type_t type)
483 {
484 return pmix_bfrops_base_data_type_string(&mca_bfrops_v21_component.types, type);
485 }
486
487
488 static pmix_status_t pmix21_bfrop_pack_array(pmix_pointer_array_t *regtypes,
489 pmix_buffer_t *buffer, const void *src,
490 int32_t num_vals, pmix_data_type_t type)
491 {
492 pmix_info_array_t *ptr;
493 int32_t i;
494 pmix_status_t ret;
495
496 ptr = (pmix_info_array_t *) src;
497
498 for (i = 0; i < num_vals; ++i) {
499
500 if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(regtypes, buffer, &ptr[i].size, 1, PMIX_SIZE))) {
501 return ret;
502 }
503 if (0 < ptr[i].size) {
504
505 if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_info(regtypes, buffer, ptr[i].array, ptr[i].size, PMIX_INFO))) {
506 return ret;
507 }
508 }
509 }
510
511 return PMIX_SUCCESS;
512 }
513
514 static pmix_status_t pmix21_bfrop_pack_modex(pmix_pointer_array_t *regtypes,
515 pmix_buffer_t *buffer, const void *src,
516 int32_t num_vals, pmix_data_type_t type)
517 {
518 pmix_modex_data_t *ptr;
519 int32_t i;
520 pmix_status_t ret;
521
522 ptr = (pmix_modex_data_t *) src;
523
524 for (i = 0; i < num_vals; ++i) {
525 if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_sizet(regtypes, buffer, &ptr[i].size, 1, PMIX_SIZE))) {
526 return ret;
527 }
528 if( 0 < ptr[i].size){
529 if (PMIX_SUCCESS != (ret = pmix_bfrops_base_pack_byte(regtypes, buffer, ptr[i].blob, ptr[i].size, PMIX_UINT8))) {
530 return ret;
531 }
532 }
533 }
534 return PMIX_SUCCESS;
535 }
536
537
538
539
540 static pmix_status_t pmix21_bfrop_unpack_array(pmix_pointer_array_t *regtypes,
541 pmix_buffer_t *buffer, void *dest,
542 int32_t *num_vals, pmix_data_type_t type)
543 {
544 pmix_info_array_t *ptr;
545 int32_t i, n, m;
546 pmix_status_t ret;
547
548 pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output,
549 "pmix21_bfrop_unpack: %d info arrays", *num_vals);
550
551 ptr = (pmix_info_array_t*) dest;
552 n = *num_vals;
553
554 for (i = 0; i < n; ++i) {
555 pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output,
556 "pmix21_bfrop_unpack: init array[%d]", i);
557 memset(&ptr[i], 0, sizeof(pmix_info_array_t));
558
559 m=1;
560 if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(regtypes, buffer,
561 &ptr[i].size, &m, PMIX_SIZE))) {
562 return ret;
563 }
564 if (0 < ptr[i].size) {
565 ptr[i].array = (pmix_info_t*)malloc(ptr[i].size * sizeof(pmix_info_t));
566 m=ptr[i].size;
567 if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_value(regtypes, buffer,
568 ptr[i].array, &m, PMIX_INFO))) {
569 return ret;
570 }
571 }
572 }
573 return PMIX_SUCCESS;
574 }
575
576 static pmix_status_t pmix21_bfrop_unpack_modex(pmix_pointer_array_t *regtypes,
577 pmix_buffer_t *buffer, void *dest,
578 int32_t *num_vals, pmix_data_type_t type)
579 {
580 pmix_modex_data_t *ptr;
581 int32_t i, n, m;
582 pmix_status_t ret;
583
584 pmix_output_verbose(20, pmix_bfrops_base_framework.framework_output,
585 "pmix20_bfrop_unpack: %d modex", *num_vals);
586
587 ptr = (pmix_modex_data_t *) dest;
588 n = *num_vals;
589
590 for (i = 0; i < n; ++i) {
591 memset(&ptr[i], 0, sizeof(pmix_modex_data_t));
592
593 m=1;
594 if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_sizet(regtypes, buffer, &ptr[i].size, &m, PMIX_SIZE))) {
595 return ret;
596 }
597 if (0 < ptr[i].size) {
598 ptr[i].blob = (uint8_t*)malloc(ptr[i].size * sizeof(uint8_t));
599 m=ptr[i].size;
600 if (PMIX_SUCCESS != (ret = pmix_bfrops_base_unpack_byte(regtypes, buffer, ptr[i].blob, &m, PMIX_UINT8))) {
601 return ret;
602 }
603 }
604 }
605 return PMIX_SUCCESS;
606 }
607
608
609
610
611 static pmix_status_t pmix21_bfrop_copy_array(pmix_info_array_t **dest,
612 pmix_info_array_t *src,
613 pmix_data_type_t type)
614 {
615 pmix_info_t *d1, *s1;
616
617 *dest = (pmix_info_array_t*)malloc(sizeof(pmix_info_array_t));
618 (*dest)->size = src->size;
619 (*dest)->array = (pmix_info_t*)malloc(src->size * sizeof(pmix_info_t));
620 d1 = (pmix_info_t*)(*dest)->array;
621 s1 = (pmix_info_t*)src->array;
622 memcpy(d1, s1, src->size * sizeof(pmix_info_t));
623 return PMIX_SUCCESS;
624 }
625
626 static pmix_status_t pmix21_bfrop_copy_modex(pmix_modex_data_t **dest, pmix_modex_data_t *src,
627 pmix_data_type_t type)
628 {
629 *dest = (pmix_modex_data_t*)malloc(sizeof(pmix_modex_data_t));
630 if (NULL == *dest) {
631 return PMIX_ERR_OUT_OF_RESOURCE;
632 }
633 (*dest)->blob = NULL;
634 (*dest)->size = 0;
635 if (NULL != src->blob) {
636 (*dest)->blob = (uint8_t*)malloc(src->size * sizeof(uint8_t));
637 if (NULL == (*dest)->blob) {
638 return PMIX_ERR_OUT_OF_RESOURCE;
639 }
640 memcpy((*dest)->blob, src->blob, src->size * sizeof(uint8_t));
641 (*dest)->size = src->size;
642 }
643 return PMIX_SUCCESS;
644 }
645
646
647
648
649 static pmix_status_t pmix21_bfrop_print_array(char **output, char *prefix,
650 pmix_info_array_t *src, pmix_data_type_t type)
651 {
652 size_t j;
653 char *tmp, *tmp2, *tmp3, *pfx;
654 pmix_info_t *s1;
655
656 if (0 > asprintf(&tmp, "%sARRAY SIZE: %ld", prefix, (long)src->size)) {
657 return PMIX_ERR_NOMEM;
658 }
659 if (0 > asprintf(&pfx, "\n%s\t", (NULL == prefix) ? "" : prefix)) {
660 free(tmp);
661 return PMIX_ERR_NOMEM;
662 }
663 s1 = (pmix_info_t*)src->array;
664
665 for (j=0; j < src->size; j++) {
666 pmix_bfrops_base_print_info(&tmp2, pfx, &s1[j], PMIX_INFO);
667 if (0 > asprintf(&tmp3, "%s%s", tmp, tmp2)) {
668 free(tmp);
669 free(tmp2);
670 return PMIX_ERR_NOMEM;
671 }
672 free(tmp);
673 free(tmp2);
674 tmp = tmp3;
675 }
676 *output = tmp;
677 return PMIX_SUCCESS;
678 }
679
680 static pmix_status_t pmix21_bfrop_print_modex(char **output, char *prefix,
681 pmix_modex_data_t *src, pmix_data_type_t type)
682 {
683 return PMIX_SUCCESS;
684 }
685
686