src/os_cpu/linux_zero/vm/atomic_linux_zero.inline.hpp

Print this page


   1 /*
   2  * Copyright (c) 2003, 2005, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2007, 2008 Red Hat, Inc.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 








  26 // Implementation of class atomic
  27 
  28 #ifdef M68K
  29 
  30 /*
  31  * __m68k_cmpxchg
  32  *
  33  * Atomically store newval in *ptr if *ptr is equal to oldval for user space.
  34  * Returns newval on success and oldval if no exchange happened.
  35  * This implementation is processor specific and works on
  36  * 68020 68030 68040 and 68060.
  37  *
  38  * It will not work on ColdFire, 68000 and 68010 since they lack the CAS
  39  * instruction.
  40  * Using a kernelhelper would be better for arch complete implementation.
  41  *
  42  */
  43 
  44 static inline int __m68k_cmpxchg(int oldval, int newval, volatile int *ptr) {
  45   int ret;


 274                                     intptr_t compare_value) {
 275 #ifdef ARM
 276   return arm_compare_and_swap(dest, compare_value, exchange_value);
 277 #else
 278 #ifdef M68K
 279   return m68k_compare_and_swap(dest, compare_value, exchange_value);
 280 #else
 281   return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
 282 #endif // M68K
 283 #endif // ARM
 284 }
 285 
 286 inline void* Atomic::cmpxchg_ptr(void* exchange_value,
 287                                  volatile void* dest,
 288                                  void* compare_value) {
 289 
 290   return (void *) cmpxchg_ptr((intptr_t) exchange_value,
 291                               (volatile intptr_t*) dest,
 292                               (intptr_t) compare_value);
 293 }


   1 /*
   2  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2007, 2008 Red Hat, Inc.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #ifndef OS_CPU_LINUX_ZERO_VM_ATOMIC_LINUX_ZERO_INLINE_HPP
  27 #define OS_CPU_LINUX_ZERO_VM_ATOMIC_LINUX_ZERO_INLINE_HPP
  28 
  29 #include "orderAccess_linux_zero.inline.hpp"
  30 #include "runtime/atomic.hpp"
  31 #include "runtime/os.hpp"
  32 #include "vm_version_zero.hpp"
  33 
  34 // Implementation of class atomic
  35 
  36 #ifdef M68K
  37 
  38 /*
  39  * __m68k_cmpxchg
  40  *
  41  * Atomically store newval in *ptr if *ptr is equal to oldval for user space.
  42  * Returns newval on success and oldval if no exchange happened.
  43  * This implementation is processor specific and works on
  44  * 68020 68030 68040 and 68060.
  45  *
  46  * It will not work on ColdFire, 68000 and 68010 since they lack the CAS
  47  * instruction.
  48  * Using a kernelhelper would be better for arch complete implementation.
  49  *
  50  */
  51 
  52 static inline int __m68k_cmpxchg(int oldval, int newval, volatile int *ptr) {
  53   int ret;


 282                                     intptr_t compare_value) {
 283 #ifdef ARM
 284   return arm_compare_and_swap(dest, compare_value, exchange_value);
 285 #else
 286 #ifdef M68K
 287   return m68k_compare_and_swap(dest, compare_value, exchange_value);
 288 #else
 289   return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
 290 #endif // M68K
 291 #endif // ARM
 292 }
 293 
 294 inline void* Atomic::cmpxchg_ptr(void* exchange_value,
 295                                  volatile void* dest,
 296                                  void* compare_value) {
 297 
 298   return (void *) cmpxchg_ptr((intptr_t) exchange_value,
 299                               (volatile intptr_t*) dest,
 300                               (intptr_t) compare_value);
 301 }
 302 
 303 #endif // OS_CPU_LINUX_ZERO_VM_ATOMIC_LINUX_ZERO_INLINE_HPP