macros.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2015 Google Inc. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef BENCHMARK_MACROS_H_
  15. #define BENCHMARK_MACROS_H_
  16. #if __cplusplus < 201103L
  17. # define BENCHMARK_DISALLOW_COPY_AND_ASSIGN(TypeName) \
  18. TypeName(const TypeName&); \
  19. TypeName& operator=(const TypeName&)
  20. #else
  21. # define BENCHMARK_DISALLOW_COPY_AND_ASSIGN(TypeName) \
  22. TypeName(const TypeName&) = delete; \
  23. TypeName& operator=(const TypeName&) = delete
  24. #endif
  25. #if defined(__GNUC__)
  26. # define BENCHMARK_UNUSED __attribute__((unused))
  27. # define BENCHMARK_ALWAYS_INLINE __attribute__((always_inline))
  28. #elif defined(_MSC_VER) && !defined(__clang__)
  29. # define BENCHMARK_UNUSED
  30. # define BENCHMARK_ALWAYS_INLINE __forceinline
  31. #else
  32. # define BENCHMARK_UNUSED
  33. # define BENCHMARK_ALWAYS_INLINE
  34. #endif
  35. #if defined(__GNUC__)
  36. # define BENCHMARK_BUILTIN_EXPECT(x, y) __builtin_expect(x, y)
  37. #else
  38. # define BENCHMARK_BUILTIN_EXPECT(x, y) x
  39. #endif
  40. #endif // BENCHMARK_MACROS_H_