uatomic/x86: Remove redundant memory barriers
[urcu.git] / include / urcu / uatomic / sparc64.h
CommitLineData
d3d3857f
MJ
1// SPDX-FileCopyrightText: 1991-1994 by Xerox Corporation. All rights reserved.
2// SPDX-FileCopyrightText: 1996-1999 by Silicon Graphics. All rights reserved.
3// SPDX-FileCopyrightText: 1999-2003 Hewlett-Packard Development Company, L.P.
4// SPDX-FileCopyrightText: 2009 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5//
6// SPDX-License-Identifier: LicenseRef-Boehm-GC
7
58de5a4b
MD
8#ifndef _URCU_ARCH_UATOMIC_SPARC64_H
9#define _URCU_ARCH_UATOMIC_SPARC64_H
10
67ecffc0 11/*
58de5a4b
MD
12 * Code inspired from libuatomic_ops-1.2, inherited in part from the
13 * Boehm-Demers-Weiser conservative garbage collector.
14 */
15
16#include <urcu/compiler.h>
17#include <urcu/system.h>
18
36bc70a8
MD
19#ifdef __cplusplus
20extern "C" {
67ecffc0 21#endif
36bc70a8 22
58de5a4b
MD
23/* cmpxchg */
24
25static inline __attribute__((always_inline))
26unsigned long _uatomic_cmpxchg(void *addr, unsigned long old,
27 unsigned long _new, int len)
28{
29 switch (len) {
30 case 4:
31 {
32 __asm__ __volatile__ (
33 "membar #StoreLoad | #LoadLoad\n\t"
34 "cas [%1],%2,%0\n\t"
35 "membar #StoreLoad | #StoreStore\n\t"
36 : "+&r" (_new)
37 : "r" (addr), "r" (old)
38 : "memory");
39
40 return _new;
41 }
b39e1761 42#if (CAA_BITS_PER_LONG == 64)
58de5a4b
MD
43 case 8:
44 {
45 __asm__ __volatile__ (
46 "membar #StoreLoad | #LoadLoad\n\t"
47 "casx [%1],%2,%0\n\t"
48 "membar #StoreLoad | #StoreStore\n\t"
49 : "+&r" (_new)
50 : "r" (addr), "r" (old)
51 : "memory");
52
53 return _new;
54 }
55#endif
56 }
57 __builtin_trap();
58 return 0;
59}
60
61
e56d99bf
MD
62#define uatomic_cmpxchg(addr, old, _new) \
63 ((__typeof__(*(addr))) _uatomic_cmpxchg((addr), \
64 caa_cast_long_keep_sign(old), \
65 caa_cast_long_keep_sign(_new), \
58de5a4b
MD
66 sizeof(*(addr))))
67
67ecffc0 68#ifdef __cplusplus
36bc70a8
MD
69}
70#endif
71
a2e7bf9c 72#include <urcu/uatomic/generic.h>
8760d94e 73
58de5a4b 74#endif /* _URCU_ARCH_UATOMIC_PPC_H */
This page took 0.05074 seconds and 4 git commands to generate.