apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ian Holsman <Ian.Hols...@cnet.com>
Subject RE: cvs commit: apr/atomic/netware apr_atomic.c
Date Thu, 28 Mar 2002 00:46:37 GMT
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

hi.

this wont work as you still have race conditions
in the 2 functions you implented (the _dec and _cas)
oh.. and the _dec looks like it is adding instead of subtracting

is novell x86 only ?
I'm thinking of just grabbing freeBSD's atomic implementation
and using that as the default x86 implementation.

> -----Original Message-----
> From: bnicholes@apache.org [mailto:bnicholes@apache.org]
> Sent: Wednesday, March 27, 2002 3:52 PM
> To: apr-cvs@apache.org
> Subject: cvs commit: apr/atomic/netware apr_atomic.c
> 
> 
> bnicholes    02/03/27 15:51:51
> 
>   Modified:    .        NWGNUmakefile
>                build    nw_export.inc
>                include  apr_atomic.h
>   Added:       atomic/netware apr_atomic.c
>   Log:
>   Added the NetWare version of atomic.c to the build
>   
>   Revision  Changes    Path
>   1.2       +5 -0      apr/NWGNUmakefile
>   
>   Index: NWGNUmakefile
>  
> ===================================================================
>   RCS file: /home/cvs/apr/NWGNUmakefile,v
>   retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- NWGNUmakefile	1 Mar 2002 22:25:26 -0000	1.1
>   +++ NWGNUmakefile	27 Mar 2002 23:51:50 -0000	1.2
>   @@ -238,6 +238,7 @@
>    # Paths must all use the '/' character
>    #
>    FILES_lib_objs = \
>   +	$(OBJDIR)/apr_atomic.o \
>    	$(OBJDIR)/apr_cpystrn.o \
>    	$(OBJDIR)/apr_fnmatch.o \
>    	$(OBJDIR)/apr_getpass.o \
>   @@ -317,6 +318,10 @@
>    #
>    # Any specialized rules here
>    #
>   +
>   +$(OBJDIR)/%.o: atomic/netware/%.c $(OBJDIR)\cc.opt
>   +	@echo Compiling $<
>   +	$(CC) atomic\netware\$(<F) -o=$(OBJDIR)\$(@F) @$(OBJDIR)\cc.opt
>    
>    $(OBJDIR)/%.o: strings/%.c $(OBJDIR)\cc.opt
>    	@echo Compiling $<
>   
>   
>   
>   1.4       +1 -0      apr/build/nw_export.inc
>   
>   Index: nw_export.inc
>  
> ===================================================================
>   RCS file: /home/cvs/apr/build/nw_export.inc,v
>   retrieving revision 1.3
>   retrieving revision 1.4
>   diff -u -r1.3 -r1.4
>   --- nw_export.inc	20 Feb 2002 19:58:57 -0000	1.3
>   +++ nw_export.inc	27 Mar 2002 23:51:50 -0000	1.4
>   @@ -10,6 +10,7 @@
>    #undef APR_DECLARE_DATA
>    
>    /* Preprocess all of the standard APR headers. */
>   +#include "apr_atomic.h"
>    #include "apr_compat.h"
>    #include "apr_dso.h"
>    #include "apr_errno.h"
>   
>   
>   
>   1.21      +1 -1      apr/include/apr_atomic.h
>   
>   Index: apr_atomic.h
>  
> ===================================================================
>   RCS file: /home/cvs/apr/include/apr_atomic.h,v
>   retrieving revision 1.20
>   retrieving revision 1.21
>   diff -u -r1.20 -r1.21
>   --- apr_atomic.h	22 Mar 2002 18:51:07 -0000	1.20
>   +++ apr_atomic.h	27 Mar 2002 23:51:51 -0000	1.21
>   @@ -176,7 +176,7 @@
>    #define apr_atomic_t unsigned long
>    
>    #define apr_atomic_add(mem, val)     atomic_add(mem,val)
>   -#define apr_atomic_dec(mem)          atomic_dec(mem)
>   +APR_DECLARE(int) apr_atomic_dec(apr_atomic_t *mem);
>    #define apr_atomic_inc(mem)          atomic_inc(mem)
>    #define apr_atomic_set(mem, val)     (*mem = val)
>    #define apr_atomic_read(mem)         (*mem)
>   
>   
>   
>   1.1                  apr/atomic/netware/apr_atomic.c
>   
>   Index: apr_atomic.c
>  
> ===================================================================
>   /* 
> ====================================================================
>    * The Apache Software License, Version 1.1
>    *
>    * Copyright (c) 2000-2002 The Apache Software Foundation.  
> All rights
>    * reserved.
>    *
>    * Redistribution and use in source and binary forms, with 
> or without
>    * modification, are permitted provided that the following 
> conditions
>    * are met:
>    *
>    * 1. Redistributions of source code must retain the above
> copyright 
>    *    notice, this list of conditions and the following
> disclaimer. 
>    *
>    * 2. Redistributions in binary form must reproduce the 
> above copyright
>    *    notice, this list of conditions and the following 
> disclaimer in
>    *    the documentation and/or other materials provided with the
>    *    distribution.
>    *
>    * 3. The end-user documentation included with the
> redistribution, 
>    *    if any, must include the following acknowledgment:
>    *       "This product includes software developed by the
>    *        Apache Software Foundation (http://www.apache.org/)."
>    *    Alternately, this acknowledgment may appear in the 
> software itself,
>    *    if and wherever such third-party acknowledgments 
> normally appear.
>    *
>    * 4. The names "Apache" and "Apache Software Foundation" must
>    *    not be used to endorse or promote products derived from
> this 
>    *    software without prior written permission. For written
>    *    permission, please contact apache@apache.org.
>    *
>    * 5. Products derived from this software may not be called 
> "Apache",
>    *    nor may "Apache" appear in their name, without prior
> written 
>    *    permission of the Apache Software Foundation.
>    *
>    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR
> IMPLIED 
>    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
> WARRANTIES 
>    * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>    * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION
> OR 
>    * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
> INCIDENTAL, 
>    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
> NOT 
>    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
> OF 
>    * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
> CAUSED AND
>    * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
> LIABILITY,
>    * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 
> ANY WAY OUT
>    * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
> POSSIBILITY OF
>    * SUCH DAMAGE.
>    * 
> ====================================================================
>    *
>    * This software consists of voluntary contributions made by many
>    * individuals on behalf of the Apache Software Foundation. 
>  For more
>    * information on the Apache Software Foundation, please see
>    * <http://www.apache.org/>.
>    */
>   
>   
>   #include "apr.h"
>   #include "apr_lock.h"
>   #include "apr_thread_mutex.h"
>   #include "apr_atomic.h"
>   
>   #if APR_HAS_THREADS
>   
>   #if defined(APR_ATOMIC_NEED_DEFAULT)  || 
> defined(APR_ATOMIC_NEED_CAS_DEFAULT)
>   
>   #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<NUM_ATOMIC_HASH;i++) {
>           rv = apr_thread_mutex_create(&(hash_mutex[i]), 
> APR_THREAD_MUTEX_DEFAULT, p);
>           if (rv != APR_SUCCESS)
>              return rv;
>       }
>       return APR_SUCCESS;
>   }
>   #endif /* APR_ATOMIC_NEED_DEFAULT || APR_ATOMIC_NEED_CAS_DEFAULT
> */ 
>   
>   int apr_atomic_dec(apr_atomic_t *mem) 
>   {
>       atomic_inc(mem);
>       return *mem; 
>   }
>   
>   #if defined(APR_ATOMIC_NEED_CAS_DEFAULT)
>   
>   apr_uint32_t apr_atomic_cas(volatile apr_uint32_t *mem,long 
> with, long cmp)
>   {
>       apr_thread_mutex_t *lock = hash_mutex[ATOMIC_HASH(mem)];
>       long prev;
>   
>       if (apr_thread_mutex_lock(lock) == APR_SUCCESS) {
>           prev = *(long*)mem;
>           if ( prev == cmp) {
>               *(long*)mem = with;
>           }
>           apr_thread_mutex_unlock(lock);
>           return prev;
>       }
>       return *(long*)mem;
>   }
>   #endif /* APR_ATOMIC_NEED_CAS_DEFAULT */
>   
>   
>   #endif /* APR_HAS_THREADS */
>   
>   
>   
> 

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPKJn7Kt6YLws+GQnEQIPhgCdEX8fk6hJ6RmZUEBj8UwcZATh8IcAnAvH
DwsjreFipAr4nehiZqbFpXDD
=q9Ga
-----END PGP SIGNATURE-----

Mime
View raw message