1 /* src/vm/jit/sparc64/atomic.hpp - SPARC64 atomic instructions
4 CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
6 This file is part of CACAO.
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2, or (at
11 your option) any later version.
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 #ifndef _MD_ATOMIC_HPP
27 #define _MD_ATOMIC_HPP
33 #include "threads/atomic.hpp"
37 * An atomic compare and swap for 32-bit integer values.
39 * @param p Pointer to memory address.
40 * @param oldval Old value to be expected.
41 * @param newval New value to be stored.
43 * @return value of the memory location before the store
45 inline uint32_t Atomic::compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
48 // This one should be correct.
51 __asm__ __volatile__ (
54 : "=&r" (result), "=m" (*p)
55 : "r" (oldval), "r" (newval), "r" (p));
59 return generic_compare_and_swap(p, oldval, newval);
65 * An atomic compare and swap for 64-bit integer values.
67 * @param p Pointer to memory address.
68 * @param oldval Old value to be expected.
69 * @param newval New value to be stored.
71 * @return value of the memory location before the store
73 inline uint64_t Atomic::compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
77 __asm__ __volatile__ (
80 : "=&r" (result), "=m" (*p)
81 : "r" (oldval), "r" (newval), "r" (p));
88 * An atomic compare and swap for pointer values.
90 * @param p Pointer to memory address.
91 * @param oldval Old value to be expected.
92 * @param newval New value to be stored.
94 * @return value of the memory location before the store
96 inline void* Atomic::compare_and_swap(volatile void** p, void* oldval, void* newval)
98 return (void*) compare_and_swap((volatile uint64_t*) p, (uint64_t) oldval, (uint64_t) newval);
105 inline void Atomic::memory_barrier(void)
107 __asm__ __volatile__ ("membar 0x0F" : : : "memory" );
112 * A write memory barrier.
114 inline void Atomic::write_memory_barrier(void)
116 __asm__ __volatile__ ("wmb" : : : "memory");
121 * An instruction barrier.
123 inline void Atomic::instruction_barrier(void)
125 __asm__ __volatile__ ("mb" : : : "memory");
128 #endif // _MD_ATOMIC_HPP
132 * These are local overrides for various environment variables in Emacs.
133 * Please do not remove this and leave it at the end of the file, where
134 * Emacs will automagically detect them.
135 * ---------------------------------------------------------------------
138 * indent-tabs-mode: t
142 * vim:noexpandtab:sw=4:ts=4: