Enable Altivec acceleration in libjpeg-turbo for the PPC CPUs which support

it - detection is done at runtime.

Patch from Donovan Watteau, thanks!

ok sthen@
This commit is contained in:
landry 2016-12-03 11:22:50 +00:00
parent 45efb3df5f
commit cc2f829a92
2 changed files with 34 additions and 1 deletions

View File

@ -1,10 +1,11 @@
# $OpenBSD: Makefile,v 1.56 2016/10/18 14:28:14 sthen Exp $ # $OpenBSD: Makefile,v 1.57 2016/12/03 11:22:50 landry Exp $
COMMENT= SIMD-accelerated JPEG codec replacement of libjpeg COMMENT= SIMD-accelerated JPEG codec replacement of libjpeg
V= 1.5.1 V= 1.5.1
DISTNAME= jpeg-turbo-${V} DISTNAME= jpeg-turbo-${V}
PKGNAME= jpeg-${V} PKGNAME= jpeg-${V}
REVISION= 0
EPOCH= 0 EPOCH= 0
SHARED_LIBS+= jpeg 68.1 # 64.0 SHARED_LIBS+= jpeg 68.1 # 64.0

View File

@ -0,0 +1,32 @@
$OpenBSD: patch-simd_jsimd_powerpc_c,v 1.1 2016/12/03 11:22:50 landry Exp $
Detect Altivec support on ppc.
--- simd/jsimd_powerpc.c.orig Wed Sep 21 01:36:59 2016
+++ simd/jsimd_powerpc.c Fri Dec 2 19:23:14 2016
@@ -26,6 +26,12 @@
#include <string.h>
#include <ctype.h>
+#if defined(__OpenBSD__)
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <machine/cpu.h>
+#endif
+
static unsigned int simd_support = ~0;
#if defined(__linux__) || defined(ANDROID) || defined(__ANDROID__)
@@ -116,6 +122,12 @@ init_simd (void)
if (bufsize > SOMEWHAT_SANE_PROC_CPUINFO_SIZE_LIMIT)
break;
}
+#elif defined(__OpenBSD__)
+ int mib[2] = { CTL_MACHDEP, CPU_ALTIVEC };
+ int altivec;
+ size_t len = sizeof(altivec);
+ if (sysctl(mib, 2, &altivec, &len, NULL, 0) == 0 && altivec != 0)
+ simd_support |= JSIMD_ALTIVEC;
#endif
/* Force different settings through environment variables */