blob: 07f68e8a3ec3d040dcb7499cdf3238351f785395 [file] [log] [blame]
Guillaume Chatelet439d3712018-02-01 10:03:09 +01001// Copyright 2017 Google Inc.
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
Rashmica Guptac45e32f2018-05-02 14:30:25 +100015#include <string.h>
16
Guillaume Chatelet439d3712018-02-01 10:03:09 +010017#include "hwcaps_for_testing.h"
Rashmica Guptac45e32f2018-05-02 14:30:25 +100018#include "internal/string_view.h"
Guillaume Chatelet439d3712018-02-01 10:03:09 +010019
20namespace cpu_features {
21
22namespace {
23static auto* const g_hardware_capabilities = new HardwareCapabilities();
Rashmica Guptac45e32f2018-05-02 14:30:25 +100024static auto* const g_platform_types = new PlatformType();
Guillaume Chatelet439d3712018-02-01 10:03:09 +010025} // namespace
26
27void SetHardwareCapabilities(uint32_t hwcaps, uint32_t hwcaps2) {
28 g_hardware_capabilities->hwcaps = hwcaps;
29 g_hardware_capabilities->hwcaps2 = hwcaps2;
30}
31
Arvid Gerstmannfd483902018-05-03 17:07:07 +020032HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void) {
Guillaume Chatelet439d3712018-02-01 10:03:09 +010033 return *g_hardware_capabilities;
34}
35
Rashmica Guptac45e32f2018-05-02 14:30:25 +100036void SetPlatformTypes(const char* platform, const char* base_platform) {
37 CpuFeatures_StringView_CopyString(str(platform), g_platform_types->platform,
38 sizeof(g_platform_types->platform));
39 CpuFeatures_StringView_CopyString(str(base_platform),
40 g_platform_types->base_platform,
41 sizeof(g_platform_types->base_platform));
42}
43
44PlatformType CpuFeatures_GetPlatformType(void) { return *g_platform_types; }
Guillaume Chatelet439d3712018-02-01 10:03:09 +010045} // namespace cpu_features