From 4b46e70b37a5691b17d7770a527f454d24fb94c4 Mon Sep 17 00:00:00 2001 From: doodspav Date: Sat, 11 May 2024 02:40:44 +0300 Subject: [PATCH] GHI #32 Add explicit and transaction feature check functions --- include/patomic/types/feature_check.h | 178 ++++++++++++++++++++++++++ 1 file changed, 178 insertions(+) diff --git a/include/patomic/types/feature_check.h b/include/patomic/types/feature_check.h index 32bff1703..76c0d688d 100644 --- a/include/patomic/types/feature_check.h +++ b/include/patomic/types/feature_check.h @@ -264,6 +264,60 @@ patomic_feature_check_all( ); +/** + * @addtogroup feature_check + * + * @brief + * Checks if all of the operations in all the categories in a set of opcats + * are supported by the given explicit ops struct. + * + * @param opcats + * One or more patomic_opcat_t flags combined. + * + * @returns + * The input "opcats" value where each bit corresponding to a supported opcat + * has been cleared. An opcat is supported if all of its operations are + * supported. A return value of 0 means that everything requested is + * supported. + * + * @note + * Invalid bits in "opcats" which do not correspond to a patomic_opcat_t + * label are ignored and remain set in the return value. + */ +PATOMIC_EXPORT unsigned int +patomic_feature_check_all_explicit( + const patomic_ops_explicit_t *ops, + unsigned int opcats +); + + +/** + * @addtogroup feature_check + * + * @brief + * Checks if all of the operations in all the categories in a set of opcats + * are supported by the given transaction ops struct. + * + * @param opcats + * One or more patomic_opcat_t flags combined. + * + * @returns + * The input "opcats" value where each bit corresponding to a supported opcat + * has been cleared. An opcat is supported if all of its operations are + * supported. A return value of 0 means that everything requested is + * supported. + * + * @note + * Invalid bits in "opcats" which do not correspond to a patomic_opcat_t + * label are ignored and remain set in the return value. + */ +PATOMIC_EXPORT unsigned int +patomic_feature_check_all_transaction( + const patomic_ops_transaction_t *ops, + unsigned int opcats +); + + /** * @addtogroup feature_check * @@ -291,6 +345,60 @@ patomic_feature_check_any( ); +/** + * @addtogroup feature_check + * + * @brief + * Checks if any of the operations in all the categories in a set of opcats + * are supported by the given explicit ops struct. + * + * @param opcats + * One or more patomic_opcat_t flags combined. + * + * @returns + * The input "opcats" value where each bit corresponding to a supported opcat + * has been cleared. An opcat is supported if any of its operations are + * supported. A return value of 0 means that everything requested is + * supported. + * + * @note + * Invalid bits in "opcats" which do not correspond to a patomic_opcat_t + * label are ignored and remain set in the return value. + */ +PATOMIC_EXPORT unsigned int +patomic_feature_check_any_explicit( + const patomic_ops_explicit_t *ops, + unsigned int opcats +); + + +/** + * @addtogroup feature_check + * + * @brief + * Checks if any of the operations in all the categories in a set of opcats + * are supported by the given transaction ops struct. + * + * @param opcats + * One or more patomic_opcat_t flags combined. + * + * @returns + * The input "opcats" value where each bit corresponding to a supported opcat + * has been cleared. An opcat is supported if any of its operations are + * supported. A return value of 0 means that everything requested is + * supported. + * + * @note + * Invalid bits in "opcats" which do not correspond to a patomic_opcat_t + * label are ignored and remain set in the return value. + */ +PATOMIC_EXPORT unsigned int +patomic_feature_check_any_transaction( + const patomic_ops_transaction_t *ops, + unsigned int opcats +); + + /** * @addtogroup feature_check * @@ -326,4 +434,74 @@ patomic_feature_check_leaf( ); +/** + * @addtogroup feature_check + * + * @brief + * Checks if any operations in the set of opkinds in the category opcat are + * supported by the given explicit ops struct. + * + * @param opcat + * Any single patomic_opcat_t flag that has a single bit set. + * + * @param opkinds + * One or more patomic_opkind_t flags combined. + * + * @returns + * The input "opkinds" value interpreted according to "opcat" where each bit + * corresponding to a supported opkind has been cleared. A return value of 0 + * means that everything requested is supported. + * + * @note + * Invalid bits in "opkinds" which do not correspond to a patomic_opkind_t + * label are ignored and remain set in the return value. + * + * @warning + * The "opcat" value MUST have exactly 1 bit set. This means that labels such + * as patomic_opcat_NONE and patomic_opcats_* are not allowed. This will + * always be asserted (even if NDEBUG is defined). + */ +PATOMIC_EXPORT unsigned int +patomic_feature_check_leaf_explicit( + const patomic_ops_explicit_t *ops, + patomic_opcat_t opcat, + unsigned int opkinds +); + + +/** + * @addtogroup feature_check + * + * @brief + * Checks if any operations in the set of opkinds in the category opcat are + * supported by the given transaction ops struct. + * + * @param opcat + * Any single patomic_opcat_t flag that has a single bit set. + * + * @param opkinds + * One or more patomic_opkind_t flags combined. + * + * @returns + * The input "opkinds" value interpreted according to "opcat" where each bit + * corresponding to a supported opkind has been cleared. A return value of 0 + * means that everything requested is supported. + * + * @note + * Invalid bits in "opkinds" which do not correspond to a patomic_opkind_t + * label are ignored and remain set in the return value. + * + * @warning + * The "opcat" value MUST have exactly 1 bit set. This means that labels such + * as patomic_opcat_NONE and patomic_opcats_* are not allowed. This will + * always be asserted (even if NDEBUG is defined). + */ +PATOMIC_EXPORT unsigned int +patomic_feature_check_leaf_transaction( + const patomic_ops_transaction_t *ops, + patomic_opcat_t opcat, + unsigned int opkinds +); + + #endif /* PATOMIC_FEATURE_CHECK_H */