OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebM project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef TEST_REGISTER_STATE_CHECK_H_ | 11 #ifndef TEST_REGISTER_STATE_CHECK_H_ |
12 #define TEST_REGISTER_STATE_CHECK_H_ | 12 #define TEST_REGISTER_STATE_CHECK_H_ |
13 | 13 |
14 #ifdef _WIN64 | 14 #include "third_party/googletest/src/include/gtest/gtest.h" |
| 15 #include "./vpx_config.h" |
| 16 |
| 17 #if defined(_WIN64) |
15 | 18 |
16 #define _WIN32_LEAN_AND_MEAN | 19 #define _WIN32_LEAN_AND_MEAN |
17 #include <windows.h> | 20 #include <windows.h> |
18 #include <winnt.h> | 21 #include <winnt.h> |
19 | 22 |
20 #include "third_party/googletest/src/include/gtest/gtest.h" | |
21 | |
22 namespace testing { | 23 namespace testing { |
23 namespace internal { | 24 namespace internal { |
24 | 25 |
25 inline bool operator==(const M128A& lhs, const M128A& rhs) { | 26 inline bool operator==(const M128A& lhs, const M128A& rhs) { |
26 return (lhs.Low == rhs.Low && lhs.High == rhs.High); | 27 return (lhs.Low == rhs.Low && lhs.High == rhs.High); |
27 } | 28 } |
28 | 29 |
29 } // namespace internal | 30 } // namespace internal |
30 } // namespace testing | 31 } // namespace testing |
31 | 32 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 CONTEXT pre_context_; | 75 CONTEXT pre_context_; |
75 }; | 76 }; |
76 | 77 |
77 #define REGISTER_STATE_CHECK(statement) do { \ | 78 #define REGISTER_STATE_CHECK(statement) do { \ |
78 libvpx_test::RegisterStateCheck reg_check; \ | 79 libvpx_test::RegisterStateCheck reg_check; \ |
79 statement; \ | 80 statement; \ |
80 } while (false) | 81 } while (false) |
81 | 82 |
82 } // namespace libvpx_test | 83 } // namespace libvpx_test |
83 | 84 |
84 #else // !_WIN64 | 85 #elif defined(CONFIG_SHARED) && defined(HAVE_NEON) \ |
| 86 && !CONFIG_SHARED && HAVE_NEON |
| 87 |
| 88 #include "vpx/vpx_integer.h" |
| 89 |
| 90 extern "C" { |
| 91 // Save the d8-d15 registers into store. |
| 92 void vp9_push_neon(int64_t *store); |
| 93 } |
| 94 |
| 95 namespace libvpx_test { |
| 96 |
| 97 // Compares the state of d8-d15 at construction with their state at |
| 98 // destruction. These registers should be preserved by the callee on |
| 99 // arm platform. |
| 100 // Usage: |
| 101 // { |
| 102 // RegisterStateCheck reg_check; |
| 103 // FunctionToVerify(); |
| 104 // } |
| 105 class RegisterStateCheck { |
| 106 public: |
| 107 RegisterStateCheck() { initialized_ = StoreRegisters(pre_store_); } |
| 108 ~RegisterStateCheck() { EXPECT_TRUE(Check()); } |
| 109 |
| 110 private: |
| 111 static bool StoreRegisters(int64_t store[8]) { |
| 112 vp9_push_neon(store); |
| 113 return true; |
| 114 } |
| 115 |
| 116 // Compares the register state. Returns true if the states match. |
| 117 bool Check() const { |
| 118 if (!initialized_) return false; |
| 119 int64_t post_store[8]; |
| 120 vp9_push_neon(post_store); |
| 121 for (int i = 0; i < 8; ++i) { |
| 122 EXPECT_EQ(pre_store_[i], post_store[i]) << "d" |
| 123 << i + 8 << " has been modified"; |
| 124 } |
| 125 return !testing::Test::HasNonfatalFailure(); |
| 126 } |
| 127 |
| 128 bool initialized_; |
| 129 int64_t pre_store_[8]; |
| 130 }; |
| 131 |
| 132 #define REGISTER_STATE_CHECK(statement) do { \ |
| 133 libvpx_test::RegisterStateCheck reg_check; \ |
| 134 statement; \ |
| 135 } while (false) |
| 136 |
| 137 } // namespace libvpx_test |
| 138 |
| 139 #else |
85 | 140 |
86 namespace libvpx_test { | 141 namespace libvpx_test { |
87 | 142 |
88 class RegisterStateCheck {}; | 143 class RegisterStateCheck {}; |
89 #define REGISTER_STATE_CHECK(statement) statement | 144 #define REGISTER_STATE_CHECK(statement) statement |
90 | 145 |
91 } // namespace libvpx_test | 146 } // namespace libvpx_test |
92 | 147 |
93 #endif // _WIN64 | 148 #endif // _WIN64 |
94 | 149 |
95 #endif // TEST_REGISTER_STATE_CHECK_H_ | 150 #endif // TEST_REGISTER_STATE_CHECK_H_ |
OLD | NEW |