compiler.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. #ifndef ANDROID_CUTILS_COMPILER_H
  17. #define ANDROID_CUTILS_COMPILER_H
  18. /*
  19. * helps the compiler's optimizer predicting branches
  20. */
  21. #ifdef __cplusplus
  22. # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), true ))
  23. # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), false ))
  24. #else
  25. # define CC_LIKELY( exp ) (__builtin_expect( !!(exp), 1 ))
  26. # define CC_UNLIKELY( exp ) (__builtin_expect( !!(exp), 0 ))
  27. #endif
  28. /**
  29. * exports marked symbols
  30. *
  31. * if used on a C++ class declaration, this macro must be inserted
  32. * after the "class" keyword. For instance:
  33. *
  34. * template <typename TYPE>
  35. * class ANDROID_API Singleton { }
  36. */
  37. #define ANDROID_API __attribute__((visibility("default")))
  38. #endif // ANDROID_CUTILS_COMPILER_H