Fix asymmetry in data structure construct/destruct API
Overview
Some PMIx data structures use a function for construction and a macro for destruction. See https://github.com/openpmix/openpmix/pull/2844 for a discussion of this issue.
Motivation
For consistency, the PMIx standard should be symmetric and consistent in the interface used for the data structure lifecycle. This discontinuity occurred while making the ABI for datatypes that were complex to construct but simple to destruct.
Discussion Items
Per PMIx Meeting on Dec. 8, 2022, the group decided to use functions for both types of operations. An implementation may provide a macro for backward compatibility that calls the appropriate function. The rationale was that by using functions instead of macros makes the interface stronger in an ABI sense, as well as more consistent.
I'm kinda stuck on how to convert this macro to a function:
I'm kinda stuck on how to convert this macro to a function:
#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)
Any suggestions?
I have converted all the macros to functions, except for the one posted above. I think I have a solution there and will be playing with it next.
I think this issue has been resolved when we added the ABI in v5.0.