Cleanup: remove trailing whitespaces at EOL
[urcu.git] / urcu / uatomic / sparc64.h
CommitLineData
58de5a4b
MD
1#ifndef _URCU_ARCH_UATOMIC_SPARC64_H
2#define _URCU_ARCH_UATOMIC_SPARC64_H
3
67ecffc0 4/*
58de5a4b
MD
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
36bc70a8
MD
26#ifdef __cplusplus
27extern "C" {
67ecffc0 28#endif
36bc70a8 29
58de5a4b
MD
30/* cmpxchg */
31
32static inline __attribute__((always_inline))
33unsigned 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 }
b39e1761 49#if (CAA_BITS_PER_LONG == 64)
58de5a4b
MD
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
e56d99bf
MD
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), \
58de5a4b
MD
73 sizeof(*(addr))))
74
67ecffc0 75#ifdef __cplusplus
36bc70a8
MD
76}
77#endif
78
a2e7bf9c 79#include <urcu/uatomic/generic.h>
8760d94e 80
58de5a4b 81#endif /* _URCU_ARCH_UATOMIC_PPC_H */
This page took 0.049099 seconds and 4 git commands to generate.