cpuid: add null fallback

This commit is contained in:
Danny Robson 2019-02-02 16:40:37 +11:00
parent c5633a32c5
commit 3a518fbac8
3 changed files with 41 additions and 1 deletions

View File

@ -194,7 +194,11 @@ if (host_cpu STREQUAL "x86_64")
cpuid/x86.hpp
)
else ()
message (FATAL_ERROR "Unknown architecture ${host_cpu}")
message (WARNING "Unknown architecture ${host_cpu}. Defaulting to null implementation")
list (APPEND UTIL_FILES
cpuid/none.cpp
cpuid/none.hpp
)
endif ()

19
cpuid/none.cpp Normal file
View File

@ -0,0 +1,19 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 2019 Danny Robson <danny@nerdcruft.net>
*/
#include "none.hpp"
#include <ostream>
///////////////////////////////////////////////////////////////////////////////
std::ostream&
cruft::cpu::operator<< (std::ostream &os, none const &)
{
return os << "{ }";
}

17
cpuid/none.hpp Normal file
View File

@ -0,0 +1,17 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 2019 Danny Robson <danny@nerdcruft.net>
*/
#pragma once
#include <iosfwd>
namespace cruft::cpu {
struct none { };
std::ostream& operator<< (std::ostream &os, none const &);
};