[PATCH 2.3.1] wombat: make wInterlocked_set consistent


Sam Wilson <Sam.Wilson@...>
 

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)
{


Damian Maguire <DMaguire@...>
 

Cheers for the patch Sam, looks good. Can you raise this in bugzilla
(bugs.openmama.org) as well, and we can track getting it into next
there?

Thanks,

Damian

On Thu, 2014-10-02 at 13:25 +0000, Sam Wilson wrote:
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)
{
________________________________________________________

This message may contain confidential information and is intended for specific recipients unless explicitly noted otherwise. If you have reason to believe you are not an intended recipient of this message, please delete it and notify the sender. This message may not represent the opinion of Intercontinental Exchange, Inc. (ICE), Euronext or any of their subsidiaries or affiliates, and does not constitute a contract or guarantee. Unencrypted electronic mail is not secure and the recipient of this message is expected to provide safeguards from viruses and pursue alternate means of communication where privacy or a binding message is desired.
________________________________________________________