2025-07-06 11:15:27 -07:00
|
|
|
/* Copyright (C) 2025 Wildfire Games.
|
2009-04-18 10:00:33 -07:00
|
|
|
*
|
2010-02-08 08:23:39 -08:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
|
* the following conditions:
|
2016-11-23 03:18:37 -08:00
|
|
|
*
|
2010-02-08 08:23:39 -08:00
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
|
* in all copies or substantial portions of the Software.
|
2016-11-23 03:18:37 -08:00
|
|
|
*
|
2010-02-08 08:23:39 -08:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2009-04-18 10:00:33 -07:00
|
|
|
*/
|
|
|
|
|
|
2009-04-18 10:51:05 -07:00
|
|
|
/*
|
|
|
|
|
* CPU and memory detection.
|
2006-04-11 16:59:08 -07:00
|
|
|
*/
|
|
|
|
|
|
2007-05-02 05:07:08 -07:00
|
|
|
#ifndef INCLUDED_CPU
|
|
|
|
|
#define INCLUDED_CPU
|
2005-05-17 22:32:09 -07:00
|
|
|
|
2025-07-06 11:15:27 -07:00
|
|
|
#include "lib/status.h"
|
2025-07-26 00:43:13 -07:00
|
|
|
#include "lib/sysdep/arch.h"
|
2009-11-10 07:48:41 -08:00
|
|
|
#include "lib/sysdep/compiler.h"
|
|
|
|
|
|
2006-09-22 06:19:40 -07:00
|
|
|
namespace ERR
|
|
|
|
|
{
|
2011-05-03 05:38:42 -07:00
|
|
|
const Status CPU_FEATURE_MISSING = -130000;
|
|
|
|
|
const Status CPU_UNKNOWN_OPCODE = -130001;
|
|
|
|
|
const Status CPU_UNKNOWN_VENDOR = -130002;
|
2016-11-23 03:18:37 -08:00
|
|
|
|
2006-09-22 06:19:40 -07:00
|
|
|
}
|
2004-06-19 07:45:04 -07:00
|
|
|
|
2009-11-10 07:48:41 -08:00
|
|
|
|
2007-09-23 08:36:29 -07:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
// CPU detection
|
2004-06-19 07:45:04 -07:00
|
|
|
|
2007-09-23 08:36:29 -07:00
|
|
|
/**
|
|
|
|
|
* @return string identifying the CPU (usually a cleaned-up version of the
|
|
|
|
|
* brand string)
|
|
|
|
|
**/
|
2022-01-30 22:53:30 -08:00
|
|
|
const char* cpu_IdentifierString();
|
2007-09-23 08:36:29 -07:00
|
|
|
|
2005-05-02 22:05:16 -07:00
|
|
|
|
2010-07-12 15:14:28 -07:00
|
|
|
/**
|
|
|
|
|
* pause in spin-wait loops, as a performance optimisation.
|
|
|
|
|
**/
|
|
|
|
|
inline void cpu_Pause()
|
|
|
|
|
{
|
2010-07-14 05:23:53 -07:00
|
|
|
#if MSC_VERSION && ARCH_X86_X64
|
2010-07-12 15:14:28 -07:00
|
|
|
_mm_pause();
|
2010-07-14 05:23:53 -07:00
|
|
|
#elif GCC_VERSION && ARCH_X86_X64
|
2010-07-12 15:14:28 -07:00
|
|
|
__asm__ __volatile__( "rep; nop" : : : "memory" );
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2007-05-16 08:56:47 -07:00
|
|
|
|
2007-05-02 05:07:08 -07:00
|
|
|
#endif // #ifndef INCLUDED_CPU
|