[vlc-commits] [Git][videolan/vlc][master] 2 commits: freebsd: add Altivec detection
Hugo Beauzée-Luyssen (@chouquette)
gitlab at videolan.org
Tue Mar 1 09:34:44 UTC 2022
Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC
Commits:
ef237826 by Rémi Denis-Courmont at 2022-03-01T08:57:31+00:00
freebsd: add Altivec detection
- - - - -
bc146294 by Rémi Denis-Courmont at 2022-03-01T08:57:31+00:00
cpu: remove SIGILL testing on PPC
Linux, FreeBSD and OpenBSD have proper checks and do not use this code.
macOS also had tests while it was supported, but it no longer is.
- - - - -
3 changed files:
- src/Makefile.am
- + src/freebsd/cpu.c
- src/misc/cpu.c
Changes:
=====================================
src/Makefile.am
=====================================
@@ -472,6 +472,7 @@ endif
if HAVE_FREEBSD
libvlccore_la_SOURCES += \
+ freebsd/cpu.c \
freebsd/thread.c
endif
=====================================
src/freebsd/cpu.c
=====================================
@@ -0,0 +1,43 @@
+/*****************************************************************************
+ * freebsd/cpu.c: CPU detection code for FreeBSD
+ *****************************************************************************
+ * Copyright (C) 2022 Rémi Denis-Courmont
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+#include <vlc_common.h>
+#include <vlc_cpu.h>
+
+#if defined (__powerpc__) /* both 32- and 64-bit */
+unsigned vlc_CPU_raw(void)
+{
+ unsigned int flags = 0;
+ int opt;
+ size_t optlen = sizeof (opt);
+
+ if (sysctlbyname("hw.altivec", &opt, &optlen, NULL, 0) == 0 && opt != 0)
+ flags |= VLC_CPU_ALTIVEC;
+
+ return flags;
+}
+#endif
=====================================
src/misc/cpu.c
=====================================
@@ -58,8 +58,7 @@
#include <machine/cpu.h>
#endif
-#if defined (__i386__) || defined (__x86_64__) || defined (__powerpc__) \
- || defined (__ppc__) || defined (__ppc64__) || defined (__powerpc64__)
+#if defined (__i386__) || defined (__x86_64__)
# if defined (HAVE_FORK)
static bool vlc_CPU_check (const char *name, void (*func) (void))
{
@@ -94,14 +93,6 @@ VLC_SSE static void SSE_test (void)
asm volatile ("xorps %%xmm0,%%xmm0\n" : : : "xmm0", "xmm1");
}
#endif
-
-#if defined (CAN_COMPILE_ALTIVEC)
-static void Altivec_test (void)
-{
- asm volatile ("mtspr 256, %0\n" "vand %%v0, %%v0, %%v0\n" : : "r" (-1));
-}
-#endif
-
#else /* _WIN32 || __OS2__ */
# define vlc_CPU_check(name, func) (1)
#endif
@@ -192,11 +183,6 @@ out:
if( i_error == 0 && i_has_altivec != 0 )
i_capabilities |= VLC_CPU_ALTIVEC;
-
-# elif defined( CAN_COMPILE_ALTIVEC )
- if (vlc_CPU_check ("Altivec", Altivec_test))
- i_capabilities |= VLC_CPU_ALTIVEC;
-
# endif
#endif
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/40a4b4b4a9bbdd70fcbc4f491bc86051fe23162a...bc146294cfeabde3a0c919883931c17e7c36630d
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/40a4b4b4a9bbdd70fcbc4f491bc86051fe23162a...bc146294cfeabde3a0c919883931c17e7c36630d
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list