PAPI 7.1.0.0
Loading...
Searching...
No Matches
char_acquire_release_volatile.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003-2004 Hewlett-Packard Development Company, L.P.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23/* This file adds definitions appropriate for environments in which */
24/* volatile load of a given type has acquire semantics, and volatile */
25/* store of a given type has release semantics. This is arguably */
26/* supposed to be true with the standard Itanium software conventions. */
27/* Empirically gcc/ia64 does some reordering of ordinary operations */
28/* around volatiles even when we think it should not. GCC v3.3 and */
29/* earlier could reorder a volatile store with another store. As of */
30/* March 2005, gcc pre-4 reuses some previously computed common */
31/* subexpressions across a volatile load; hence, we now add compiler */
32/* barriers for gcc. */
33
34#ifndef AO_HAVE_GCC_BARRIER
35 /* TODO: Check GCC version (if workaround not needed for modern GCC). */
36# if defined(__GNUC__)
37# define AO_GCC_BARRIER() AO_compiler_barrier()
38# else
39# define AO_GCC_BARRIER() (void)0
40# endif
41# define AO_HAVE_GCC_BARRIER
42#endif
43
44AO_INLINE unsignedchar
45AO_char_load_acquire(const volatile unsignedchar *addr)
46{
47 unsignedchar result = *addr;
48
49 /* A normal volatile load generates an ld.acq (on IA-64). */
51 return result;
52}
53#define AO_HAVE_char_load_acquire
54
55AO_INLINE void
56AO_char_store_release(volatile unsignedchar *addr, unsignedchar new_val)
57{
59 /* A normal volatile store generates an st.rel (on IA-64). */
60 *addr = new_val;
61}
62#define AO_HAVE_char_store_release
volatile int result
#define AO_INLINE
Definition: atomic_ops.h:186
AO_INLINE void AO_char_store_release(volatile unsignedchar *addr, unsignedchar new_val)
#define AO_GCC_BARRIER()
AO_INLINE unsigned char AO_char_load_acquire(const volatile unsignedchar *addr)