On Sat, 2003-03-22 at 20:39, Craig Rodrigues wrote:
> -#define apr_atomic_set(mem, val) atomic_set_int(mem, val)
> +#define apr_atomic_set(mem, val) (*(mem) = val)
This part looks okay; we make the same assumption (that
a 32-bit aligned write is atomic) on many other platforms.
> #define apr_atomic_read(mem) (*mem)
> +
> +#define APR_OVERRIDE_ATOMIC_DEC 1
> +APR_INLINE int apr_atomic_dec(apr_atomic_t *mem)
> +{
> + atomic_subtract_int(mem,1);
> + return *mem;
> +}
As a couple of people have noted already, this one won't
really provide atomicity.
The only solutions I can think of at the moment are:
1) Fall back to the default mutex-based implementation
for apr_atomic_dec on FreeBSD, or
2) Use inline assembly like we do for Linux, with a
fallback to the mutex-based implementation for
CPUs where we don't have an assembly version.
What do you think of option 2?
Brian