-
Notifications
You must be signed in to change notification settings - Fork 2
/
pmix_macros.h
1101 lines (986 loc) · 49.9 KB
/
pmix_macros.h
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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright (c) 2013-2020 Intel, Inc. All rights reserved.
* Copyright (c) 2016-2019 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016-2019 Mellanox Technologies, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer listed
* in this license in the documentation and/or other materials
* provided with the distribution.
*
* - Neither the name of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* The copyright holders provide no reassurances that the source code
* provided does not infringe any patent, copyright, or any other
* intellectual property rights of third parties. The copyright holders
* disclaim any liability to any recipient for claims brought against
* recipient by any third party for infringement of that parties
* intellectual property rights.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright (c) 2020 Cisco Systems, Inc. All rights reserved
* Copyright (c) 2021-2022 Nanook Consulting All rights reserved.
* Copyright (c) 2016-2022 IBM Corporation. All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/*
* PMIx Standard macros
*/
#ifndef PMIX_MACROS_H
#define PMIX_MACROS_H
/* *******************************************************************
* PMIx Standard types, constants, and callback functions
* *******************************************************************/
#include "pmix_types.h"
/* *******************************************************************
* The PMIx ABI Support functions that _do not_ rely on the macros defined
* in this header. They provide 'static inline' functions required to
* support these macro definitions.
* *******************************************************************/
#include "pmix_abi_support.h"
/* define a macro for testing for valid ranks */
#define PMIX_RANK_IS_VALID(r) \
((r) < PMIX_RANK_VALID)
/* define a macro for identifying system event values */
#define PMIX_SYSTEM_EVENT(a) \
((a) <= PMIX_EVENT_SYS_BASE && PMIX_EVENT_SYS_OTHER <= (a))
/* declare a convenience macro for checking keys */
#define PMIX_CHECK_KEY(a, b) \
(0 == strncmp((a)->key, (b), PMIX_MAX_KEYLEN))
/* check if the key is reserved */
#define PMIX_CHECK_RESERVED_KEY(a) \
(0 == strncmp((a), "pmix", 4))
/* load the key into the data structure */
#define PMIX_LOAD_KEY(a, b) \
do { \
memset((a), 0, PMIX_MAX_KEYLEN+1); \
if (NULL != (b)) { \
pmixabi_strncpy((char*)(a), (const char*)(b), PMIX_MAX_KEYLEN); \
} \
}while(0)
/* define a convenience macro for loading nspaces */
#define PMIX_LOAD_NSPACE(a, b) \
do { \
memset((a), 0, PMIX_MAX_NSLEN+1); \
if (NULL != (b)) { \
pmixabi_strncpy((char*)(a), (b), PMIX_MAX_NSLEN); \
} \
}while(0)
/* define a convenience macro for checking nspaces */
#define PMIX_CHECK_NSPACE(a, b) \
(PMIX_NSPACE_INVALID((a)) || PMIX_NSPACE_INVALID((b)) || 0 == strncmp((a), (b), PMIX_MAX_NSLEN))
/* define a convenience macro for loading names */
#define PMIX_LOAD_PROCID(a, b, c) \
do { \
PMIX_LOAD_NSPACE((a)->nspace, (b)); \
(a)->rank = (c); \
}while(0)
#define PMIX_XFER_PROCID(a, b) \
memcpy((a), (b), sizeof(pmix_proc_t))
#define PMIX_PROCID_XFER(a, b) PMIX_XFER_PROCID(a, b)
/* define a convenience macro for checking names */
#define PMIX_CHECK_PROCID(a, b) \
(PMIX_CHECK_NSPACE((a)->nspace, (b)->nspace) && ((a)->rank == (b)->rank || (PMIX_RANK_WILDCARD == (a)->rank || PMIX_RANK_WILDCARD == (b)->rank)))
#define PMIX_CHECK_RANK(a, b) \
((a) == (b) || (PMIX_RANK_WILDCARD == (a) || PMIX_RANK_WILDCARD == (b)))
#define PMIX_NSPACE_INVALID(a) \
(NULL == (a) || 0 == pmixabi_nslen((a)))
#define PMIX_PROCID_INVALID(a) \
(PMIX_NSPACE_INVALID((a)->nspace) || PMIX_RANK_INVALID == (a)->rank)
/*
* ARGV support
*/
#define PMIX_ARGV_COUNT(r, a) \
(r) = pmixabi_argv_count(a)
#define PMIX_ARGV_APPEND(r, a, b) \
(r) = pmixabi_argv_append_nosize(&(a), (b))
#define PMIX_ARGV_PREPEND(r, a, b) \
(r) = pmixabi_argv_prepend_nosize(&(a), b)
#define PMIX_ARGV_APPEND_UNIQUE(r, a, b) \
(r) = pmixabi_argv_append_unique_nosize(a, b)
#define PMIX_ARGV_FREE(a) \
do { \
if (NULL != (a)) { \
for (char **p = (a); NULL != *p; ++p) { \
free(*p); \
} \
free(a); \
} \
} while(0)
#define PMIX_ARGV_SPLIT(a, b, c) \
(a) = pmixabi_argv_split(b, c)
#define PMIX_ARGV_JOIN(a, b, c) \
(a) = pmixabi_argv_join(b, c)
#define PMIX_ARGV_COPY(a, b) \
(a) = pmixabi_argv_copy(b)
/*
* Environment support
*/
#define PMIX_SETENV(r, a, b, c) \
(r) = pmixabi_setenv((a), (b), true, (c))
/*
* pmix_coord_t
*/
#define PMIX_COORD_CREATE(m, d, n) \
do { \
pmix_coord_t *_m; \
_m = (pmix_coord_t*)pmixabi_calloc((d), sizeof(pmix_coord_t)); \
if (NULL != _m) { \
_m->view = PMIX_COORD_VIEW_UNDEF; \
_m->dims = (n); \
_m->coord = (uint32_t*)pmixabi_calloc((n), sizeof(uint32_t)); \
(m) = _m; \
} \
} while(0)
#define PMIX_COORD_CONSTRUCT(m) \
do { \
(m)->view = PMIX_COORD_VIEW_UNDEF; \
(m)->coord = NULL; \
(m)->dims = 0; \
} while(0)
#define PMIX_COORD_DESTRUCT(m) \
do { \
(m)->view = PMIX_COORD_VIEW_UNDEF; \
if (NULL != (m)->coord) { \
pmixabi_free((m)->coord); \
(m)->coord = NULL; \
(m)->dims = 0; \
} \
} while(0)
#define PMIX_COORD_FREE(m, n) \
do { \
size_t _nc_; \
if (NULL != (m)) { \
for (_nc_ = 0; _nc_ < (n); _nc_++) { \
PMIX_COORD_DESTRUCT(&(m)[_nc_]); \
} \
pmixabi_free((m)); \
(m) = NULL; \
} \
} while(0)
/*
* pmix_cpuset_t
*/
#define PMIX_CPUSET_CONSTRUCT(m) \
memset((m), 0, sizeof(pmix_cpuset_t))
#define PMIX_CPUSET_CREATE(m, n) \
(m) = (pmix_cpuset_t*)pmixabi_calloc((n), sizeof(pmix_cpuset_t));
/*
* pmix_topology_t
*/
#define PMIX_TOPOLOGY_CONSTRUCT(m) \
memset((m), 0, sizeof(pmix_topology_t))
#define PMIX_TOPOLOGY_CREATE(m, n) \
(m) = (pmix_topology_t*)pmixabi_calloc(n, sizeof(pmix_topology_t))
/*
* pmix_geometry_t
*/
#define PMIX_GEOMETRY_CONSTRUCT(m) \
memset((m), 0, sizeof(pmix_geometry_t));
#define PMIX_GEOMETRY_DESTRUCT(m) \
do { \
if (NULL != (m)->uuid) { \
pmixabi_free((m)->uuid); \
(m)->uuid = NULL; \
} \
if (NULL != (m)->osname) { \
pmixabi_free((m)->osname); \
(m)->osname = NULL; \
} \
if (NULL != (m)->coordinates) { \
PMIX_COORD_FREE((m)->coordinates, (m)->ncoords); \
} \
} while(0)
#define PMIX_GEOMETRY_CREATE(m, n) \
(m) = (pmix_geometry_t*)pmixabi_calloc((n), sizeof(pmix_geometry_t))
#define PMIX_GEOMETRY_FREE(m, n) \
do { \
size_t _i; \
if (NULL != (m)) { \
for (_i=0; _i < (n); _i++) { \
PMIX_GEOMETRY_DESTRUCT(&(m)[_i]); \
} \
pmixabi_free((m)); \
(m) = NULL; \
} \
} while(0)
/*
* pmix_device_distance_t
*/
#define PMIX_DEVICE_DIST_CONSTRUCT(m) \
do { \
memset((m), 0, sizeof(pmix_device_distance_t)); \
(m)->mindist = UINT16_MAX; \
(m)->maxdist = UINT16_MAX; \
} while(0);
#define PMIX_DEVICE_DIST_DESTRUCT(m) \
do { \
if (NULL != ((m)->uuid)) { \
free((m)->uuid); \
} \
if (NULL != ((m)->osname)) { \
free((m)->osname); \
} \
} while(0)
#define PMIX_DEVICE_DIST_CREATE(m, n) \
do { \
size_t _i; \
pmix_device_distance_t *_m; \
_m = (pmix_device_distance_t*)pmixabi_calloc((n), sizeof(pmix_device_distance_t)); \
if (NULL != _m) { \
for (_i=0; _i < (n); _i++) { \
_m[_i].mindist = UINT16_MAX; \
_m[_i].maxdist = UINT16_MAX; \
} \
} \
(m) = _m; \
} while(0)
#define PMIX_DEVICE_DIST_FREE(m, n) \
do { \
size_t _i; \
if (NULL != (m)) { \
for (_i=0; _i < (n); _i++) { \
PMIX_DEVICE_DIST_DESTRUCT(&(m)[_i]); \
} \
free((m)); \
(m) = NULL; \
} \
} while(0)
/*
* pmix_byte_object_t
*/
#define PMIX_BYTE_OBJECT_CREATE(m, n) \
do { \
(m) = (pmix_byte_object_t*)pmixabi_malloc((n) * sizeof(pmix_byte_object_t)); \
if (NULL != (m)) { \
memset((m), 0, (n)*sizeof(pmix_byte_object_t)); \
} \
} while(0)
#define PMIX_BYTE_OBJECT_CONSTRUCT(m) \
do { \
(m)->bytes = NULL; \
(m)->size = 0; \
} while(0)
#define PMIX_BYTE_OBJECT_DESTRUCT(m) \
do { \
if (NULL != (m)->bytes) { \
pmixabi_free((m)->bytes); \
} \
(m)->bytes = NULL; \
(m)->size = 0; \
} while(0)
#define PMIX_BYTE_OBJECT_FREE(m, n) \
do { \
size_t _bon; \
if (NULL != (m)) { \
for (_bon=0; _bon < n; _bon++) { \
PMIX_BYTE_OBJECT_DESTRUCT(&(m)[_bon]); \
} \
pmixabi_free((m)); \
(m) = NULL; \
} \
} while(0)
#define PMIX_BYTE_OBJECT_LOAD(b, d, s) \
do { \
(b)->bytes = (char*)(d); \
(d) = NULL; \
(b)->size = (s); \
(s) = 0; \
} while(0)
/*
* pmix_endpoint_t
*/
#define PMIX_ENDPOINT_CONSTRUCT(m) \
memset((m), 0, sizeof(pmix_endpoint_t))
#define PMIX_ENDPOINT_DESTRUCT(m) \
do { \
if (NULL != (m)->uuid) { \
free((m)->uuid); \
} \
if (NULL != (m)->osname) { \
free((m)->osname); \
} \
if (NULL != (m)->endpt.bytes) { \
free((m)->endpt.bytes); \
} \
} while(0)
#define PMIX_ENDPOINT_CREATE(m, n) \
(m) = (pmix_endpoint_t*)pmixabi_calloc((n), sizeof(pmix_endpoint_t))
#define PMIX_ENDPOINT_FREE(m, n) \
do { \
size_t _n; \
if (NULL != (m)) { \
for (_n=0; _n < (n); _n++) { \
PMIX_ENDPOINT_DESTRUCT(&((m)[_n])); \
} \
free((m)); \
(m) = NULL; \
} \
} while(0)
/*
* pmix_envar_t
*/
#define PMIX_ENVAR_CONSTRUCT(m) \
do { \
(m)->envar = NULL; \
(m)->value = NULL; \
(m)->separator = '\0'; \
} while(0)
#define PMIX_ENVAR_DESTRUCT(m) \
do { \
if (NULL != (m)->envar) { \
pmixabi_free((m)->envar); \
(m)->envar = NULL; \
} \
if (NULL != (m)->value) { \
pmixabi_free((m)->value); \
(m)->value = NULL; \
} \
} while(0)
#define PMIX_ENVAR_CREATE(m, n) \
do { \
(m) = (pmix_envar_t*)pmixabi_calloc((n) , sizeof(pmix_envar_t)); \
} while (0)
#define PMIX_ENVAR_FREE(m, n) \
do { \
size_t _ek; \
if (NULL != (m)) { \
for (_ek=0; _ek < (n); _ek++) { \
PMIX_ENVAR_DESTRUCT(&(m)[_ek]); \
} \
pmixabi_free((m)); \
} \
} while (0)
#define PMIX_ENVAR_LOAD(m, e, v, s) \
do { \
if (NULL != (e)) { \
(m)->envar = strdup(e); \
} \
if (NULL != (v)) { \
(m)->value = strdup(v); \
} \
(m)->separator = (s); \
} while(0)
/*
* pmix_proc_t
*/
#define PMIX_PROC_CREATE(m, n) \
do { \
(m) = (pmix_proc_t*)pmixabi_calloc((n) , sizeof(pmix_proc_t)); \
} while (0)
#define PMIX_PROC_RELEASE(m) \
do { \
pmixabi_free((m)); \
(m) = NULL; \
} while (0)
#define PMIX_PROC_CONSTRUCT(m) \
do { \
memset((m), 0, sizeof(pmix_proc_t)); \
} while (0)
#define PMIX_PROC_DESTRUCT(m)
#define PMIX_PROC_FREE(m, n) \
do { \
if (NULL != (m)) { \
pmixabi_free((m)); \
(m) = NULL; \
} \
} while (0)
#define PMIX_PROC_LOAD(m, n, r) \
do { \
PMIX_PROC_CONSTRUCT((m)); \
pmixabi_strncpy((char*)(m)->nspace, (n), PMIX_MAX_NSLEN); \
(m)->rank = (r); \
} while(0)
#define PMIX_MULTICLUSTER_NSPACE_CONSTRUCT(t, c, n) \
do { \
size_t _len; \
memset((t), 0, PMIX_MAX_NSLEN+1); \
_len = pmixabi_nslen((c)); \
if ((_len + pmixabi_nslen((n))) < PMIX_MAX_NSLEN) { \
pmixabi_strncpy((char*)(t), (c), PMIX_MAX_NSLEN); \
(t)[_len] = ':'; \
pmixabi_strncpy((char*)&(t)[_len+1], (n), PMIX_MAX_NSLEN - _len); \
} \
} while(0)
#define PMIX_MULTICLUSTER_NSPACE_PARSE(t, c, n) \
do { \
size_t _n, _j; \
for (_n=0; '\0' != (t)[_n] && ':' != (t)[_n] && \
_n <= PMIX_MAX_NSLEN; _n++) { \
(c)[_n] = (t)[_n]; \
} \
_n++; \
for (_j=0; _n <= PMIX_MAX_NSLEN && \
'\0' != (t)[_n]; _n++, _j++) { \
(n)[_j] = (t)[_n]; \
} \
} while(0)
/*
* pmix_proc_info_t
*/
#define PMIX_PROC_INFO_CREATE(m, n) \
do { \
(m) = (pmix_proc_info_t*)pmixabi_calloc((n) , sizeof(pmix_proc_info_t)); \
} while (0)
#define PMIX_PROC_INFO_RELEASE(m) \
do { \
PMIX_PROC_INFO_FREE((m), 1); \
} while (0)
#define PMIX_PROC_INFO_CONSTRUCT(m) \
do { \
memset((m), 0, sizeof(pmix_proc_info_t)); \
} while (0)
#define PMIX_PROC_INFO_DESTRUCT(m) \
do { \
if (NULL != (m)->hostname) { \
pmixabi_free((m)->hostname); \
(m)->hostname = NULL; \
} \
if (NULL != (m)->executable_name) { \
pmixabi_free((m)->executable_name); \
(m)->executable_name = NULL; \
} \
} while(0)
#define PMIX_PROC_INFO_FREE(m, n) \
do { \
size_t _k; \
if (NULL != (m)) { \
for (_k=0; _k < (n); _k++) { \
PMIX_PROC_INFO_DESTRUCT(&(m)[_k]); \
} \
pmixabi_free((m)); \
} \
} while (0)
/*
* pmix_value_t
*/
/* allocate and initialize a specified number of value structs */
#define PMIX_VALUE_CREATE(m, n) \
do { \
int _ii; \
pmix_value_t *_v; \
(m) = (pmix_value_t*)pmixabi_calloc((n), sizeof(pmix_value_t)); \
_v = (pmix_value_t*)(m); \
if (NULL != (m)) { \
for (_ii=0; _ii < (int)(n); _ii++) { \
_v[_ii].type = PMIX_UNDEF; \
} \
} \
} while (0)
/* release a single pmix_value_t struct, including its data */
#define PMIX_VALUE_RELEASE(m) \
do { \
PMIX_VALUE_DESTRUCT((m)); \
pmixabi_free((m)); \
(m) = NULL; \
} while (0)
/* initialize a single value struct */
#define PMIX_VALUE_CONSTRUCT(m) \
do { \
memset((m), 0, sizeof(pmix_value_t)); \
(m)->type = PMIX_UNDEF; \
} while (0)
/* release the memory in the value struct data field */
#define PMIX_VALUE_DESTRUCT(m) \
pmixabi_value_destruct(m)
#define PMIX_VALUE_FREE(m, n) \
do { \
size_t _vv; \
if (NULL != (m)) { \
for (_vv=0; _vv < (n); _vv++) { \
PMIX_VALUE_DESTRUCT(&((m)[_vv])); \
} \
pmixabi_free((m)); \
(m) = NULL; \
} \
} while (0)
#define PMIX_VALUE_GET_NUMBER(s, m, n, t) \
do { \
(s) = PMIX_SUCCESS; \
if (PMIX_SIZE == (m)->type) { \
(n) = (t)((m)->data.size); \
} else if (PMIX_INT == (m)->type) { \
(n) = (t)((m)->data.integer); \
} else if (PMIX_INT8 == (m)->type) { \
(n) = (t)((m)->data.int8); \
} else if (PMIX_INT16 == (m)->type) { \
(n) = (t)((m)->data.int16); \
} else if (PMIX_INT32 == (m)->type) { \
(n) = (t)((m)->data.int32); \
} else if (PMIX_INT64 == (m)->type) { \
(n) = (t)((m)->data.int64); \
} else if (PMIX_UINT == (m)->type) { \
(n) = (t)((m)->data.uint); \
} else if (PMIX_UINT8 == (m)->type) { \
(n) = (t)((m)->data.uint8); \
} else if (PMIX_UINT16 == (m)->type) { \
(n) = (t)((m)->data.uint16); \
} else if (PMIX_UINT32 == (m)->type) { \
(n) = (t)((m)->data.uint32); \
} else if (PMIX_UINT64 == (m)->type) { \
(n) = (t)((m)->data.uint64); \
} else if (PMIX_FLOAT == (m)->type) { \
(n) = (t)((m)->data.fval); \
} else if (PMIX_DOUBLE == (m)->type) { \
(n) = (t)((m)->data.dval); \
} else if (PMIX_PID == (m)->type) { \
(n) = (t)((m)->data.pid); \
} else if (PMIX_PROC_RANK == (m)->type) { \
(n) = (t)((m)->data.rank); \
} else { \
(s) = PMIX_ERR_BAD_PARAM; \
} \
} while(0)
/*
* pmix_info_t
*/
#define PMIX_INFO_CREATE(m, n) \
do { \
pmix_info_t *_i; \
(m) = (pmix_info_t*)pmixabi_calloc((n), sizeof(pmix_info_t)); \
if (NULL != (m)) { \
_i = (pmix_info_t*)(m); \
_i[(n)-1].flags = PMIX_INFO_ARRAY_END; \
} \
} while (0)
#define PMIX_INFO_CONSTRUCT(m) \
do { \
memset((m), 0, sizeof(pmix_info_t)); \
(m)->value.type = PMIX_UNDEF; \
} while (0)
#define PMIX_INFO_DESTRUCT(m) \
do { \
PMIX_VALUE_DESTRUCT(&(m)->value); \
} while (0)
#define PMIX_INFO_FREE(m, n) \
do { \
size_t _is; \
if (NULL != (m)) { \
for (_is=0; _is < (n); _is++) { \
PMIX_INFO_DESTRUCT(&((m)[_is])); \
} \
pmixabi_free((m)); \
(m) = NULL; \
} \
} while (0)
#define PMIX_INFO_REQUIRED(m) \
((m)->flags |= PMIX_INFO_REQD)
#define PMIX_INFO_OPTIONAL(m) \
((m)->flags &= ~PMIX_INFO_REQD)
#define PMIX_INFO_IS_REQUIRED(m) \
((m)->flags & PMIX_INFO_REQD)
#define PMIX_INFO_IS_OPTIONAL(m) \
!((m)->flags & PMIX_INFO_REQD)
#define PMIX_INFO_WAS_PROCESSED(m) \
((m)->flags |= PMIX_INFO_REQD_PROCESSED)
#define PMIX_INFO_PROCESSED(m) \
((m)->flags & PMIX_INFO_REQD_PROCESSED)
#define PMIX_INFO_IS_END(m) \
((m)->flags & PMIX_INFO_ARRAY_END)
#define PMIX_INFO_TRUE(m) \
(PMIX_UNDEF == (m)->value.type || (PMIX_BOOL == (m)->value.type && (m)->value.data.flag)) ? true : false
/*
* pmix_pdata_t
*/
#define PMIX_PDATA_CREATE(m, n) \
do { \
(m) = (pmix_pdata_t*)pmixabi_calloc((n), sizeof(pmix_pdata_t)); \
} while (0)
#define PMIX_PDATA_RELEASE(m) \
do { \
PMIX_VALUE_DESTRUCT(&(m)->value); \
pmixabi_free((m)); \
(m) = NULL; \
} while (0)
#define PMIX_PDATA_CONSTRUCT(m) \
do { \
memset((m), 0, sizeof(pmix_pdata_t)); \
(m)->value.type = PMIX_UNDEF; \
} while (0)
#define PMIX_PDATA_DESTRUCT(m) \
do { \
PMIX_VALUE_DESTRUCT(&(m)->value); \
} while (0)
#define PMIX_PDATA_FREE(m, n) \
do { \
size_t _ps; \
pmix_pdata_t *_pdf = (pmix_pdata_t*)(m); \
if (NULL != _pdf) { \
for (_ps=0; _ps < (n); _ps++) { \
PMIX_PDATA_DESTRUCT(&(_pdf[_ps])); \
} \
pmixabi_free((m)); \
(m) = NULL; \
} \
} while (0)
/*
* pmix_app_t
*/
#define PMIX_APP_CREATE(m, n) \
do { \
(m) = (pmix_app_t*)pmixabi_calloc((n), sizeof(pmix_app_t)); \
} while (0)
#define PMIX_APP_INFO_CREATE(m, n) \
do { \
(m)->ninfo = (n); \
PMIX_INFO_CREATE((m)->info, (m)->ninfo); \
} while(0)
#define PMIX_APP_RELEASE(m) \
do { \
PMIX_APP_DESTRUCT((m)); \
pmixabi_free((m)); \
(m) = NULL; \
} while (0)
#define PMIX_APP_CONSTRUCT(m) \
do { \
memset((m), 0, sizeof(pmix_app_t)); \
} while (0)
#define PMIX_APP_DESTRUCT(m) \
do { \
size_t _aii; \
if (NULL != (m)->cmd) { \
pmixabi_free((m)->cmd); \
(m)->cmd = NULL; \
} \
if (NULL != (m)->argv) { \
for (_aii=0; NULL != (m)->argv[_aii]; _aii++) { \
pmixabi_free((m)->argv[_aii]); \
} \
pmixabi_free((m)->argv); \
(m)->argv = NULL; \
} \
if (NULL != (m)->env) { \
for (_aii=0; NULL != (m)->env[_aii]; _aii++) { \
pmixabi_free((m)->env[_aii]); \
} \
pmixabi_free((m)->env); \
(m)->env = NULL; \
} \
if (NULL != (m)->cwd) { \
pmixabi_free((m)->cwd); \
(m)->cwd = NULL; \
} \
if (NULL != (m)->info) { \
PMIX_INFO_FREE((m)->info, (m)->ninfo); \
(m)->info = NULL; \
(m)->ninfo = 0; \
} \
} while (0)
#define PMIX_APP_FREE(m, n) \
do { \
size_t _as; \
if (NULL != (m)) { \
for (_as=0; _as < (n); _as++) { \
PMIX_APP_DESTRUCT(&((m)[_as])); \
} \
pmixabi_free((m)); \
(m) = NULL; \
} \
} while (0)
/*
* pmix_query_t
*/
#define PMIX_QUERY_CREATE(m, n) \
do { \
(m) = (pmix_query_t*)pmixabi_calloc((n) , sizeof(pmix_query_t)); \
} while (0)
#define PMIX_QUERY_QUALIFIERS_CREATE(m, n) \
do { \
(m)->nqual = (n); \
PMIX_INFO_CREATE((m)->qualifiers, (m)->nqual); \
} while(0)
#define PMIX_QUERY_RELEASE(m) \
do { \
PMIX_QUERY_DESTRUCT((m)); \
pmixabi_free((m)); \
(m) = NULL; \
} while (0)
#define PMIX_QUERY_CONSTRUCT(m) \
do { \
memset((m), 0, sizeof(pmix_query_t)); \
} while (0)
#define PMIX_QUERY_DESTRUCT(m) \
do { \
size_t _qi; \
if (NULL != (m)->keys) { \
for (_qi=0; NULL != (m)->keys[_qi]; _qi++) { \
pmixabi_free((m)->keys[_qi]); \
} \
pmixabi_free((m)->keys); \
(m)->keys = NULL; \
} \
if (NULL != (m)->qualifiers) { \
PMIX_INFO_FREE((m)->qualifiers, (m)->nqual); \
(m)->qualifiers = NULL; \
(m)->nqual = 0; \
} \
} while (0)
#define PMIX_QUERY_FREE(m, n) \
do { \
size_t _qs; \
if (NULL != (m)) { \
for (_qs=0; _qs < (n); _qs++) { \
PMIX_QUERY_DESTRUCT(&((m)[_qs])); \
} \
pmixabi_free((m)); \
(m) = NULL; \
} \
} while (0)
/*
* pmix_regattr_t
*/
#define PMIX_REGATTR_CONSTRUCT(a) \
do { \
if (NULL != (a)) { \
(a)->name = NULL; \
memset((a)->string, 0, PMIX_MAX_KEYLEN+1); \
(a)->type = PMIX_UNDEF; \
(a)->description = NULL; \
} \
} while(0)
#define PMIX_REGATTR_LOAD(a, n, k, t, v) \
do { \
pmix_status_t _rgl; \
if (NULL != (n)) { \
(a)->name = strdup((n)); \
} \
if (NULL != (k)) { \
PMIX_LOAD_KEY((a)->string, (k)); \
} \
(a)->type = (t); \
if (NULL != (v)) { \
PMIX_ARGV_APPEND(_rgl, &(a)->description, (v)); \
} \
} while(0)
#define PMIX_REGATTR_DESTRUCT(a) \
do { \
if (NULL != (a)) { \
if (NULL != (a)->name) { \
pmixabi_free((a)->name); \
} \
if (NULL != (a)->description) { \
PMIX_ARGV_FREE((a)->description); \
} \
} \
} while(0)
#define PMIX_REGATTR_CREATE(m, n) \
do { \
(m) = (pmix_regattr_t*)pmixabi_calloc((n) , sizeof(pmix_regattr_t)); \
} while (0)
#define PMIX_REGATTR_FREE(m, n) \
do { \
size_t _ra; \
if (NULL != (m)) { \
for (_ra=0; _ra < (n); _ra++) { \
PMIX_REGATTR_DESTRUCT(&((m)[_ra])); \
} \
pmixabi_free((m)); \
(m) = NULL; \
} \
} while (0)
#define PMIX_REGATTR_XFER(a, b) \
do { \
size_t _n; \
PMIX_REGATTR_CONSTRUCT((a)); \
if (NULL != ((b)->name)) { \
(a)->name = strdup((b)->name); \
} \
PMIX_LOAD_KEY((a)->string, (b)->string); \
(a)->type = (b)->type; \
if (NULL != (b)->description) { \
PMIX_ARGV_COPY((a)->description, (b)->description); \
} \
} while(0)
/*
* pmix_fabric_t
*/
#define PMIX_FABRIC_CONSTRUCT(x) \
memset(x, 0, sizeof(pmix_fabric_t))
/*
* pmix_data_array_t
*/
#define PMIX_DATA_ARRAY_CONSTRUCT(m, n, t) \
do { \
(m)->type = (t); \
(m)->size = (n); \
if (0 < (n)) { \
if (PMIX_INFO == (t)) { \
PMIX_INFO_CREATE((m)->array, (n)); \
\
} else if (PMIX_PROC == (t)) { \
PMIX_PROC_CREATE((m)->array, (n)); \
\
} else if (PMIX_PROC_INFO == (t)) { \
PMIX_PROC_INFO_CREATE((m)->array, (n)); \
\
} else if (PMIX_ENVAR == (t)) { \
PMIX_ENVAR_CREATE((m)->array, (n)); \
\
} else if (PMIX_VALUE == (t)) { \
PMIX_VALUE_CREATE((m)->array, (n)); \
\
} else if (PMIX_PDATA == (t)) { \
PMIX_PDATA_CREATE((m)->array, (n)); \
\
} else if (PMIX_QUERY == (t)) { \
PMIX_QUERY_CREATE((m)->array, (n)); \
\
} else if (PMIX_APP == (t)) { \
PMIX_APP_CREATE((m)->array, (n)); \
\
} else if (PMIX_BYTE_OBJECT == (t) || \
PMIX_COMPRESSED_STRING == (t)) { \
PMIX_BYTE_OBJECT_CREATE((m)->array, (n)); \
\
} else if (PMIX_ALLOC_DIRECTIVE == (t) || \
PMIX_PROC_STATE == (t) || \
PMIX_PERSIST == (t) || \
PMIX_SCOPE == (t) || \
PMIX_DATA_RANGE == (t) || \
PMIX_BYTE == (t) || \
PMIX_INT8 == (t) || \
PMIX_UINT8 == (t) || \
PMIX_POINTER == (t)) { \
(m)->array = pmixabi_calloc((n), sizeof(int8_t)); \
\
} else if (PMIX_STRING == (t)) { \
(m)->array = pmixabi_calloc((n), sizeof(char*)); \
\
} else if (PMIX_SIZE == (t)) { \
(m)->array = pmixabi_calloc((n), sizeof(size_t)); \
\
} else if (PMIX_PID == (t)) { \
(m)->array = pmixabi_calloc((n), sizeof(pid_t)); \
\
} else if (PMIX_INT == (t) || \
PMIX_UINT == (t) || \
PMIX_STATUS == (t)) { \
(m)->array = pmixabi_calloc((n), sizeof(int)); \
\
} else if (PMIX_IOF_CHANNEL == (t) || \
PMIX_DATA_TYPE == (t) || \
PMIX_INT16 == (t) || \
PMIX_UINT16 == (t)) { \
(m)->array = pmixabi_calloc((n), sizeof(int16_t)); \