From cvs-return-2946-apmail-apr-cvs-archive=apr.apache.org@apr.apache.org Tue Feb 12 21:49:16 2002 Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 44655 invoked by uid 500); 12 Feb 2002 21:49:16 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 44643 invoked from network); 12 Feb 2002 21:49:16 -0000 Date: 12 Feb 2002 21:49:15 -0000 Message-ID: <20020212214915.21349.qmail@icarus.apache.org> From: ianh@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/include apr_atomic.h X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ianh 02/02/12 13:49:15 Added: atomic/unix apr_atomic.c include apr_atomic.h Log: atomic operation. still expermental Revision Changes Path 1.1 apr/atomic/unix/apr_atomic.c Index: apr_atomic.c =================================================================== #include "apr.h" #include "apr_lock.h" #include "apr_thread_mutex.h" #include "apr_atomic.h" #ifdef WIN32 /* win32 implementation is all macros */ #else #define NUM_ATOMIC_HASH 7 /* shift by 2 to get rid of alignment issues */ #define ATOMIC_HASH(x) (int)(((long)x>>2)%NUM_ATOMIC_HASH) static apr_thread_mutex_t **hash_mutex; apr_status_t apr_atomic_init(apr_pool_t *p ) { int i; apr_status_t rv; hash_mutex =apr_palloc(p,sizeof(apr_thread_mutex_t*) * NUM_ATOMIC_HASH); for (i=0;i. * * Portions of this software are based upon public domain software * originally written at the National Center for Supercomputing Applications, * University of Illinois, Urbana-Champaign. */ #ifndef APR_ATOMIC_H #define APR_ATOMIC_H #ifdef __cplusplus extern "C" { #endif #ifdef WIN32 #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_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_init(pool) APR_SUCCESS #else #define apr_atomic_read(p) *p apr_status_t apr_atomic_init(apr_pool_t *p); long apr_atomic_set(volatile long*mem, long val); long apr_atomic_add(volatile long*mem, long val); long apr_atomic_inc( volatile long *mem); long apr_atomic_dec(volatile long *mem); long apr_atomic_cas(volatile long *mem,long with,long cmp); #endif #ifdef __cplusplus } #endif #endif /* !APR_ATOMIC_H */