gregames 02/03/22 10:04:47
Modified: include apr_atomic.h Added: atomic/os390 atomic.c Log: add apr atomic support for OS/390 Revision Changes Path 1.1 apr/atomic/os390/atomic.c Index: 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 [EMAIL PROTECTED] * * 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_atomic.h" #if APR_HAS_THREADS apr_atomic_t apr_atomic_add(apr_atomic_t *mem, apr_uint32_t val) { apr_atomic_t old, new_val; old = *mem; /* old is automatically updated on cs failure */ do { new_val = old + val; } while (__cs(&old, mem, new_val)); return new_val; } apr_uint32_t apr_atomic_cas(apr_atomic_t *mem, apr_uint32_t swap, apr_uint32_t cmp) { apr_uint32_t old = cmp; __cs(&old, mem, swap); return old; /* old is automatically updated from mem on cs failure */ } #endif /* APR_HAS_THREADS */ 1.19 +24 -0 apr/include/apr_atomic.h Index: apr_atomic.h =================================================================== RCS file: /home/cvs/apr/include/apr_atomic.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- apr_atomic.h 18 Mar 2002 15:42:56 -0000 1.18 +++ apr_atomic.h 22 Mar 2002 18:04:47 -0000 1.19 @@ -214,6 +214,30 @@ apr_uint32_t apr_atomic_sub_sparc(volatile apr_atomic_t *mem, apr_uint32_t sub); apr_uint32_t apr_atomic_cas_sparc(volatile apr_uint32_t *mem, long with, long cmp); +#elif defined(__MVS__) /* OS/390 */ +#include <stdlib.h> +#define apr_atomic_t cs_t + +apr_int32_t apr_atomic_add(volatile apr_atomic_t *mem, apr_int32_t val); +apr_uint32_t apr_atomic_cas(volatile apr_atomic_t *mem, apr_uint32_t swap, + apr_uint32_t cmp); + +#define apr_atomic_inc(mem) apr_atomic_add(mem, 1) +#define apr_atomic_dec(mem) apr_atomic_add(mem, -1) +#define apr_atomic_init(pool) APR_SUCCESS + +/* warning: the following two operations, _read and _set, are atomic + * if the memory variables are aligned (the usual case). + * + * If you try really hard and manage to mis-align them, they are not + * guaranteed to be atomic on S/390. But then your program will blow up + * with SIGBUS on a sparc, or with a S0C6 abend if you use the mis-aligned + * variables with other apr_atomic_* operations on OS/390. + */ + +#define apr_atomic_read(p) *p +#define apr_atomic_set(mem, val) *mem= val + #else #if APR_HAS_THREADS #define APR_ATOMIC_NEED_DEFAULT 1
