17ec681f3Smrg/* 27ec681f3Smrg * Copyright (C) 2009 The Android Open Source Project 37ec681f3Smrg * 47ec681f3Smrg * Licensed under the Apache License, Version 2.0 (the "License"); 57ec681f3Smrg * you may not use this file except in compliance with the License. 67ec681f3Smrg * You may obtain a copy of the License at 77ec681f3Smrg * 87ec681f3Smrg * http://www.apache.org/licenses/LICENSE-2.0 97ec681f3Smrg * 107ec681f3Smrg * Unless required by applicable law or agreed to in writing, software 117ec681f3Smrg * distributed under the License is distributed on an "AS IS" BASIS, 127ec681f3Smrg * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 137ec681f3Smrg * See the License for the specific language governing permissions and 147ec681f3Smrg * limitations under the License. 157ec681f3Smrg */ 167ec681f3Smrg 177ec681f3Smrg#ifndef ANDROID_CUTILS_COMPILER_H 187ec681f3Smrg#define ANDROID_CUTILS_COMPILER_H 197ec681f3Smrg 207ec681f3Smrg/* 217ec681f3Smrg * helps the compiler's optimizer predicting branches 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#ifdef __cplusplus 257ec681f3Smrg# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true )) 267ec681f3Smrg# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false )) 277ec681f3Smrg#else 287ec681f3Smrg# define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 )) 297ec681f3Smrg# define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 )) 307ec681f3Smrg#endif 317ec681f3Smrg 327ec681f3Smrg/** 337ec681f3Smrg * exports marked symbols 347ec681f3Smrg * 357ec681f3Smrg * if used on a C++ class declaration, this macro must be inserted 367ec681f3Smrg * after the "class" keyword. For instance: 377ec681f3Smrg * 387ec681f3Smrg * template <typename TYPE> 397ec681f3Smrg * class ANDROID_API Singleton { } 407ec681f3Smrg */ 417ec681f3Smrg 427ec681f3Smrg#define ANDROID_API __attribute__((visibility("default"))) 437ec681f3Smrg 447ec681f3Smrg#endif // ANDROID_CUTILS_COMPILER_H 45