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 33 Lines | |||||
#if MSC_VERSION | #if MSC_VERSION | ||||
# 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__) | |||||
# define __cpuidex(regsArray, level, index)\ | |||||
__asm__ __volatile__ ("pushl %%ebx\n"\ | |||||
"cpuid\n"\ | |||||
"mov %%ebx,%1\n"\ | |||||
"popl %%ebx"\ | |||||
: "=a" ((regsArray)[0]), "=r" ((regsArray)[1]), "=c" ((regsArray)[2]), "=d" ((regsArray)[3])\ | |||||
: "0" (level), "2" (index)); | |||||
# else | |||||
# define __cpuidex(regsArray, level, index)\ | # define __cpuidex(regsArray, level, index)\ | ||||
Not Done Inline ActionsRemove this entirely. wraitii: Remove this entirely. | |||||
__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 | |||||
#else | #else | ||||
# error "compiler not supported" | # error "compiler not supported" | ||||
#endif | #endif | ||||
// some of this module's functions are frequently called but require | // some of this module's functions are frequently called but require | ||||
// non-trivial initialization, so caching is helpful. isInitialized | // non-trivial initialization, so caching is helpful. isInitialized | ||||
// flags aren't thread-safe, so we use ModuleInit. calling it from | // flags aren't thread-safe, so we use ModuleInit. calling it from | ||||
▲ Show 20 Lines • Show All 449 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
2021