From e076fbe7439302cc773e3eb2db31fff6fc299a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Tue, 28 Feb 2023 20:37:40 +0200 Subject: [PATCH] cpu: remove the old SSE register tests Since CAN_COMPILE_SSE is no longer defined, this has been silently disabled. Besides: - This was always compiled out on Windows and OS/2. - This is no longer linked in on Linux since the more robust /proc/cpuinfo checks were introduced. - This is not used on MacOS at least since X86-32 support was dropped. The point of this test was to verify that the OS scheduler supports the SSE register bank. According to the introduction commit 22 years ago (2788bc6a4e38026492aa9fb1f2b3b01cad61207d), the problem affected Linux 2.2.x, which is long since unsupported. In the end, we still test the CPU feature support via CPUID. Remove this test only implicitly assumes that the OS kernel is not broken. For what it is worth, this "fixes" the use of _exit() inside library code which was flagged by some linting tools. --- src/misc/cpu.c | 73 ++++++-------------------------------------------- 1 file changed, 8 insertions(+), 65 deletions(-) diff --git a/src/misc/cpu.c b/src/misc/cpu.c index 4748d0641d..ad21e6105d 100644 --- a/src/misc/cpu.c +++ b/src/misc/cpu.c @@ -39,21 +39,9 @@ #include -#include -#ifndef _WIN32 -#include -#include -#include -#else -#include #if defined(_MSC_VER) && !defined(__clang__) # include // __cpuid #endif -#endif - -#ifdef __APPLE__ -#include -#endif #if defined(__OpenBSD__) && defined(__powerpc__) #include @@ -61,46 +49,6 @@ #include #endif -#if defined (__i386__) || defined (__x86_64__) -# if defined (HAVE_FORK) -static bool vlc_CPU_check (const char *name, void (*func) (void)) -{ - pid_t pid = fork(); - - switch (pid) - { - case 0: - signal (SIGILL, SIG_DFL); - func (); - _exit (0); - case -1: - return false; - } - - int status; - while( waitpid( pid, &status, 0 ) == -1 ); - - if( WIFEXITED( status ) && WEXITSTATUS( status ) == 0 ) - return true; - - fprintf (stderr, "Warning: your CPU has %s instructions, but not your " - "operating system.\n", name); - fprintf( stderr, " some optimizations will be disabled unless " - "you upgrade your OS\n" ); - return false; -} - -#if defined (CAN_COMPILE_SSE) && !defined (__SSE__) -VLC_SSE static void SSE_test (void) -{ - asm volatile ("xorps %%xmm0,%%xmm0\n" : : : "xmm0", "xmm1"); -} -#endif -#else /* _WIN32 || __OS2__ */ -# define vlc_CPU_check(name, func) (1) -#endif -#endif - /** * Determines the CPU capabilities. */ @@ -159,19 +107,14 @@ VLC_WEAK unsigned vlc_CPU_raw(void) cpuid( 0x00000001 ); -# if defined (CAN_COMPILE_SSE) && !defined (__SSE__) - if (( i_edx & 0x02000000 ) && vlc_CPU_check ("SSE", SSE_test)) -# endif - { - if (i_edx & 0x04000000) - i_capabilities |= VLC_CPU_SSE2; - if (i_ecx & 0x00000001) - i_capabilities |= VLC_CPU_SSE3; - if (i_ecx & 0x00000200) - i_capabilities |= VLC_CPU_SSSE3; - if (i_ecx & 0x00080000) - i_capabilities |= VLC_CPU_SSE4_1; - } + if (i_edx & 0x04000000) + i_capabilities |= VLC_CPU_SSE2; + if (i_ecx & 0x00000001) + i_capabilities |= VLC_CPU_SSE3; + if (i_ecx & 0x00000200) + i_capabilities |= VLC_CPU_SSSE3; + if (i_ecx & 0x00080000) + i_capabilities |= VLC_CPU_SSE4_1; /* test for additional capabilities */ cpuid( 0x80000000 );