David 'Digit' Turner | 6c8a2f2 | 2010-06-10 23:34:24 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef BIONIC_ATOMIC_INLINE_H |
| 18 | #define BIONIC_ATOMIC_INLINE_H |
| 19 | |
| 20 | /* |
| 21 | * Inline declarations and macros for some special-purpose atomic |
| 22 | * operations. These are intended for rare circumstances where a |
| 23 | * memory barrier needs to be issued inline rather than as a function |
| 24 | * call. |
| 25 | * |
David 'Digit' Turner | 6c8a2f2 | 2010-06-10 23:34:24 -0700 | [diff] [blame] | 26 | * Macros defined in this header: |
| 27 | * |
Serban Constantinescu | 845c778 | 2013-12-19 11:57:10 +0000 | [diff] [blame] | 28 | * void ANDROID_MEMBAR_FULL() |
David 'Digit' Turner | 6c8a2f2 | 2010-06-10 23:34:24 -0700 | [diff] [blame] | 29 | * Full memory barrier. Provides a compiler reordering barrier, and |
| 30 | * on SMP systems emits an appropriate instruction. |
| 31 | */ |
| 32 | |
| 33 | #if !defined(ANDROID_SMP) |
| 34 | # error "Must define ANDROID_SMP before including atomic-inline.h" |
| 35 | #endif |
| 36 | |
| 37 | #ifdef __cplusplus |
| 38 | extern "C" { |
| 39 | #endif |
| 40 | |
David 'Digit' Turner | e31bfae | 2011-11-15 15:47:02 +0100 | [diff] [blame] | 41 | /* Define __ATOMIC_INLINE__ to control the inlining of all atomics |
| 42 | * functions declared here. For a slight performance boost, we want |
| 43 | * all of them to be always_inline |
David 'Digit' Turner | 6c8a2f2 | 2010-06-10 23:34:24 -0700 | [diff] [blame] | 44 | */ |
David 'Digit' Turner | e31bfae | 2011-11-15 15:47:02 +0100 | [diff] [blame] | 45 | #define __ATOMIC_INLINE__ static __inline__ __attribute__((always_inline)) |
David 'Digit' Turner | 6c8a2f2 | 2010-06-10 23:34:24 -0700 | [diff] [blame] | 46 | |
Colin Cross | d1973ca | 2014-01-21 19:50:58 -0800 | [diff] [blame] | 47 | #if defined(__arm__) |
Elliott Hughes | 52d6233 | 2012-07-27 17:40:29 -0700 | [diff] [blame] | 48 | # include "bionic_atomic_arm.h" |
Colin Cross | d1973ca | 2014-01-21 19:50:58 -0800 | [diff] [blame] | 49 | #elif defined(__aarch64__) |
| 50 | # include "bionic_atomic_arm64.h" |
David 'Digit' Turner | e31bfae | 2011-11-15 15:47:02 +0100 | [diff] [blame] | 51 | #elif defined(__i386__) |
Elliott Hughes | 52d6233 | 2012-07-27 17:40:29 -0700 | [diff] [blame] | 52 | # include "bionic_atomic_x86.h" |
Raghu Gandham | f7fb9e1 | 2012-06-29 15:52:55 -0700 | [diff] [blame] | 53 | #elif defined(__mips__) |
Elliott Hughes | 52d6233 | 2012-07-27 17:40:29 -0700 | [diff] [blame] | 54 | # include "bionic_atomic_mips.h" |
David 'Digit' Turner | 6c8a2f2 | 2010-06-10 23:34:24 -0700 | [diff] [blame] | 55 | #else |
Elliott Hughes | 52d6233 | 2012-07-27 17:40:29 -0700 | [diff] [blame] | 56 | # include "bionic_atomic_gcc_builtin.h" |
David 'Digit' Turner | 6c8a2f2 | 2010-06-10 23:34:24 -0700 | [diff] [blame] | 57 | #endif |
| 58 | |
David 'Digit' Turner | e31bfae | 2011-11-15 15:47:02 +0100 | [diff] [blame] | 59 | #define ANDROID_MEMBAR_FULL __bionic_memory_barrier |
David 'Digit' Turner | 6c8a2f2 | 2010-06-10 23:34:24 -0700 | [diff] [blame] | 60 | |
| 61 | #ifdef __cplusplus |
| 62 | } // extern "C" |
| 63 | #endif |
| 64 | |
| 65 | #endif // BIONIC_ATOMIC_INLINE_H |