Closed bremoran closed 8 years ago
one way to instantiate them would be add declarations for the specializations in atomic_ops.h:
/* For ARMv7-M and above, we use the load/store-exclusive instructions to
* implement atomic_cas, so we provide three specialization corresponding to the
* byte, half-word, and word variants of the instructions. As long as the following
* declarations are available, the compiler will find the proper call targets. */
#if (__CORTEX_M >= 0x03)
template <> bool atomic_cas<uint8_t> (uint8_t *ptr, uint8_t *expectedCurrentValue, uint8_t desiredValue);
template <> bool atomic_cas<uint16_t>(uint16_t *ptr, uint16_t *expectedCurrentValue, uint16_t desiredValue);
template <> bool atomic_cas<uint32_t>(uint32_t *ptr, uint32_t *expectedCurrentValue, uint32_t desiredValue);
#endif /* #if (__CORTEX_M >= 0x03) */
ARM Internal Ref: IOTSFW-1824
Since overloads are adequate and templates are not required for the specialized versions of atomic_cas
I would prefer the overload version.
I was incorrect: Using overloads instead of template specializations causes atomic_incr
to select the wrong version of atomic_cas
.
Template specializations of
atomic_cas
are not instantiated because they live in a cpp file and are not available to the compiler for elaboration during function template name lookup. The specializations ofatomic_cas
should live in eitheratomic_ops.h
or a header included byatomic_ops.h