apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@apache.org>
Subject Re: cvs commit: apr/atomic/netware apr_atomic.c
Date Thu, 04 Dec 2003 22:40:05 GMT
Because the old value isn't atomically fetched with the add/sub operation, 
is this solution worse than no solution at all?

Perhaps we need two flavors, one fast (add/sub) that do *not* rely on any
result value (returning void) and another that explicitly returns the old value
on add, and the new value on subtract?

Bill

At 03:44 PM 12/4/2003, bnicholes@apache.org wrote:
>bnicholes    2003/12/04 13:44:33
>
>  Modified:    atomic/netware apr_atomic.c
>  Log:
>  Fix up the return values for apr_atomic_add32() and apr_atomic_inc32() since the native
Netware functions return void by default
>  
>  Revision  Changes    Path
>  1.8       +6 -2      apr/atomic/netware/apr_atomic.c
>  
>  Index: apr_atomic.c
>  ===================================================================
>  RCS file: /home/cvs/apr/atomic/netware/apr_atomic.c,v
>  retrieving revision 1.7
>  retrieving revision 1.8
>  diff -u -r1.7 -r1.8
>  --- apr_atomic.c      4 Dec 2003 20:06:03 -0000       1.7
>  +++ apr_atomic.c      4 Dec 2003 21:44:33 -0000       1.8
>  @@ -64,7 +64,9 @@
>   
>   APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t
val)
>   {
>  -    return atomic_add((unsigned long *)mem,(unsigned long)val);
>  +    apr_uint32_t old = *mem;
>  +    atomic_add((unsigned long *)mem,(unsigned long)val);
>  +    return old;
>   }
>   
>   APR_DECLARE(void) apr_atomic_sub32(volatile apr_uint32_t *mem, apr_uint32_t val)
>  @@ -74,7 +76,9 @@
>   
>   APR_DECLARE(apr_uint32_t) apr_atomic_inc32(volatile apr_uint32_t *mem)
>   {
>  -    return atomic_inc((unsigned long *)mem);
>  +    apr_uint32_t old = *mem;
>  +    atomic_inc((unsigned long *)mem);
>  +    return old;
>   }
>   
>   APR_DECLARE(void) apr_atomic_set32(volatile apr_uint32_t *mem, apr_uint32_t val)
>  
>  
>  


Mime
View raw message