2128N/A * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. 2128N/A * Copyright 2007, 2008, 2011 Red Hat, Inc. 1010N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1010N/A * This code is free software; you can redistribute it and/or modify it 1010N/A * under the terms of the GNU General Public License version 2 only, as 1010N/A * published by the Free Software Foundation. 1010N/A * This code is distributed in the hope that it will be useful, but WITHOUT 1010N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1010N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1010N/A * version 2 for more details (a copy is included in the LICENSE file that 1010N/A * You should have received a copy of the GNU General Public License version 1010N/A * 2 along with this work; if not, write to the Free Software Foundation, 1010N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1010N/A// Implementation of class atomic 1010N/A * Atomically store newval in *ptr if *ptr is equal to oldval for user space. 1010N/A * Returns newval on success and oldval if no exchange happened. 1010N/A * This implementation is processor specific and works on 1010N/A * 68020 68030 68040 and 68060. 1010N/A * It will not work on ColdFire, 68000 and 68010 since they lack the CAS 1010N/A * Using a kernelhelper would be better for arch complete implementation. 1010N/A/* Perform an atomic compare and swap: if the current value of `*PTR' 1010N/A is OLDVAL, then write NEWVAL into `*PTR'. Return the contents of 1010N/A `*PTR' before the operation.*/ 1010N/A // We failed even though prev == oldval. Try again. 1010N/A/* Atomically add an int to memory. */ 1010N/A/* Atomically write VALUE into `*PTR' and returns the previous 1010N/A * Atomically store newval in *ptr if *ptr is equal to oldval for user space. 1010N/A * Return zero if *ptr was changed or non-zero if no exchange happened. 1010N/A * The C flag is also set if *ptr was changed to allow for assembly 1010N/A * optimization in the calling code. 1010N/A/* Perform an atomic compare and swap: if the current value of `*PTR' 1010N/A is OLDVAL, then write NEWVAL into `*PTR'. Return the contents of 1010N/A `*PTR' before the operation.*/ 1010N/A // We failed even though prev == oldval. Try again. 1010N/A/* Atomically add an int to memory. */ 1010N/A // Loop until a __kernel_cmpxchg succeeds. 1010N/A/* Atomically write VALUE into `*PTR' and returns the previous 1010N/A // Loop until a __kernel_cmpxchg succeeds. 1010N/A // __sync_lock_test_and_set is a bizarrely named atomic exchange 1010N/A // operation. Note that some platforms only support this with the 1010N/A // limitation that the only valid value to store is the immediate 1010N/A // constant 1. There is a test for this in JNI_CreateJavaVM(). 1879N/A#
endif // OS_CPU_LINUX_ZERO_VM_ATOMIC_LINUX_ZERO_INLINE_HPP