PAPI 7.1.0.0
Loading...
Searching...
No Matches
emul_cas.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
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/*
24 * Ensure, if at all possible, that AO_compare_and_swap_full() is
25 * available. The emulation should be brute-force signal-safe, even
26 * though it actually blocks.
27 * Including this file will generate an error if AO_compare_and_swap_full()
28 * cannot be made available.
29 * This will be included from platform-specific atomic_ops files
30 * if appropriate, and if AO_REQUIRE_CAS is defined. It should not be
31 * included directly, especially since it affects the implementation
32 * of other atomic update primitives.
33 * The implementation assumes that only AO_store_XXX and AO_test_and_set_XXX
34 * variants are defined, and that AO_test_and_set_XXX is not used to
35 * operate on compare_and_swap locations.
36 */
37
38#ifndef AO_ATOMIC_OPS_H
39# error This file should not be included directly.
40#endif
41
42#ifndef AO_HAVE_double_t
43# include "standard_ao_double_t.h"
44#endif
45
46#ifdef __cplusplus
47 extern "C" {
48#endif
49
51 AO_t old_val, AO_t new_val);
52
53AO_API int
55 AO_t old_val1, AO_t old_val2,
56 AO_t new_val1, AO_t new_val2);
57
58AO_API void AO_store_full_emulation(volatile AO_t *addr, AO_t val);
59
60#ifndef AO_HAVE_fetch_compare_and_swap_full
61# define AO_fetch_compare_and_swap_full(addr, old, newval) \
62 AO_fetch_compare_and_swap_emulation(addr, old, newval)
63# define AO_HAVE_fetch_compare_and_swap_full
64#endif
65
66#ifndef AO_HAVE_compare_double_and_swap_double_full
67# define AO_compare_double_and_swap_double_full(addr, old1, old2, \
68 newval1, newval2) \
69 AO_compare_double_and_swap_double_emulation(addr, old1, old2, \
70 newval1, newval2)
71# define AO_HAVE_compare_double_and_swap_double_full
72#endif
73
74#undef AO_store
75#undef AO_HAVE_store
76#undef AO_store_write
77#undef AO_HAVE_store_write
78#undef AO_store_release
79#undef AO_HAVE_store_release
80#undef AO_store_full
81#undef AO_HAVE_store_full
82#define AO_store_full(addr, val) AO_store_full_emulation(addr, val)
83#define AO_HAVE_store_full
84
85#ifdef __cplusplus
86 } /* extern "C" */
87#endif
#define AO_t
Definition: atomic_ops.h:156
#define AO_API
Definition: atomic_ops.h:259
AO_API void AO_store_full_emulation(volatile AO_t *addr, AO_t val)
AO_API AO_t AO_fetch_compare_and_swap_emulation(volatile AO_t *addr, AO_t old_val, AO_t new_val)
AO_API int AO_compare_double_and_swap_double_emulation(volatile AO_double_t *addr, AO_t old_val1, AO_t old_val2, AO_t new_val1, AO_t new_val2)