Cleanup: remove trailing whitespaces at EOL
[urcu.git] / urcu / uatomic / sparc64.h
1 #ifndef _URCU_ARCH_UATOMIC_SPARC64_H
2 #define _URCU_ARCH_UATOMIC_SPARC64_H
3
4 /*
5 * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
6 * Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
7 * Copyright (c) 1999-2003 by Hewlett-Packard Company. All rights reserved.
8 * Copyright (c) 2009 Mathieu Desnoyers
9 *
10 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
11 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
12 *
13 * Permission is hereby granted to use or copy this program
14 * for any purpose, provided the above notices are retained on all copies.
15 * Permission to modify the code and to distribute modified code is granted,
16 * provided the above notices are retained, and a notice that the code was
17 * modified is included with the above copyright notice.
18 *
19 * Code inspired from libuatomic_ops-1.2, inherited in part from the
20 * Boehm-Demers-Weiser conservative garbage collector.
21 */
22
23 #include <urcu/compiler.h>
24 #include <urcu/system.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /* cmpxchg */
31
32 static inline __attribute__((always_inline))
33 unsigned long _uatomic_cmpxchg(void *addr, unsigned long old,
34 unsigned long _new, int len)
35 {
36 switch (len) {
37 case 4:
38 {
39 __asm__ __volatile__ (
40 "membar #StoreLoad | #LoadLoad\n\t"
41 "cas [%1],%2,%0\n\t"
42 "membar #StoreLoad | #StoreStore\n\t"
43 : "+&r" (_new)
44 : "r" (addr), "r" (old)
45 : "memory");
46
47 return _new;
48 }
49 #if (CAA_BITS_PER_LONG == 64)
50 case 8:
51 {
52 __asm__ __volatile__ (
53 "membar #StoreLoad | #LoadLoad\n\t"
54 "casx [%1],%2,%0\n\t"
55 "membar #StoreLoad | #StoreStore\n\t"
56 : "+&r" (_new)
57 : "r" (addr), "r" (old)
58 : "memory");
59
60 return _new;
61 }
62 #endif
63 }
64 __builtin_trap();
65 return 0;
66 }
67
68
69 #define uatomic_cmpxchg(addr, old, _new) \
70 ((__typeof__(*(addr))) _uatomic_cmpxchg((addr), \
71 caa_cast_long_keep_sign(old), \
72 caa_cast_long_keep_sign(_new), \
73 sizeof(*(addr))))
74
75 #ifdef __cplusplus
76 }
77 #endif
78
79 #include <urcu/uatomic/generic.h>
80
81 #endif /* _URCU_ARCH_UATOMIC_PPC_H */
This page took 0.040332 seconds and 4 git commands to generate.