summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Jones <mjjones@us.ibm.com>2013-05-20 13:06:40 -0500
committerA. Patrick Williams III <iawillia@us.ibm.com>2013-06-03 10:50:15 -0500
commit1f79cf92ac06ef465121108f25dc58c3ac976a5e (patch)
tree5f6327284fbbf9d66595a727b01eef6e554b605d /src
parenta874adbf657c43b2bed6f3e45f4292dcc048843d (diff)
downloadtalos-hostboot-1f79cf92ac06ef465121108f25dc58c3ac976a5e.tar.gz
talos-hostboot-1f79cf92ac06ef465121108f25dc58c3ac976a5e.zip
HWPF: Improve FAPI->TARG attribute mapping compile time type check
Old code used to check that the user's data size was the same as the Targeting attribute, new code checks that the type is the same. Change-Id: Ia9d8050e9d71cecf567f549ffa74f0ed36358d76 Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/4602 Tested-by: Jenkins Server Reviewed-by: Brian H. Horton <brianh@linux.ibm.com> Reviewed-by: Van H. Lee <vanlee@us.ibm.com> Reviewed-by: A. Patrick Williams III <iawillia@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r--src/include/usr/hwpf/plat/fapiPlatAttributeService.H52
1 files changed, 24 insertions, 28 deletions
diff --git a/src/include/usr/hwpf/plat/fapiPlatAttributeService.H b/src/include/usr/hwpf/plat/fapiPlatAttributeService.H
index 812ecb6fc..97c60b0de 100644
--- a/src/include/usr/hwpf/plat/fapiPlatAttributeService.H
+++ b/src/include/usr/hwpf/plat/fapiPlatAttributeService.H
@@ -70,23 +70,18 @@ namespace platAttrSvc
{
/**
- * @brief Compile time check that a FAPI attribute is the same size as a
- * TARGETING attribute when they are direct mapped
+ * @brief Compile time check that a variable is the same type as a Targeting
+ * attribute.
*
- * If the size is different then an undefined class is instantiated leading
- * to a compile time failure else an empty inline function is optimized out
- * by the compiler.
+ * Used when mapping a FAPI Attribute to a Targeting attribute to ensure that
+ * the type is correct, if not correct then this function will not be found
+ * and a compile error will result
*
- * @param[in] result of size comparison
- *
- * @return Pointer to Targeting Target
+ * @param[in] T Type of Targeting attribute
+ * @param[in] Reference to user's FAPI Attribute variable that must be of
+ * type T
*/
-class ErrorFapiTargSizeMismatch;
-template<const bool SIZE_MISMATCH> void failIfFapiTargAttrSizeMismatch()
-{
- ErrorFapiTargSizeMismatch();
-}
-template <> inline void failIfFapiTargAttrSizeMismatch<false>() {}
+template<typename T> void failIfTargTypeMismatch(T &) { }
/**
* @brief Gets a Targeting attribute, this is called by the macro that maps a
@@ -463,29 +458,30 @@ fapi::ReturnCode fapiPlatGetPhaseRotatorData (
} // namespace fapi
/**
- * @brief Macro which directly maps a FAPI_ATTR_GET to a Targeting attr get
+ * @brief Macro that directly maps a FAPI_ATTR_GET to a Targeting attr get
*
- * Firstly there is a compile time check that the FAPI Attribute has the same
- * size as the correpsonding TARGETING attribute, this is optimized out, then
- * there is a single function call
+ * Firstly there is a compile time check that the user's VAL variable matches
+ * the Targeting attribute type, this is optimized out, then there is a
+ * single function call
*/
#define FAPI_PLAT_ATTR_SVC_GETMACRO_DIRECT(ID, PTARGET, VAL) \
- (fapi::platAttrSvc::failIfFapiTargAttrSizeMismatch<sizeof(VAL) != \
- sizeof(TARGETING::AttributeTraits \
- <FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID>::Type)>(), \
+ (fapi::platAttrSvc::failIfTargTypeMismatch \
+ <TARGETING::AttributeTraits \
+ <FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID>::Type>(VAL), \
fapi::platAttrSvc::getTargetingAttr(PTARGET, \
FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID, sizeof(VAL), &(VAL)))
+
/**
- * @brief Macro which directly maps a FAPI_ATTR_SET to a Targeting attr set
+ * @brief Macro that directly maps a FAPI_ATTR_SET to a Targeting attr set
*
- * Firstly there is a compile time check that the FAPI Attribute has the same
- * size as the correpsonding TARGETING attribute, this is optimized out, then
- * there is a single function call
+ * Firstly there is a compile time check that the user's VAL variable matches
+ * the Targeting attribute type, this is optimized out, then there is a
+ * single function call
*/
#define FAPI_PLAT_ATTR_SVC_SETMACRO_DIRECT(ID, PTARGET, VAL) \
- (fapi::platAttrSvc::failIfFapiTargAttrSizeMismatch<sizeof(VAL) != \
- sizeof(TARGETING::AttributeTraits \
- <FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID>::Type)>(), \
+ (fapi::platAttrSvc::failIfTargTypeMismatch \
+ <TARGETING::AttributeTraits \
+ <FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID>::Type>(VAL), \
fapi::platAttrSvc::setTargetingAttr(PTARGET, \
FAPI_PLAT_ATTR_SVC_MACRO_DIRECT_FAPI_##ID, sizeof(VAL), &(VAL)))
OpenPOWER on IntegriCloud