Hey,
Attached is a patch to make wInterlocked_set consistent between Windows
and Linux. The previous behaviour on Windows was to return the prior
value of the interlocked int, while on Linux the behaviour was to return
the new value.
This patch makes both platforms return the prior value, and updates the
documentation to express that.
diff --git a/common/c_cpp/src/c/linux/wInterlocked.h
b/common/c_cpp/src/c/linux/wInterlocked.h
index 6ee00db..720e54d 100644
--- a/common/c_cpp/src/c/linux/wInterlocked.h
+++ b/common/c_cpp/src/c/linux/wInterlocked.h
@@ -131,12 +131,11 @@ WCOMMONINLINE int
wInterlocked_read(wInterlockedInt *value)
*
* @param[in] newValue The new value to set.
* @param[in] value Pointer to the value to be set.
- * @return The updated integer.
+ * @return The original integer in value.
*/
WCOMMONINLINE int wInterlocked_set(int newValue, wInterlockedInt *value)
{
- axchg32(value, (uint32_t)newValue);
- return (int)*value;
+ return axchg32(value, (uint32_t)newValue);
}
#endif /* _WOMBAT_WINTERLOCKED_H */
diff --git a/common/c_cpp/src/c/windows/wombat/wInterlocked.h
b/common/c_cpp/src/c/windows/wombat/wInterlocked.h
index f5da11a..f93e088 100644
--- a/common/c_cpp/src/c/windows/wombat/wInterlocked.h
+++ b/common/c_cpp/src/c/windows/wombat/wInterlocked.h
@@ -87,7 +87,7 @@ WCOMMONINLINE int wInterlocked_read(wInterlockedInt
*value)
*
* @param[in] newValue The new value to set.
* @param[in] value Pointer to the value to be set.
- * @return The updated integer.
+ * @return The original integer in value.
*/
WCOMMONINLINE int wInterlocked_set(int newValue, wInterlockedInt *value)
{