Changeset View
Changeset View
Standalone View
Standalone View
source/lib/sysdep/arch/x86_x64/x86_x64.cpp
/* Copyright (C) 2018 Wildfire Games. | /* Copyright (C) 2021 Wildfire Games. | ||||
Stan: 2021 | |||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
* "Software"), to deal in the Software without restriction, including | * "Software"), to deal in the Software without restriction, including | ||||
* without limitation the rights to use, copy, modify, merge, publish, | * without limitation the rights to use, copy, modify, merge, publish, | ||||
* distribute, sublicense, and/or sell copies of the Software, and to | * distribute, sublicense, and/or sell copies of the Software, and to | ||||
* permit persons to whom the Software is furnished to do so, subject to | * permit persons to whom the Software is furnished to do so, subject to | ||||
* the following conditions: | * the following conditions: | ||||
Show All 34 Lines | |||||
# include <intrin.h> // __rdtsc | # include <intrin.h> // __rdtsc | ||||
#endif | #endif | ||||
namespace x86_x64 { | namespace x86_x64 { | ||||
#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 150030729 | #if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 150030729 | ||||
// VC10+ and VC9 SP1: __cpuidex is already available | // VC10+ and VC9 SP1: __cpuidex is already available | ||||
#elif GCC_VERSION | #elif GCC_VERSION | ||||
# if defined(__i386__) && defined(__PIC__) | # if defined(__i386__) && defined(__PIC__) | ||||
# define __cpuidex(regsArray, level, index)\ | # define __cpuidex(regsArray, level, index)\ | ||||
__asm__ __volatile__ ("pushl %%ebx\n"\ | __asm__ __volatile__ ( \ | ||||
"mov %%ebx, %%edi\n" \ | |||||
"cpuid\n"\ | "cpuid\n"\ | ||||
"mov %%ebx,%1\n"\ | "xchg %%edi, %%ebx\n" \ | ||||
"popl %%ebx"\ | : "=a" ((regsArray)[0]), "=D" ((regsArray)[1]), "=c" ((regsArray)[2]), "=d" ((regsArray)[3])\ | ||||
: "=a" ((regsArray)[0]), "=r" ((regsArray)[1]), "=c" ((regsArray)[2]), "=d" ((regsArray)[3])\ | |||||
: "0" (level), "2" (index)); | : "0" (level), "2" (index)); | ||||
# else | # else | ||||
wraitiiUnsubmitted Not Done Inline ActionsRemove this entirely. wraitii: Remove this entirely. | |||||
# define __cpuidex(regsArray, level, index)\ | # define __cpuidex(regsArray, level, index)\ | ||||
__asm__ __volatile__ ("cpuid"\ | __asm__ __volatile__ ("cpuid"\ | ||||
: "=a" ((regsArray)[0]), "=b" ((regsArray)[1]), "=c" ((regsArray)[2]), "=d" ((regsArray)[3])\ | : "=a" ((regsArray)[0]), "=b" ((regsArray)[1]), "=c" ((regsArray)[2]), "=d" ((regsArray)[3])\ | ||||
: "0" (level), "2" (index)); | : "0" (level), "2" (index)); | ||||
# endif | # endif | ||||
#else | #else | ||||
# error "compiler not supported" | # error "compiler not supported" | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 454 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
2021