apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Pane <bp...@pacbell.net>
Subject Re: problem with apr_atomic_init on freebsd
Date Fri, 05 Jul 2002 21:25:45 GMT
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

/* 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);

#if !defined(apr_atomic_inc)
void apr_atomic_inc(volatile apr_atomic_t *mem);

/* ...declarations for the rest of the atomic functions... */

/* Finally, decide whether we need a de apr_atomic_init() */
apr_status_t apr_atomic_init(apr_pool_t *p);
#define apr_atomic_init(p)   APR_SUCCESS

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.


View raw message