Guillaume Chatelet | 3cc8f31 | 2020-10-12 08:55:20 +0000 | [diff] [blame] | 1 | // Copyright 2017 Google LLC |
Guillaume Chatelet | 439d371 | 2018-02-01 10:03:09 +0100 | [diff] [blame] | 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 | |
Guillaume Chatelet | 22a5362 | 2020-09-23 11:52:20 +0200 | [diff] [blame] | 15 | #include "hwcaps_for_testing.h" |
| 16 | |
Rashmica Gupta | c45e32f | 2018-05-02 14:30:25 +1000 | [diff] [blame] | 17 | #include <string.h> |
| 18 | |
Rashmica Gupta | c45e32f | 2018-05-02 14:30:25 +1000 | [diff] [blame] | 19 | #include "internal/string_view.h" |
Guillaume Chatelet | 439d371 | 2018-02-01 10:03:09 +0100 | [diff] [blame] | 20 | |
| 21 | namespace cpu_features { |
| 22 | |
| 23 | namespace { |
| 24 | static auto* const g_hardware_capabilities = new HardwareCapabilities(); |
Rashmica Gupta | c45e32f | 2018-05-02 14:30:25 +1000 | [diff] [blame] | 25 | static auto* const g_platform_types = new PlatformType(); |
Guillaume Chatelet | 439d371 | 2018-02-01 10:03:09 +0100 | [diff] [blame] | 26 | } // namespace |
| 27 | |
| 28 | void SetHardwareCapabilities(uint32_t hwcaps, uint32_t hwcaps2) { |
| 29 | g_hardware_capabilities->hwcaps = hwcaps; |
| 30 | g_hardware_capabilities->hwcaps2 = hwcaps2; |
| 31 | } |
| 32 | |
Arvid Gerstmann | fd48390 | 2018-05-03 17:07:07 +0200 | [diff] [blame] | 33 | HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void) { |
Guillaume Chatelet | 439d371 | 2018-02-01 10:03:09 +0100 | [diff] [blame] | 34 | return *g_hardware_capabilities; |
| 35 | } |
| 36 | |
Rashmica Gupta | c45e32f | 2018-05-02 14:30:25 +1000 | [diff] [blame] | 37 | void SetPlatformTypes(const char* platform, const char* base_platform) { |
| 38 | CpuFeatures_StringView_CopyString(str(platform), g_platform_types->platform, |
| 39 | sizeof(g_platform_types->platform)); |
| 40 | CpuFeatures_StringView_CopyString(str(base_platform), |
| 41 | g_platform_types->base_platform, |
| 42 | sizeof(g_platform_types->base_platform)); |
| 43 | } |
| 44 | |
| 45 | PlatformType CpuFeatures_GetPlatformType(void) { return *g_platform_types; } |
Guillaume Chatelet | 439d371 | 2018-02-01 10:03:09 +0100 | [diff] [blame] | 46 | } // namespace cpu_features |