apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr/include apr_atomic.h
Date Wed, 15 Oct 2003 21:33:22 GMT
wrowe       2003/10/15 14:33:22

  Modified:    include  apr_atomic.h
  Log:
    Use function overrides to provide the correct argument types for our
    macro'ized atomic transliterations.
  
    This code is 100% safer than the equivilant argument and return value
    casts, because the user's first arg can't be forced from a value to
    a pointer, and conversly for more than one argument.
  
  Revision  Changes    Path
  1.60      +31 -2     apr/include/apr_atomic.h
  
  Index: apr_atomic.h
  ===================================================================
  RCS file: /home/cvs/apr/include/apr_atomic.h,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- apr_atomic.h	15 Oct 2003 20:39:34 -0000	1.59
  +++ apr_atomic.h	15 Oct 2003 21:33:22 -0000	1.60
  @@ -239,13 +239,42 @@
   
   #define apr_atomic_init(pool)        APR_SUCCESS
   #define apr_atomic_add(mem, val)     InterlockedExchangeAdd(mem,val)
  -#define apr_atomic_dec(mem)          InterlockedDecrement(mem)
   #define apr_atomic_inc(mem)          InterlockedIncrement(mem)
  +#define apr_atomic_dec(mem)          InterlockedDecrement(mem)
   #define apr_atomic_set(mem, val)     InterlockedExchange(mem, val)
   #define apr_atomic_read(mem)         (*mem)
   #define apr_atomic_cas(mem,with,cmp) InterlockedCompareExchange(mem,with,cmp)
   #define apr_atomic_casptr(mem,with,cmp) InterlockedCompareExchangePointer(mem,with,cmp)
   
  +/* 
  + * Remapping function pointer type to accept apr_uint32_t's type-safely
  + * as the arguments for as our apr_atomic_foo32 Functions
  + */
  +typedef WINBASEAPI apr_uint32_t (WINAPI apr_atomic_win32_ptr_fn)
  +                                           (apr_uint32_t volatile *);
  +typedef WINBASEAPI apr_uint32_t (WINAPI apr_atomic_win32_ptr_val_fn)
  +                                           (apr_uint32_t volatile *, 
  +                                            apr_uint32_t);
  +typedef WINBASEAPI apr_uint32_t (WINAPI apr_atomic_win32_ptr_val_val_fn)
  +                                           (apr_uint32_t volatile *, 
  +                                            apr_uint32_t, apr_uint32_t);
  +
  +#define apr_atomic_add32(mem, val)      \
  +    ((apr_atomic_win32_ptr_val_fn)InterlockedExchangeAdd)(mem,val)
  +#define apr_atomic_sub32(mem, val)      \
  +    ((apr_atomic_win32_ptr_val_fn)InterlockedExchangeSub)(mem,val)
  +#define apr_atomic_inc32(mem)           \
  +    ((apr_atomic_win32_ptr_fn)InterlockedIncrement)(mem)
  +#define apr_atomic_dec32(mem)           \
  +    ((apr_atomic_win32_ptr_fn)InterlockedDecrement)(mem)
  +#define apr_atomic_set32(mem, val)      \
  +    ((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem,val)
  +#define apr_atomic_read32(mem)          (*mem)
  +#define apr_atomic_cas32(mem,with,cmp)  \
  +    ((apr_atomic_win32_ptr_val_val_fn)InterlockedCompareExchange)(mem,val)
  +#define apr_atomic_xchg32(mem,val)      \
  +    ((apr_atomic_win32_ptr_val_fn)InterlockedExchange)(mem,val)
  +
   #elif defined(NETWARE)
   
   #define apr_atomic_init(pool)           APR_SUCCESS
  @@ -507,7 +536,7 @@
    */
   #if APR_ATOMIC_NEED_DEFAULT_INIT
   #if defined(apr_atomic_init) || defined(APR_OVERRIDE_ATOMIC_INIT)
  -#error Platform has redefined apr_atomic_init, but other default default atomics require
a default apr_atomic_init
  +#error Platform has redefined apr_atomic_init, but other default atomics require a default
apr_atomic_init
   #endif
   #endif /* APR_ATOMIC_NEED_DEFAULT_INIT */
   
  
  
  

Mime
View raw message