On Fri, 2002-07-05 at 14:09, Garrett Rooney wrote:
> On Fri, Jul 05, 2002 at 02:05:41PM -0700, Brian Pane wrote:
>
> > Here's what I have so far. It's basically the same as what
> > you've described, except that I have an additional check to
> > make sure the apr_atomic_init() isn't already defined as a
> > macro.
> >
> > Does this work on FreeBSD?
>
> this works fine here. while it would be nice if someone could get the
> ifdefs in apr_atomic.h figured out so that we don't need to do this,
> it's not a big deal, and this fixes the build, so i'd say commit it.
Thanks, I just commited the change.
To fix the configuration of atomics more generally, what I'm
thinking of is a restructuring of apr_atomic.h to look like
this:
/* First, platform specific overrides */
#if platform1
/* #define any atomic functions that have native implementations
* on platform1
*/
#define apr_atomic_cas(mem, with, cmp) Platform1_CAS(mem, with, cmp)
#define apr_atomic_set(mem, val) (*mem) = (val)
#elif platform2
/* #define any atomic functions that have native implementations
* on platform2
*/
#define apr_atomic_cas(mem, with, cmp) asm(...inline assembly...)
#elif /* etc... */
#endif /* end of platform-specific overrides */
/* Now declare all the functions that haven't
#if !defined(apr_atomic_add)
void apr_atomic_add(volatile apr_atomic_t *mem, apr_uint32_t val);
#define NEED_ATOMIC_INIT 1
#endif
#if !defined(apr_atomic_inc)
void apr_atomic_inc(volatile apr_atomic_t *mem);
#define NEED_ATOMIC_INIT 1
#endif
/* ...declarations for the rest of the atomic functions... */
/* Finally, decide whether we need a de apr_atomic_init() */
#if NEED_ATOMIC_INIT
apr_status_t apr_atomic_init(apr_pool_t *p);
#else
#define apr_atomic_init(p) APR_SUCCESS
#endif
This design would let us handle each atomic API function
independently of the rest: if a platform has native versions
of atomic_set and atomic_read, for example, we can use those
and fall back on the mutex-based C functions for all the other
operations in the atomic API.
--Brian