summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrooneg <rooneg@13f79535-47bb-0310-9956-ffa450edef68>2006-09-25 16:32:02 +0000
committerrooneg <rooneg@13f79535-47bb-0310-9956-ffa450edef68>2006-09-25 16:32:02 +0000
commit213b3e129b8742a1f34f84b82e30547102d2bbe6 (patch)
tree835649babce81baf6115df6895488033a9e18712
parent4ea1b5148498cb629d65bf9762dbe5035a2e6bd0 (diff)
downloadlibapr-213b3e129b8742a1f34f84b82e30547102d2bbe6.tar.gz
Fix apr_atomic_cas on platforms with 64 bit longs.
This is being committed to 0.9.x directly because it is no longer applicable to the 1.x branches. Submitted by: Philip Martin <philip codematters.co.uk> * atomic/unix/apr_atomic.c (apr_atomic_cas): Truncate 64 bit argument values. * CHANGES: Note change. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/0.9.x@449724 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--CHANGES3
-rw-r--r--atomic/unix/apr_atomic.c16
2 files changed, 11 insertions, 8 deletions
diff --git a/CHANGES b/CHANGES
index 7c760fcd1..0e659d9b5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,8 @@
Changes with APR 0.9.13
+ *) Fix apr_atomic_cas on platforms with 64 bit longs.
+ [Philip Martin <philip codematters.co.uk>]
+
*) Provide folding in autogenerated .manifest files for Win32 builders
using VisualStudio 2005 [William Rowe]
diff --git a/atomic/unix/apr_atomic.c b/atomic/unix/apr_atomic.c
index 87758523d..d7a223a06 100644
--- a/atomic/unix/apr_atomic.c
+++ b/atomic/unix/apr_atomic.c
@@ -123,23 +123,23 @@ int apr_atomic_dec(volatile apr_atomic_t *mem)
#if !defined(apr_atomic_cas) && !defined(APR_OVERRIDE_ATOMIC_CAS)
apr_uint32_t apr_atomic_cas(volatile apr_uint32_t *mem, long with, long cmp)
{
- long prev;
+ apr_uint32_t prev;
#if APR_HAS_THREADS
apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)];
if (apr_thread_mutex_lock(lock) == APR_SUCCESS) {
- prev = *(long*)mem;
- if (prev == cmp) {
- *(long*)mem = with;
+ prev = *mem;
+ if (prev == (apr_uint32_t)cmp) {
+ *mem = (apr_uint32_t)with;
}
apr_thread_mutex_unlock(lock);
return prev;
}
- return *(long*)mem;
+ return *mem;
#else
- prev = *(long*)mem;
- if (prev == cmp) {
- *(long*)mem = with;
+ prev = *mem;
+ if (prev == (apr_uint32_t)cmp) {
+ *mem = (apr_uint32_t)with;
}
return prev;
#endif /* APR_HAS_THREADS */