00001 /* ///////////////////////////////////////////////////////////////////////// 00002 * File: unixstl/synch/atomic_types.h 00003 * 00004 * Purpose: UNIXSTL atomic functions. 00005 * 00006 * Created: 23rd October 1997 00007 * Updated: 29th April 2010 00008 * 00009 * Thanks: To Brad Cox, for helping out in testing and fixing the 00010 * implementation for MAC OSX (Intel). 00011 * 00012 * Home: http://stlsoft.org/ 00013 * 00014 * Copyright (c) 1997-2010, Matthew Wilson and Synesis Software 00015 * All rights reserved. 00016 * 00017 * Redistribution and use in source and binary forms, with or without 00018 * modification, are permitted provided that the following conditions are met: 00019 * 00020 * - Redistributions of source code must retain the above copyright notice, this 00021 * list of conditions and the following disclaimer. 00022 * - Redistributions in binary form must reproduce the above copyright notice, 00023 * this list of conditions and the following disclaimer in the documentation 00024 * and/or other materials provided with the distribution. 00025 * - Neither the name(s) of Matthew Wilson and Synesis Software nor the names of 00026 * any contributors may be used to endorse or promote products derived from 00027 * this software without specific prior written permission. 00028 * 00029 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00030 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00031 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00032 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 00033 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 00034 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 00035 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00036 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00037 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 00038 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00039 * POSSIBILITY OF SUCH DAMAGE. 00040 * 00041 * ////////////////////////////////////////////////////////////////////// */ 00042 00043 00050 #ifndef UNIXSTL_INCL_UNIXSTL_SYNCH_H_ATOMIC_TYPES 00051 #define UNIXSTL_INCL_UNIXSTL_SYNCH_H_ATOMIC_TYPES 00052 00053 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION 00054 # define UNIXSTL_VER_UNIXSTL_SYNCH_H_ATOMIC_TYPES_MAJOR 7 00055 # define UNIXSTL_VER_UNIXSTL_SYNCH_H_ATOMIC_TYPES_MINOR 0 00056 # define UNIXSTL_VER_UNIXSTL_SYNCH_H_ATOMIC_TYPES_REVISION 1 00057 # define UNIXSTL_VER_UNIXSTL_SYNCH_H_ATOMIC_TYPES_EDIT 201 00058 #endif /* !STLSOFT_DOCUMENTATION_SKIP_SECTION */ 00059 00060 /* ///////////////////////////////////////////////////////////////////////// 00061 * Includes 00062 */ 00063 00064 #ifndef UNIXSTL_INCL_UNIXSTL_H_UNIXSTL 00065 # include <unixstl/unixstl.h> 00066 #endif /* !UNIXSTL_INCL_UNIXSTL_H_UNIXSTL */ 00067 #ifndef UNIXSTL_INCL_UNIXSTL_SYNCH_UTIL_H_FEATURES 00068 # include <unixstl/synch/util/features.h> 00069 #endif /* !UNIXSTL_INCL_UNIXSTL_SYNCH_UTIL_H_FEATURES */ 00070 00071 #if defined(UNIXSTL_FORCE_ATOMIC_INTEGER_OPERATIONS) 00072 /* Nothing to include here; UNIXSTL_FORCED_ATOMIC_INTEGER_IMPLEMENTATIONS will be included inside unixstl namespace */ 00073 #elif defined(UNIXSTL_ATOMIC_INTEGER_OPERATIONS_VIA_GCC_BUILTINS) 00074 /* Nothing to include, since using built-ins */ 00075 #elif defined(UNIXSTL_ATOMIC_INTEGER_OPERATIONS_VIA_MACOSX) 00076 # include <libkern/OSAtomic.h> 00077 #elif defined(UNIXSTL_ATOMIC_INTEGER_OPERATIONS_VIA_WINDOWS_INTERLOCKED) 00078 # include <windows.h> 00079 #else 00080 # error Atomic integer operations not supported: see unixstl/synch/util/features.h for details 00081 #endif /* ? */ 00082 00083 /* ///////////////////////////////////////////////////////////////////////// 00084 * Namespace 00085 */ 00086 00087 #ifndef _UNIXSTL_NO_NAMESPACE 00088 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00089 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00090 /* There is no stlsoft namespace, so must define ::unixstl */ 00091 namespace unixstl 00092 { 00093 # else 00094 /* Define stlsoft::unixstl_project */ 00095 00096 namespace stlsoft 00097 { 00098 00099 namespace unixstl_project 00100 { 00101 00102 # endif /* _STLSOFT_NO_NAMESPACE */ 00103 #endif /* !_UNIXSTL_NO_NAMESPACE */ 00104 00105 /* ///////////////////////////////////////////////////////////////////////// 00106 * Typedefs 00107 */ 00108 00109 #if defined(UNIXSTL_FORCE_ATOMIC_INTEGER_OPERATIONS) 00110 # ifndef UNIXSTL_FORCED_ATOMIC_INT_T 00111 # error If you are forcing atomic integer support (by defining UNIXSTL_FORCE_ATOMIC_INTEGER_OPERATIONS) you must also define UNIXSTL_FORCED_ATOMIC_INT_T 00112 # endif /* UNIXSTL_FORCED_ATOMIC_INT_T */ 00113 typedef UNIXSTL_FORCED_ATOMIC_INT_T atomic_int_t; 00114 #elif defined(UNIXSTL_ATOMIC_INTEGER_OPERATIONS_VIA_GCC_BUILTINS) 00115 typedef volatile int atomic_int_t; 00116 # elif defined(UNIXSTL_ATOMIC_INTEGER_OPERATIONS_VIA_WINDOWS_INTERLOCKED) 00117 typedef us_sint32_t atomic_int_t; 00118 # elif defined(UNIXSTL_ATOMIC_INTEGER_OPERATIONS_VIA_MACOSX) 00119 typedef STLSOFT_NS_GLOBAL(int32_t) atomic_int_t; 00120 #else 00121 # error Atomic integer operations not supported: see unixstl/synch/util/features.h for details 00122 #endif 00123 00124 /* ////////////////////////////////////////////////////////////////////// */ 00125 00126 #ifndef _UNIXSTL_NO_NAMESPACE 00127 # if defined(_STLSOFT_NO_NAMESPACE) || \ 00128 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION) 00129 } /* namespace unixstl */ 00130 # else 00131 } /* namespace unixstl_project */ 00132 } /* namespace stlsoft */ 00133 # endif /* _STLSOFT_NO_NAMESPACE */ 00134 #endif /* !_UNIXSTL_NO_NAMESPACE */ 00135 00136 /* ////////////////////////////////////////////////////////////////////// */ 00137 00138 #endif /* !UNIXSTL_INCL_UNIXSTL_SYNCH_H_ATOMIC_FUNCTIONS */ 00139 00140 /* ///////////////////////////// end of file //////////////////////////// */