2
* Copyright (c) 2003 by Hewlett-Packard Company. All rights reserved.
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:
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
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
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
* id appropriate, and if AO_FORCE_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.
38
#if !defined(ATOMIC_OPS_H)
39
# error This file should not be included directly.
42
#ifndef AO_HAVE_double_t
43
# include "standard_ao_double_t.h"
46
int AO_compare_and_swap_emulation(volatile AO_t *addr, AO_t old,
49
int AO_compare_double_and_swap_double_emulation(volatile AO_double_t *addr,
50
AO_t old_val1, AO_t old_val2,
51
AO_t new_val1, AO_t new_val2);
53
void AO_store_full_emulation(volatile AO_t *addr, AO_t val);
55
#define AO_compare_and_swap_full(addr, old, newval) \
56
AO_compare_and_swap_emulation(addr, old, newval)
57
#define AO_HAVE_compare_and_swap_full
59
#ifndef AO_HAVE_compare_double_and_swap_double
60
# define AO_compare_double_and_swap_double_full(addr, old1, old2, \
62
AO_compare_double_and_swap_double_emulation(addr, old1, old2, \
64
# define AO_HAVE_compare_double_and_swap_double_full
70
#undef AO_HAVE_store_write
71
#undef AO_store_release
72
#undef AO_HAVE_store_release
74
#undef AO_HAVE_store_full
75
#define AO_store_full(addr, val) AO_store_full_emulation(addr, val)
76
#define AO_HAVE_store_full