1 // clang-format off 2 /* 3 * Copyright (C) 2009 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 #ifndef ANDROID_CUTILS_COMPILER_H 19 #define ANDROID_CUTILS_COMPILER_H 20 21 /* 22 * helps the compiler's optimizer predicting branches 23 */ 24 25 #ifdef __cplusplus 26 # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true )) 27 # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false )) 28 #else 29 # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 )) 30 # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 )) 31 #endif 32 33 /** 34 * exports marked symbols 35 * 36 * if used on a C++ class declaration, this macro must be inserted 37 * after the "class" keyword. For instance: 38 * 39 * template <typename TYPE> 40 * class ANDROID_API Singleton { } 41 */ 42 43 #define ANDROID_API __attribute__((visibility("default"))) 44 45 #endif // ANDROID_CUTILS_COMPILER_H 46