cpuid: avoid directly including x86 specifics

This commit is contained in:
Danny Robson 2019-02-02 16:34:39 +11:00
parent bb7be903b1
commit c4a67c7fc9
3 changed files with 24 additions and 6 deletions

View File

@ -3,11 +3,12 @@
* 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 2018 Danny Robson <danny@nerdcruft.net>
* Copyright 2018-2019 Danny Robson <danny@nerdcruft.net>
*/
#ifndef CRUFT_UTIL_CPUID_HPP
#define CRUFT_UTIL_CPUID_HPP
#pragma once
#include "platform.hpp"
#include <iosfwd>
@ -25,4 +26,17 @@ namespace cruft::cpu {
operator<< (std::ostream&, const cruft::cpu::base&);
};
#if defined(PROCESSOR_AMD64)
#include "cpuid_x86.hpp"
#else
#error "Unhandled architecture"
#endif
namespace cruft::cpu {
#if defined(PROCESSOR_AMD64)
using native = x86;
#else
#error "Unhandled architecture"
#endif
}

View File

@ -8,7 +8,11 @@
#pragma once
#include "cpuid.hpp"
#include "platform.hpp"
#if !defined(PROCESSOR_AMD64)
#error "Wrong architecture"
#endif
#include <array>

View File

@ -6,7 +6,7 @@
* Copyright 2018 Danny Robson <danny@nerdcruft.net>
*/
#include "cpuid_x86.hpp"
#include "cpuid.hpp"
#include <iostream>
@ -14,5 +14,5 @@
int
main ()
{
std::cout << cruft::cpu::x86 {} << '\n';
std::cout << cruft::cpu::native {} << '\n';
};