uatomic: Fix header guard comment
[urcu.git] / include / urcu / uatomic / sparc64.h
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
8 #ifndef _URCU_ARCH_UATOMIC_SPARC64_H
9 #define _URCU_ARCH_UATOMIC_SPARC64_H
10
11 /*
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
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 /* cmpxchg */
24
25 static inline __attribute__((always_inline))
26 unsigned 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 }
42 #if (CAA_BITS_PER_LONG == 64)
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
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), \
66 sizeof(*(addr))))
67
68 #ifdef __cplusplus
69 }
70 #endif
71
72 #include <urcu/uatomic/generic.h>
73
74 #endif /* _URCU_ARCH_UATOMIC_PPC_H */
This page took 0.037771 seconds and 5 git commands to generate.