0N/A/*
1879N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1472N/A * or visit www.oracle.com if you need additional information or have any
1472N/A * questions.
0N/A *
0N/A */
0N/A
1879N/A#ifndef SHARE_VM_RUNTIME_ATOMIC_HPP
1879N/A#define SHARE_VM_RUNTIME_ATOMIC_HPP
1879N/A
1879N/A#include "memory/allocation.hpp"
1879N/A
0N/Aclass Atomic : AllStatic {
0N/A public:
4272N/A // Atomic operations on jlong types are not available on all 32-bit
4272N/A // platforms. If atomic ops on jlongs are defined here they must only
4272N/A // be used from code that verifies they are available at runtime and
4272N/A // can provide an alternative action if not - see supports_cx8() for
4272N/A // a means to test availability.
4272N/A
0N/A // Atomically store to a location
0N/A static void store (jbyte store_value, jbyte* dest);
0N/A static void store (jshort store_value, jshort* dest);
0N/A static void store (jint store_value, jint* dest);
4272N/A // See comment above about using jlong atomics on 32-bit platforms
0N/A static void store (jlong store_value, jlong* dest);
0N/A static void store_ptr(intptr_t store_value, intptr_t* dest);
0N/A static void store_ptr(void* store_value, void* dest);
0N/A
0N/A static void store (jbyte store_value, volatile jbyte* dest);
0N/A static void store (jshort store_value, volatile jshort* dest);
0N/A static void store (jint store_value, volatile jint* dest);
4272N/A // See comment above about using jlong atomics on 32-bit platforms
0N/A static void store (jlong store_value, volatile jlong* dest);
0N/A static void store_ptr(intptr_t store_value, volatile intptr_t* dest);
0N/A static void store_ptr(void* store_value, volatile void* dest);
0N/A
4272N/A // See comment above about using jlong atomics on 32-bit platforms
894N/A static jlong load(volatile jlong* src);
894N/A
0N/A // Atomically add to a location, return updated value
0N/A static jint add (jint add_value, volatile jint* dest);
0N/A static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest);
0N/A static void* add_ptr(intptr_t add_value, volatile void* dest);
4272N/A // See comment above about using jlong atomics on 32-bit platforms
2592N/A static jlong add (jlong add_value, volatile jlong* dest);
2592N/A
0N/A // Atomically increment location
0N/A static void inc (volatile jint* dest);
0N/A static void inc_ptr(volatile intptr_t* dest);
0N/A static void inc_ptr(volatile void* dest);
0N/A
0N/A // Atomically decrement a location
0N/A static void dec (volatile jint* dest);
0N/A static void dec_ptr(volatile intptr_t* dest);
0N/A static void dec_ptr(volatile void* dest);
0N/A
0N/A // Performs atomic exchange of *dest with exchange_value. Returns old prior value of *dest.
113N/A static jint xchg(jint exchange_value, volatile jint* dest);
113N/A static unsigned int xchg(unsigned int exchange_value,
113N/A volatile unsigned int* dest);
113N/A
0N/A static intptr_t xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest);
0N/A static void* xchg_ptr(void* exchange_value, volatile void* dest);
0N/A
0N/A // Performs atomic compare of *dest and compare_value, and exchanges *dest with exchange_value
0N/A // if the comparison succeeded. Returns prior value of *dest. Guarantees a two-way memory
0N/A // barrier across the cmpxchg. I.e., it's really a 'fence_cmpxchg_acquire'.
0N/A static jbyte cmpxchg (jbyte exchange_value, volatile jbyte* dest, jbyte compare_value);
0N/A static jint cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value);
4272N/A // See comment above about using jlong atomics on 32-bit platforms
0N/A static jlong cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value);
113N/A
113N/A static unsigned int cmpxchg(unsigned int exchange_value,
113N/A volatile unsigned int* dest,
113N/A unsigned int compare_value);
113N/A
0N/A static intptr_t cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value);
0N/A static void* cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value);
0N/A};
1879N/A
1879N/A#endif // SHARE_VM_RUNTIME_ATOMIC_HPP