00001 /* 00002 * Copyright (c) 2004 Hewlett-Packard Development Company, L.P. 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy 00005 * of this software and associated documentation files (the "Software"), to deal 00006 * in the Software without restriction, including without limitation the rights 00007 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 * copies of the Software, and to permit persons to whom the Software is 00009 * furnished to do so, subject to the following conditions: 00010 * 00011 * The above copyright notice and this permission notice shall be included in 00012 * all copies or substantial portions of the Software. 00013 * 00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 00020 * SOFTWARE. 00021 */ 00022 00023 /* 00024 * Describes architectures on which volatile AO_t, unsigned char, unsigned 00025 * short, and unsigned int loads and stores have acquire/release semantics for 00026 * all normally legal alignments. 00027 */ 00028 //#include "acquire_release_volatile.h" 00029 //#include "char_acquire_release_volatile.h" 00030 //#include "short_acquire_release_volatile.h" 00031 //#include "int_acquire_release_volatile.h" 00032 00033 /* 00034 * This file adds definitions appropriate for environments in which an AO_t 00035 * volatile load has acquire semantics, and an AO_t volatile store has release 00036 * semantics. This is arguably supposed to be true with the standard Itanium 00037 * software conventions. 00038 */ 00039 00040 /* 00041 * Empirically gcc/ia64 does some reordering of ordinary operations around volatiles 00042 * even when we think it shouldn't. Gcc 3.3 and earlier could reorder a volatile store 00043 * with another store. As of March 2005, gcc pre-4 reused previously computed 00044 * common subexpressions across a volatile load. 00045 * Hence we now add compiler barriers for gcc. 00046 */ 00047 #if !defined(AO_GCC_BARRIER) 00048 # if defined(__GNUC__) 00049 # define AO_GCC_BARRIER() AO_compiler_barrier() 00050 # else 00051 # define AO_GCC_BARRIER() 00052 # endif 00053 #endif 00054 00055 AO_INLINE AO_t 00056 AO_load_acquire(const volatile AO_t *p) 00057 { 00058 AO_t result = *p; 00059 /* A normal volatile load generates an ld.acq */ 00060 AO_GCC_BARRIER(); 00061 return result; 00062 } 00063 #define AO_HAVE_load_acquire 00064 00065 AO_INLINE void 00066 AO_store_release(volatile AO_t *p, AO_t val) 00067 { 00068 AO_GCC_BARRIER(); 00069 /* A normal volatile store generates an st.rel */ 00070 *p = val; 00071 } 00072 #define AO_HAVE_store_release 00073 00074 /* 00075 * This file adds definitions appropriate for environments in which an unsigned char 00076 * volatile load has acquire semantics, and an unsigned char volatile store has release 00077 * semantics. This is true with the standard Itanium ABI. 00078 */ 00079 #if !defined(AO_GCC_BARRIER) 00080 # if defined(__GNUC__) 00081 # define AO_GCC_BARRIER() AO_compiler_barrier() 00082 # else 00083 # define AO_GCC_BARRIER() 00084 # endif 00085 #endif 00086 00087 AO_INLINE unsigned char 00088 AO_char_load_acquire(const volatile unsigned char *p) 00089 { 00090 unsigned char result = *p; 00091 /* A normal volatile load generates an ld.acq */ 00092 AO_GCC_BARRIER(); 00093 return result; 00094 } 00095 #define AO_HAVE_char_load_acquire 00096 00097 AO_INLINE void 00098 AO_char_store_release(volatile unsigned char *p, unsigned char val) 00099 { 00100 AO_GCC_BARRIER(); 00101 /* A normal volatile store generates an st.rel */ 00102 *p = val; 00103 } 00104 #define AO_HAVE_char_store_release 00105 00106 /* 00107 * This file adds definitions appropriate for environments in which an unsigned short 00108 * volatile load has acquire semantics, and an unsigned short volatile store has release 00109 * semantics. This is true with the standard Itanium ABI. 00110 */ 00111 #if !defined(AO_GCC_BARRIER) 00112 # if defined(__GNUC__) 00113 # define AO_GCC_BARRIER() AO_compiler_barrier() 00114 # else 00115 # define AO_GCC_BARRIER() 00116 # endif 00117 #endif 00118 00119 AO_INLINE unsigned short 00120 AO_short_load_acquire(const volatile unsigned short *p) 00121 { 00122 unsigned short result = *p; 00123 /* A normal volatile load generates an ld.acq */ 00124 AO_GCC_BARRIER(); 00125 return result; 00126 } 00127 #define AO_HAVE_short_load_acquire 00128 00129 AO_INLINE void 00130 AO_short_store_release(volatile unsigned short *p, unsigned short val) 00131 { 00132 AO_GCC_BARRIER(); 00133 /* A normal volatile store generates an st.rel */ 00134 *p = val; 00135 } 00136 #define AO_HAVE_short_store_release 00137 00138 /* 00139 * This file adds definitions appropriate for environments in which an unsigned 00140 * int volatile load has acquire semantics, and an unsigned short volatile 00141 * store has release semantics. This is true with the standard Itanium ABI. 00142 */ 00143 #if !defined(AO_GCC_BARRIER) 00144 # if defined(__GNUC__) 00145 # define AO_GCC_BARRIER() AO_compiler_barrier() 00146 # else 00147 # define AO_GCC_BARRIER() 00148 # endif 00149 #endif 00150 00151 AO_INLINE unsigned int 00152 AO_int_load_acquire(const volatile unsigned int *p) 00153 { 00154 unsigned int result = *p; 00155 /* A normal volatile load generates an ld.acq */ 00156 AO_GCC_BARRIER(); 00157 return result; 00158 } 00159 #define AO_HAVE_int_load_acquire 00160 00161 AO_INLINE void 00162 AO_int_store_release(volatile unsigned int *p, unsigned int val) 00163 { 00164 AO_GCC_BARRIER(); 00165 /* A normal volatile store generates an st.rel */ 00166 *p = val; 00167 } 00168 #define AO_HAVE_int_store_release