Andy McFadden | ac322da | 2010-05-19 22:33:28 -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 ANDROID_CUTILS_ATOMIC_INLINE_H |
| 18 | #define ANDROID_CUTILS_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 | * |
| 26 | * Most code should not use these. |
| 27 | * |
| 28 | * Anything that does include this file must set ANDROID_SMP to either |
| 29 | * 0 or 1, indicating compilation for UP or SMP, respectively. |
Andy McFadden | 8dfa47d | 2010-05-27 10:10:18 -0700 | [diff] [blame] | 30 | * |
| 31 | * Macros defined in this header: |
| 32 | * |
| 33 | * void ANDROID_MEMBAR_FULL(void) |
| 34 | * Full memory barrier. Provides a compiler reordering barrier, and |
| 35 | * on SMP systems emits an appropriate instruction. |
Andy McFadden | ac322da | 2010-05-19 22:33:28 -0700 | [diff] [blame] | 36 | */ |
| 37 | |
| 38 | #if !defined(ANDROID_SMP) |
| 39 | # error "Must define ANDROID_SMP before including atomic-inline.h" |
| 40 | #endif |
| 41 | |
Carl Shapiro | 93b0cb4 | 2010-06-03 17:05:15 -0700 | [diff] [blame] | 42 | #if defined(__arm__) |
| 43 | #include <cutils/atomic-arm.h> |
Andy McFadden | ac322da | 2010-05-19 22:33:28 -0700 | [diff] [blame] | 44 | #elif defined(__i386__) || defined(__x86_64__) |
Carl Shapiro | 93b0cb4 | 2010-06-03 17:05:15 -0700 | [diff] [blame] | 45 | #include <cutils/atomic-x86.h> |
| 46 | #elif defined(__sh__) |
| 47 | /* implementation is in atomic-android-sh.c */ |
Andy McFadden | ac322da | 2010-05-19 22:33:28 -0700 | [diff] [blame] | 48 | #else |
Carl Shapiro | 93b0cb4 | 2010-06-03 17:05:15 -0700 | [diff] [blame] | 49 | #error atomic operations are unsupported |
Andy McFadden | ac322da | 2010-05-19 22:33:28 -0700 | [diff] [blame] | 50 | #endif |
| 51 | |
Carl Shapiro | 93b0cb4 | 2010-06-03 17:05:15 -0700 | [diff] [blame] | 52 | #if ANDROID_SMP == 0 |
| 53 | #define ANDROID_MEMBAR_FULL android_compiler_barrier |
Andy McFadden | ac322da | 2010-05-19 22:33:28 -0700 | [diff] [blame] | 54 | #else |
Carl Shapiro | 93b0cb4 | 2010-06-03 17:05:15 -0700 | [diff] [blame] | 55 | #define ANDROID_MEMBAR_FULL android_memory_barrier |
Andy McFadden | ac322da | 2010-05-19 22:33:28 -0700 | [diff] [blame] | 56 | #endif |
| 57 | |
Brian Carlstrom | 464431e | 2010-09-24 10:56:43 -0700 | [diff] [blame^] | 58 | #if ANDROID_SMP == 0 |
| 59 | #define ANDROID_MEMBAR_STORE android_compiler_barrier |
| 60 | #else |
| 61 | #define ANDROID_MEMBAR_STORE android_memory_store_barrier |
| 62 | #endif |
| 63 | |
Carl Shapiro | 93b0cb4 | 2010-06-03 17:05:15 -0700 | [diff] [blame] | 64 | #endif /* ANDROID_CUTILS_ATOMIC_INLINE_H */ |