1 /* src/vm/jit/powerpc/md-atomic.hpp - PowerPC 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 static uint32_t Atomic_compare_and_swap_32(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
50 __asm__ __volatile__ ("\n\
59 : "=&r"(result), "=&r"(temp)
60 : "r"(oldval), "r"(newval), "r"(p)
68 * An atomic compare and swap for 64-bit integer values.
70 * @param p Pointer to memory address.
71 * @param oldval Old value to be expected.
72 * @param newval New value to be stored.
74 * @return value of the memory location before the store
76 inline static uint64_t Atomic_compare_and_swap_64(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
78 #warning Use generic implementation.
84 * An atomic compare and swap for pointer values.
86 * @param p Pointer to memory address.
87 * @param oldval Old value to be expected.
88 * @param newval New value to be stored.
90 * @return value of the memory location before the store
92 inline static void* Atomic_compare_and_swap_ptr(volatile void** p, void* oldval, void* newval)
94 return (void*) Atomic_compare_and_swap_32((volatile uint32_t*) p, (uint32_t) oldval, (uint32_t) newval);
101 inline static void Atomic_memory_barrier(void)
103 __asm__ __volatile__ ("sync" : : : "memory");
107 #define STORE_ORDER_BARRIER() __asm__ __volatile__ ("" : : : "memory");
108 #define MEMORY_BARRIER_AFTER_ATOMIC() __asm__ __volatile__ ("isync" : : : "memory");
110 #endif // _MD_ATOMIC_HPP
114 * These are local overrides for various environment variables in Emacs.
115 * Please do not remove this and leave it at the end of the file, where
116 * Emacs will automagically detect them.
117 * ---------------------------------------------------------------------
120 * indent-tabs-mode: t
124 * vim:noexpandtab:sw=4:ts=4: