Removed SDL_CPUINFO_DISABLED

CPU info is a core part of the SDL API, and shouldn't be disabled
main
Sam Lantinga 2024-01-16 21:43:54 -08:00
parent 52d6587084
commit 6e1b11368d
5 changed files with 8 additions and 16 deletions

View File

@ -211,7 +211,6 @@ if(EMSCRIPTEN)
set(SDL_ASSEMBLY_DEFAULT OFF)
set(SDL_SHARED_AVAILABLE OFF)
set(SDL_ATOMIC_DEFAULT OFF)
set(SDL_CPUINFO_DEFAULT OFF)
endif()
if(VITA OR PSP OR PS2 OR N3DS OR RISCOS)
@ -250,7 +249,6 @@ set(SDL_SUBSYSTEMS
Threads
Timers
File
CPUinfo
Filesystem
Sensor
Locale

View File

@ -258,7 +258,6 @@
/* Allow disabling of core subsystems */
#cmakedefine SDL_ATOMIC_DISABLED @SDL_ATOMIC_DISABLED@
#cmakedefine SDL_AUDIO_DISABLED @SDL_AUDIO_DISABLED@
#cmakedefine SDL_CPUINFO_DISABLED @SDL_CPUINFO_DISABLED@
#cmakedefine SDL_FILE_DISABLED @SDL_FILE_DISABLED@
#cmakedefine SDL_JOYSTICK_DISABLED @SDL_JOYSTICK_DISABLED@
#cmakedefine SDL_HAPTIC_DISABLED @SDL_HAPTIC_DISABLED@

View File

@ -156,7 +156,6 @@
/* SDL internal assertion support */
/* #undef SDL_DEFAULT_ASSERT_LEVEL */
#define SDL_CPUINFO_DISABLED 1
#define SDL_HAPTIC_DISABLED 1
#define SDL_HIDAPI_DISABLED 1
#ifndef __EMSCRIPTEN_PTHREADS__

View File

@ -25,7 +25,7 @@
// TODO: NEON is disabled until https://github.com/libsdl-org/SDL/issues/8352 can be fixed
#undef SDL_NEON_INTRINSICS
#ifndef SDL_CPUINFO_DISABLED
#ifndef __EMSCRIPTEN__
#if defined(__x86_64__) && defined(SDL_SSE2_INTRINSICS)
#define NEED_SCALAR_CONVERTER_FALLBACKS 0 // x86_64 guarantees SSE2.
#elif defined(__MACOS__) && defined(SDL_SSE2_INTRINSICS)
@ -35,10 +35,10 @@
#elif defined(__APPLE__) && defined(__ARM_ARCH) && (__ARM_ARCH >= 7) && defined(SDL_NEON_INTRINSICS)
#define NEED_SCALAR_CONVERTER_FALLBACKS 0 // All Apple ARMv7 chips promise NEON support.
#endif
#endif
#endif /* __EMSCRIPTEN__ */
// Set to zero if platform is guaranteed to use a SIMD codepath here.
#if !defined(NEED_SCALAR_CONVERTER_FALLBACKS) || defined(SDL_CPUINFO_DISABLED)
#if !defined(NEED_SCALAR_CONVERTER_FALLBACKS)
#define NEED_SCALAR_CONVERTER_FALLBACKS 1
#endif

View File

@ -122,7 +122,7 @@ static int CPU_haveCPUID(void)
int has_CPUID = 0;
/* *INDENT-OFF* */ /* clang-format off */
#ifndef SDL_CPUINFO_DISABLED
#ifndef __EMSCRIPTEN__
#if (defined(__GNUC__) || defined(__llvm__)) && defined(__i386__)
__asm__ (
" pushfl # Get original EFLAGS \n"
@ -209,7 +209,7 @@ done:
"1: \n"
);
#endif
#endif
#endif /* !__EMSCRIPTEN__ */
/* *INDENT-ON* */ /* clang-format on */
return has_CPUID;
}
@ -439,9 +439,7 @@ static int CPU_haveNEON(void)
{
/* The way you detect NEON is a privileged instruction on ARM, so you have
query the OS kernel in a platform-specific way. :/ */
#ifdef SDL_CPUINFO_DISABLED
return 0; /* disabled */
#elif (defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)) && (defined(_M_ARM) || defined(_M_ARM64))
#if (defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)) && (defined(_M_ARM) || defined(_M_ARM64))
/* Visual Studio, for ARM, doesn't define __ARM_ARCH. Handle this first. */
/* Seems to have been removed */
#ifndef PF_ARM_NEON_INSTRUCTIONS_AVAILABLE
@ -498,6 +496,8 @@ static int CPU_haveNEON(void)
}
return 0;
}
#elif defined(__EMSCRIPTEN__)
return 0;
#else
#warning SDL_HasNEON is not implemented for this ARM platform. Write me.
return 0;
@ -618,7 +618,6 @@ static int SDL_CPUCount = 0;
int SDL_GetCPUCount(void)
{
if (!SDL_CPUCount) {
#ifndef SDL_CPUINFO_DISABLED
#if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
if (SDL_CPUCount <= 0) {
SDL_CPUCount = (int)sysconf(_SC_NPROCESSORS_ONLN);
@ -636,7 +635,6 @@ int SDL_GetCPUCount(void)
GetSystemInfo(&info);
SDL_CPUCount = info.dwNumberOfProcessors;
}
#endif
#endif
/* There has to be at least 1, right? :) */
if (SDL_CPUCount <= 0) {
@ -1003,7 +1001,6 @@ static int SDL_SystemRAM = 0;
int SDL_GetSystemRAM(void)
{
if (!SDL_SystemRAM) {
#ifndef SDL_CPUINFO_DISABLED
#if defined(HAVE_SYSCONF) && defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)
if (SDL_SystemRAM <= 0) {
SDL_SystemRAM = (int)((Sint64)sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE) / (1024 * 1024));
@ -1072,7 +1069,6 @@ int SDL_GetSystemRAM(void)
SDL_SystemRAM = (int)SDL_round((info.max_pages + info.ignored_pages > 0 ? info.ignored_pages : 0) * B_PAGE_SIZE / 1048576.0);
}
}
#endif
#endif
}
return SDL_SystemRAM;