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