Blame src/atomic_ops/sysdeps/loadstore/acquire_release_volatile.template

Packit fe9d6e
/*
Packit fe9d6e
 * Copyright (c) 2003-2004 Hewlett-Packard Development Company, L.P.
Packit fe9d6e
 *
Packit fe9d6e
 * Permission is hereby granted, free of charge, to any person obtaining a copy
Packit fe9d6e
 * of this software and associated documentation files (the "Software"), to deal
Packit fe9d6e
 * in the Software without restriction, including without limitation the rights
Packit fe9d6e
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Packit fe9d6e
 * copies of the Software, and to permit persons to whom the Software is
Packit fe9d6e
 * furnished to do so, subject to the following conditions:
Packit fe9d6e
 *
Packit fe9d6e
 * The above copyright notice and this permission notice shall be included in
Packit fe9d6e
 * all copies or substantial portions of the Software.
Packit fe9d6e
 *
Packit fe9d6e
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Packit fe9d6e
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Packit fe9d6e
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Packit fe9d6e
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Packit fe9d6e
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Packit fe9d6e
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit fe9d6e
 * SOFTWARE.
Packit fe9d6e
 */
Packit fe9d6e
Packit fe9d6e
/* This file adds definitions appropriate for environments in which     */
Packit fe9d6e
/* volatile load of a given type has acquire semantics, and volatile    */
Packit fe9d6e
/* store of a given type has release semantics.  This is arguably       */
Packit fe9d6e
/* supposed to be true with the standard Itanium software conventions.  */
Packit fe9d6e
/* Empirically gcc/ia64 does some reordering of ordinary operations     */
Packit fe9d6e
/* around volatiles even when we think it should not.  GCC v3.3 and     */
Packit fe9d6e
/* earlier could reorder a volatile store with another store.  As of    */
Packit fe9d6e
/* March 2005, gcc pre-4 reuses some previously computed common         */
Packit fe9d6e
/* subexpressions across a volatile load; hence, we now add compiler    */
Packit fe9d6e
/* barriers for gcc.                                                    */
Packit fe9d6e
Packit fe9d6e
#ifndef AO_GCC_BARRIER
Packit fe9d6e
  /* TODO: Check GCC version (if workaround not needed for modern GCC). */
Packit fe9d6e
# if defined(__GNUC__)
Packit fe9d6e
#   define AO_GCC_BARRIER() AO_compiler_barrier()
Packit fe9d6e
# else
Packit fe9d6e
#   define AO_GCC_BARRIER() (void)0
Packit fe9d6e
# endif
Packit fe9d6e
#endif
Packit fe9d6e
Packit fe9d6e
AO_INLINE XCTYPE
Packit fe9d6e
AO_XSIZE_load_acquire(const volatile XCTYPE *addr)
Packit fe9d6e
{
Packit fe9d6e
  XCTYPE result = *addr;
Packit fe9d6e
Packit fe9d6e
  /* A normal volatile load generates an ld.acq (on IA-64).     */
Packit fe9d6e
  AO_GCC_BARRIER();
Packit fe9d6e
  return result;
Packit fe9d6e
}
Packit fe9d6e
#define AO_HAVE_XSIZE_load_acquire
Packit fe9d6e
Packit fe9d6e
AO_INLINE void
Packit fe9d6e
AO_XSIZE_store_release(volatile XCTYPE *addr, XCTYPE new_val)
Packit fe9d6e
{
Packit fe9d6e
  AO_GCC_BARRIER();
Packit fe9d6e
  /* A normal volatile store generates an st.rel (on IA-64).    */
Packit fe9d6e
  *addr = new_val;
Packit fe9d6e
}
Packit fe9d6e
#define AO_HAVE_XSIZE_store_release