Philip Martin <[EMAIL PROTECTED]> writes:

> Port some of the atomic code from 1.2.x to 0.9.x, in particular make
> mutex operations that fail cause an abort and make the generic C
> implementation of apr_atomic_cas work on 64 bit platforms.

A less radical change to the code is simply to truncate the 64 bit
values and rely on the application not to need those bits.  This
should be enough to fix Subversion which only uses small +ve integers.

* atomic/unix/apr_atomic.c (apr_atomic_cas): Truncate 64 bit argument
  values.

Index: atomic/unix/apr_atomic.c
===================================================================
--- atomic/unix/apr_atomic.c    (revision 449122)
+++ atomic/unix/apr_atomic.c    (working copy)
@@ -123,23 +123,23 @@
 #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 */

-- 
Philip Martin


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to