You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by "William A. Rowe, Jr." <wr...@rowe-clan.net> on 2003/01/10 04:38:46 UTC

Re: apr_atomic_casptr macro (was Re: Showstopper ... was: Tagged the tree)

At 05:02 PM 1/9/2003, Brad Nicholes wrote:
>The original problem that caused us to have to type cast is the fact
>that our compiler complains about the type mismatch between void* and
>unsigned long.  How does this resolve that issue?  It still looks like I
>am going to get a type mismatch.

The code below shouldn't.

typedef void*(*apr_atomic_casptr_fn_t)(void** mem, const void *cmp, const void *with);
#define apr_atomic_casptr ((apr_atomic_casptr_fn_t)(atomic_cmpxchg))

IFF the stack setup for the atomic_cmpxchg fn and the 
apr_atomic_casptr_fn_t typedefs are the same, you are 
still using a cast, but applying it to the fn itself.  The args
are still evaluated, but in terms of apr_atomic_casptr_fn_t's
declaration ;-)

See how the optional functions behave to get a little bit more
clarity about how/why we've coded functions this way.

Bill