apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Trawick <traw...@attglobal.net>
Subject Re: cvs commit: apr/atomic/netware apr_atomic.c
Date Thu, 04 Dec 2003 23:57:48 GMT
William A. Rowe, Jr. wrote:

>>  APR_DECLARE(apr_uint32_t) apr_atomic_add32(volatile apr_uint32_t *mem, apr_uint32_t
>>  {
>> -    return atomic_add((unsigned long *)mem,(unsigned long)val);
>> +    apr_uint32_t old = *mem;
>> +    atomic_add((unsigned long *)mem,(unsigned long)val);
>> +    return old;
>>  }

> Because the old value isn't atomically fetched with the add/sub operation, 
> is this solution worse than no solution at all?

looked that way to me...   c-a-s time

> 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?

I'll be glad just to have a set that is functionally sufficient to support 
common ideoms :)  Start asking for adding more to the mess we have now (which 
doesn't support enough platforms) and I'm back to wishing we had just a simple 
core routine (cas32, but also casptr) implemented for n platforms and the rest 
of it portable functions using the cas32 primitive.

View raw message