PAPI 7.1.0.0
Loading...
Searching...
No Matches
arm64.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2003 Hewlett-Packard Development Company, L.P.
3 * Copyright (c) 2021 Ivan Maidanski
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 * SOFTWARE.
22 */
23
24#include "../all_aligned_atomic_load_store.h"
25
26#ifndef AO_ASSUME_WINDOWS98
27# define AO_ASSUME_WINDOWS98
28#endif
29#ifndef AO_USE_INTERLOCKED_INTRINSICS
30# define AO_USE_INTERLOCKED_INTRINSICS
31#endif
32#include "common32_defs.h"
33
34#ifndef AO_HAVE_test_and_set_full
35# include "../test_and_set_t_is_ao_t.h"
36 /* AO_test_and_set_full() is emulated using word-wide CAS. */
37#endif
38
39#ifndef AO_NO_DOUBLE_CAS
40
41# include "../standard_ao_double_t.h"
42
43# pragma intrinsic (_InterlockedCompareExchange128)
44# pragma intrinsic (_InterlockedCompareExchange128_acq)
45# pragma intrinsic (_InterlockedCompareExchange128_nf)
46# pragma intrinsic (_InterlockedCompareExchange128_rel)
47
48 AO_INLINE int
50 AO_t old_val1, AO_t old_val2,
51 AO_t new_val1, AO_t new_val2)
52 {
53 __int64 comparandResult[2];
54
56 comparandResult[0] = old_val1; /* low */
57 comparandResult[1] = old_val2; /* high */
58 return _InterlockedCompareExchange128_nf((volatile __int64 *)addr,
59 new_val2 /* high */,
60 new_val1 /* low */,
61 comparandResult);
62 }
63# define AO_HAVE_compare_double_and_swap_double
64
65 AO_INLINE int
67 AO_t old_val1, AO_t old_val2,
68 AO_t new_val1, AO_t new_val2)
69 {
70 __int64 comparandResult[2];
71
73 comparandResult[0] = old_val1; /* low */
74 comparandResult[1] = old_val2; /* high */
75 return _InterlockedCompareExchange128_acq((volatile __int64 *)addr,
76 new_val2 /* high */,
77 new_val1 /* low */,
78 comparandResult);
79 }
80# define AO_HAVE_compare_double_and_swap_double_acquire
81
82 AO_INLINE int
84 AO_t old_val1, AO_t old_val2,
85 AO_t new_val1, AO_t new_val2)
86 {
87 __int64 comparandResult[2];
88
90 comparandResult[0] = old_val1; /* low */
91 comparandResult[1] = old_val2; /* high */
92 return _InterlockedCompareExchange128_rel((volatile __int64 *)addr,
93 new_val2 /* high */,
94 new_val1 /* low */,
95 comparandResult);
96 }
97# define AO_HAVE_compare_double_and_swap_double_release
98
99 AO_INLINE int
101 AO_t old_val1, AO_t old_val2,
102 AO_t new_val1, AO_t new_val2)
103 {
104 __int64 comparandResult[2];
105
107 comparandResult[0] = old_val1; /* low */
108 comparandResult[1] = old_val2; /* high */
109 return _InterlockedCompareExchange128((volatile __int64 *)addr,
110 new_val2 /* high */,
111 new_val1 /* low */,
112 comparandResult);
113 }
114# define AO_HAVE_compare_double_and_swap_double_full
115
116#endif /* !AO_NO_DOUBLE_CAS */
AO_INLINE int AO_compare_double_and_swap_double(volatile AO_double_t *addr, AO_t old_val1, AO_t old_val2, AO_t new_val1, AO_t new_val2)
Definition: arm64.h:49
AO_INLINE int AO_compare_double_and_swap_double_acquire(volatile AO_double_t *addr, AO_t old_val1, AO_t old_val2, AO_t new_val1, AO_t new_val2)
Definition: arm64.h:66
AO_INLINE int AO_compare_double_and_swap_double_release(volatile AO_double_t *addr, AO_t old_val1, AO_t old_val2, AO_t new_val1, AO_t new_val2)
Definition: arm64.h:83
#define AO_ASSERT_ADDR_ALIGNED(addr)
Definition: atomic_ops.h:266
#define AO_t
Definition: atomic_ops.h:156
#define AO_INLINE
Definition: atomic_ops.h:186
#define AO_compare_double_and_swap_double_full(addr, old1, old2, newval1, newval2)
Definition: emul_cas.h:67