blob: 70f884a1e701f5961874cb9b43df2fbd70a0f326 [file] [log] [blame]
Mathias Agopianb5fbd752009-04-17 14:43:36 -07001/*
Mathias Agopiancccf4272009-04-17 15:16:02 -07002 * Copyright (C) 2009 The Android Open Source Project
Mathias Agopianb5fbd752009-04-17 14:43:36 -07003 *
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_COMPILER_H
18#define ANDROID_CUTILS_COMPILER_H
19
20/*
21 * helps the compiler's optimizer predicting branches
22 */
23
24#ifdef __cplusplus
25# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true ))
26# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false ))
27#else
28# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 ))
29# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 ))
30#endif
31
Romain Guy6bcd4d32011-10-12 13:45:59 -070032/**
33 * exports marked symbols
34 *
35 * if used on a C++ class declaration, this macro must be inserted
36 * after the "class" keyword. For instance:
37 *
38 * template <typename TYPE>
39 * class ANDROID_API Singleton { }
40 */
41
42#define ANDROID_API __attribute__((visibility("default")))
43
Mathias Agopianb5fbd752009-04-17 14:43:36 -070044#endif // ANDROID_CUTILS_COMPILER_H