blob: 821ad396f605590b0f81ef1f0e640fb14409f69b [file] [log] [blame]
David 'Digit' Turner6c8a2f22010-06-10 23:34:24 -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 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 *
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.
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.
36 */
37
38#if !defined(ANDROID_SMP)
39# error "Must define ANDROID_SMP before including atomic-inline.h"
40#endif
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
David 'Digit' Turnere31bfae2011-11-15 15:47:02 +010046/* Define __ATOMIC_INLINE__ to control the inlining of all atomics
47 * functions declared here. For a slight performance boost, we want
48 * all of them to be always_inline
David 'Digit' Turner6c8a2f22010-06-10 23:34:24 -070049 */
David 'Digit' Turnere31bfae2011-11-15 15:47:02 +010050#define __ATOMIC_INLINE__ static __inline__ __attribute__((always_inline))
David 'Digit' Turner6c8a2f22010-06-10 23:34:24 -070051
52#ifdef __arm__
David 'Digit' Turnere31bfae2011-11-15 15:47:02 +010053# include <bionic_atomic_arm.h>
54#elif defined(__i386__)
55# include <bionic_atomic_x86.h>
David 'Digit' Turner6c8a2f22010-06-10 23:34:24 -070056#else
David 'Digit' Turnere31bfae2011-11-15 15:47:02 +010057# include <bionic_atomic_gcc_builtin.h>
David 'Digit' Turner6c8a2f22010-06-10 23:34:24 -070058#endif
59
David 'Digit' Turnere31bfae2011-11-15 15:47:02 +010060#define ANDROID_MEMBAR_FULL __bionic_memory_barrier
David 'Digit' Turner6c8a2f22010-06-10 23:34:24 -070061
62#ifdef __cplusplus
63} // extern "C"
64#endif
65
66#endif // BIONIC_ATOMIC_INLINE_H