• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 #if __cplusplus >= 201103L
18 #define BENCHMARK_HAS_CXX11
19 #endif
20 
21 #ifndef BENCHMARK_HAS_CXX11
22 #define BENCHMARK_DISALLOW_COPY_AND_ASSIGN(TypeName) \
23   TypeName(const TypeName&);                         \
24   TypeName& operator=(const TypeName&)
25 #else
26 #define BENCHMARK_DISALLOW_COPY_AND_ASSIGN(TypeName) \
27   TypeName(const TypeName&) = delete;                \
28   TypeName& operator=(const TypeName&) = delete
29 #endif
30 
31 #if defined(__GNUC__)
32 #define BENCHMARK_UNUSED __attribute__((unused))
33 #define BENCHMARK_ALWAYS_INLINE __attribute__((always_inline))
34 #define BENCHMARK_NOEXCEPT noexcept
35 #define BENCHMARK_NOEXCEPT_OP(x) noexcept(x)
36 #elif defined(_MSC_VER) && !defined(__clang__)
37 #define BENCHMARK_UNUSED
38 #define BENCHMARK_ALWAYS_INLINE __forceinline
39 #if _MSC_VER >= 1900
40 #define BENCHMARK_NOEXCEPT noexcept
41 #define BENCHMARK_NOEXCEPT_OP(x) noexcept(x)
42 #else
43 #define BENCHMARK_NOEXCEPT
44 #define BENCHMARK_NOEXCEPT_OP(x)
45 #endif
46 #define __func__ __FUNCTION__
47 #else
48 #define BENCHMARK_UNUSED
49 #define BENCHMARK_ALWAYS_INLINE
50 #define BENCHMARK_NOEXCEPT
51 #define BENCHMARK_NOEXCEPT_OP(x)
52 #endif
53 
54 #if defined(__GNUC__)
55 #define BENCHMARK_BUILTIN_EXPECT(x, y) __builtin_expect(x, y)
56 #define BENCHMARK_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
57 #else
58 #define BENCHMARK_BUILTIN_EXPECT(x, y) x
59 #define BENCHMARK_DEPRECATED_MSG(msg)
60 #endif
61 
62 #if defined(__GNUC__) && !defined(__clang__)
63 #define BENCHMARK_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
64 #endif
65 
66 #endif  // BENCHMARK_MACROS_H_
67