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 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /* 25 * Inline declarations and macros for some special-purpose atomic 26 * operations. These are intended for rare circumstances where a 27 * memory barrier needs to be issued inline rather than as a function 28 * call. 29 * 30 * Most code should not use these. 31 * 32 * Anything that does include this file must set ANDROID_SMP to either 33 * 0 or 1, indicating compilation for UP or SMP, respectively. 34 * 35 * Macros defined in this header: 36 * 37 * void ANDROID_MEMBAR_FULL(void) 38 * Full memory barrier. Provides a compiler reordering barrier, and 39 * on SMP systems emits an appropriate instruction. 40 */ 41 42 #if !defined(ANDROID_SMP) 43 # error "Must define ANDROID_SMP before including atomic-inline.h" 44 #endif 45 46 #if defined(__arm__) 47 #include <cutils/atomic-arm.h> 48 #elif defined(__i386__) || defined(__x86_64__) 49 #include <cutils/atomic-x86.h> 50 #elif defined(__mips__) 51 #include <cutils/atomic-mips.h> 52 #else 53 #error atomic operations are unsupported 54 #endif 55 56 #if ANDROID_SMP == 0 57 #define ANDROID_MEMBAR_FULL android_compiler_barrier 58 #else 59 #define ANDROID_MEMBAR_FULL android_memory_barrier 60 #endif 61 62 #if ANDROID_SMP == 0 63 #define ANDROID_MEMBAR_STORE android_compiler_barrier 64 #else 65 #define ANDROID_MEMBAR_STORE android_memory_store_barrier 66 #endif 67 68 #ifdef __cplusplus 69 } 70 #endif 71 72 #endif /* ANDROID_CUTILS_ATOMIC_INLINE_H */ 73