Home | History | Annotate | Download | only in cutils
      1 /*
      2  * Copyright 2012 The Android Open Source Project
      3  *
      4  * Use of this source code is governed by a BSD-style license that can be
      5  * found in the LICENSE file.
      6  */
      7 
      8 #ifndef ANDROID_CUTILS_COMPILER_H
      9 #define ANDROID_CUTILS_COMPILER_H
     10 
     11 /*
     12  * helps the compiler's optimizer predicting branches
     13  */
     14 
     15 #ifdef __cplusplus
     16 #   define CC_LIKELY( exp )    (__builtin_expect( !!(exp), true ))
     17 #   define CC_UNLIKELY( exp )  (__builtin_expect( !!(exp), false ))
     18 #else
     19 #   define CC_LIKELY( exp )    (__builtin_expect( !!(exp), 1 ))
     20 #   define CC_UNLIKELY( exp )  (__builtin_expect( !!(exp), 0 ))
     21 #endif
     22 
     23 /**
     24  * exports marked symbols
     25  *
     26  * if used on a C++ class declaration, this macro must be inserted
     27  * after the "class" keyword. For instance:
     28  *
     29  * template <typename TYPE>
     30  * class ANDROID_API Singleton { }
     31  */
     32 
     33 #define ANDROID_API __attribute__((visibility("default")))
     34 
     35 #endif // ANDROID_CUTILS_COMPILER_H
     36