1/* 2 * Copyright (C) 2009 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_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 32/** 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 44#endif // ANDROID_CUTILS_COMPILER_H 45