1 /* src/vm/jit/s390/md-atomic.hpp - s390 atomic instructions
3 Copyright (C) 2008, 2010
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"
38 * An atomic compare and swap for 32-bit integer values.
40 * @param p Pointer to memory address.
41 * @param oldval Old value to be expected.
42 * @param newval New value to be stored.
44 * @return value of the memory location before the store
46 inline uint32_t compare_and_swap(volatile uint32_t *p, uint32_t oldval, uint32_t newval)
48 __asm__ __volatile__ (
50 : "+d" (oldval), "=m" (*p)
51 : "a" (p), "d" (newval), "m" (*p)
59 * An atomic compare and swap for 64-bit integer values.
61 * @param p Pointer to memory address.
62 * @param oldval Old value to be expected.
63 * @param newval New value to be stored.
65 * @return value of the memory location before the store
67 inline uint64_t compare_and_swap(volatile uint64_t *p, uint64_t oldval, uint64_t newval)
69 return Atomic::generic_compare_and_swap(p, oldval, newval);
76 inline void memory_barrier(void)
78 __asm__ __volatile__ ("bcr 15,0" : : : "memory" );
83 * A write memory barrier.
85 inline void write_memory_barrier(void)
91 * An instruction barrier.
93 inline void instruction_barrier(void)
95 __asm__ __volatile__ ("" : : : "memory" );
100 #endif // _MD_ATOMIC_HPP
104 * These are local overrides for various environment variables in Emacs.
105 * Please do not remove this and leave it at the end of the file, where
106 * Emacs will automagically detect them.
107 * ---------------------------------------------------------------------
110 * indent-tabs-mode: t
114 * vim:noexpandtab:sw=4:ts=4: