Avoid spurious Valgrind uninitialised-value warnings
This was SVN commit r7070.
This commit is contained in:
parent
bcd47ddcbb
commit
373ed7fcb4
31
source/lib/sysdep/arch/x86_x64/tests/test_topology.h
Normal file
31
source/lib/sysdep/arch/x86_x64/tests/test_topology.h
Normal file
@ -0,0 +1,31 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* 0 A.D. is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "lib/self_test.h"
|
||||
|
||||
#include "lib/sysdep/arch/x86_x64/topology.h"
|
||||
|
||||
class TestTopology : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_run()
|
||||
{
|
||||
// Just run the function, ignoring the return value, so
|
||||
// Valgrind can check it's not doing anything very bad
|
||||
cpu_topology_Detect();
|
||||
}
|
||||
};
|
@ -55,6 +55,7 @@ static size_t CoresPerPackage()
|
||||
|
||||
case X86_X64_VENDOR_AMD:
|
||||
regs.eax = 0x80000008;
|
||||
regs.ecx = 0;
|
||||
if(x86_x64_cpuid(®s))
|
||||
coresPerPackage = bits(regs.ecx, 0, 7)+1;
|
||||
break;
|
||||
@ -93,6 +94,7 @@ static size_t LogicalPerCore()
|
||||
{
|
||||
x86_x64_CpuidRegs regs;
|
||||
regs.eax = 1;
|
||||
regs.ecx = 0;
|
||||
if(!x86_x64_cpuid(®s))
|
||||
DEBUG_WARN_ERR(ERR::CPU_FEATURE_MISSING);
|
||||
const size_t logicalPerPackage = bits(regs.ebx, 16, 23);
|
||||
|
@ -138,6 +138,7 @@ static x86_x64_Vendors DetectVendor()
|
||||
{
|
||||
x86_x64_CpuidRegs regs;
|
||||
regs.eax = 0;
|
||||
regs.ecx = 0;
|
||||
if(!x86_x64_cpuid(®s))
|
||||
DEBUG_WARN_ERR(ERR::CPU_FEATURE_MISSING);
|
||||
|
||||
@ -173,6 +174,7 @@ static void DetectSignature(size_t* model, size_t* family)
|
||||
{
|
||||
x86_x64_CpuidRegs regs;
|
||||
regs.eax = 1;
|
||||
regs.ecx = 0;
|
||||
if(!x86_x64_cpuid(®s))
|
||||
DEBUG_WARN_ERR(ERR::CPU_FEATURE_MISSING);
|
||||
*model = bits(regs.eax, 4, 7);
|
||||
@ -387,6 +389,7 @@ static void DetectCacheAndTLB()
|
||||
x86_x64_CpuidRegs regs;
|
||||
|
||||
regs.eax = 0x80000005;
|
||||
regs.ecx = 0;
|
||||
if(x86_x64_cpuid(®s))
|
||||
{
|
||||
AddTLB1Parameters(regs);
|
||||
@ -601,6 +604,7 @@ static void DetectTLB_CPUID2()
|
||||
// extract descriptors
|
||||
x86_x64_CpuidRegs regs;
|
||||
regs.eax = 2;
|
||||
regs.ecx = 0;
|
||||
if(!x86_x64_cpuid(®s))
|
||||
return;
|
||||
size_t iterations = bits(regs.eax, 0, 7);
|
||||
@ -748,6 +752,7 @@ static void DetectIdentifierString(char* identifierString, size_t maxChars)
|
||||
{
|
||||
x86_x64_CpuidRegs regs;
|
||||
regs.eax = function;
|
||||
regs.ecx = 0;
|
||||
have_brand_string &= x86_x64_cpuid(®s);
|
||||
memcpy(pos, ®s, 16);
|
||||
pos += 16;
|
||||
@ -830,6 +835,7 @@ u8 x86_x64_ApicId()
|
||||
{
|
||||
x86_x64_CpuidRegs regs;
|
||||
regs.eax = 1;
|
||||
regs.ecx = 0;
|
||||
// note: CPUID function 1 should be available everywhere, but only
|
||||
// processors with an xAPIC (8th generation or above, e.g. P4/Athlon XP)
|
||||
// will return a nonzero value.
|
||||
@ -870,6 +876,7 @@ void cpu_Serialize()
|
||||
{
|
||||
x86_x64_CpuidRegs regs;
|
||||
regs.eax = 1;
|
||||
regs.ecx = 0;
|
||||
x86_x64_cpuid(®s); // CPUID serializes execution.
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user