blob: 4f90ef1d354901d970cf73308f41dd3fd2a5fad3 [file] [log] [blame]
Andy McFaddenac322da2010-05-19 22:33:28 -07001/*
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
Carl Shapirob60d9ce2011-04-11 20:00:42 -070020#ifdef __cplusplus
21extern "C" {
22#endif
23
Andy McFaddenac322da2010-05-19 22:33:28 -070024/*
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.
Andy McFadden8dfa47d2010-05-27 10:10:18 -070034 *
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.
Andy McFaddenac322da2010-05-19 22:33:28 -070040 */
41
42#if !defined(ANDROID_SMP)
43# error "Must define ANDROID_SMP before including atomic-inline.h"
44#endif
45
Ashok Bhatc15d2ce2013-11-13 16:20:49 +000046#if defined(__aarch64__)
Colin Crossd4146e62014-01-21 20:12:28 -080047#include <cutils/atomic-arm64.h>
Ashok Bhatc15d2ce2013-11-13 16:20:49 +000048#elif defined(__arm__)
Carl Shapiro93b0cb42010-06-03 17:05:15 -070049#include <cutils/atomic-arm.h>
Qiming Shi4bc2f8d2014-01-24 10:40:14 +080050#elif defined(__i386__)
Carl Shapiro93b0cb42010-06-03 17:05:15 -070051#include <cutils/atomic-x86.h>
Qiming Shi4bc2f8d2014-01-24 10:40:14 +080052#elif defined(__x86_64__)
53#include <cutils/atomic-x86_64.h>
Duane Sand09604112012-05-24 17:40:21 -070054#elif defined(__mips__)
55#include <cutils/atomic-mips.h>
Andy McFaddenac322da2010-05-19 22:33:28 -070056#else
Carl Shapiro93b0cb42010-06-03 17:05:15 -070057#error atomic operations are unsupported
Andy McFaddenac322da2010-05-19 22:33:28 -070058#endif
59
Carl Shapiro93b0cb42010-06-03 17:05:15 -070060#if ANDROID_SMP == 0
61#define ANDROID_MEMBAR_FULL android_compiler_barrier
Andy McFaddenac322da2010-05-19 22:33:28 -070062#else
Carl Shapiro93b0cb42010-06-03 17:05:15 -070063#define ANDROID_MEMBAR_FULL android_memory_barrier
Andy McFaddenac322da2010-05-19 22:33:28 -070064#endif
65
Brian Carlstrom464431e2010-09-24 10:56:43 -070066#if ANDROID_SMP == 0
67#define ANDROID_MEMBAR_STORE android_compiler_barrier
68#else
69#define ANDROID_MEMBAR_STORE android_memory_store_barrier
70#endif
71
Carl Shapirob60d9ce2011-04-11 20:00:42 -070072#ifdef __cplusplus
73}
74#endif
75
Carl Shapiro93b0cb42010-06-03 17:05:15 -070076#endif /* ANDROID_CUTILS_ATOMIC_INLINE_H */