hardware architecture instead of the machine port. Also add support for detecting the presence of AltiVec at run-time using the machdep.altivec sysctl. At the moment AltiVec is disabled but this at least allows the configure script to build in the support if --disable-altivec is removed. Facilitates further testing and debugging. ok kili@ jakemsr@
44 lines
1.2 KiB
Plaintext
44 lines
1.2 KiB
Plaintext
$OpenBSD: patch-libavcodec_ppc_check_altivec_c,v 1.1 2008/09/05 01:10:21 brad Exp $
|
|
--- libavcodec/ppc/check_altivec.c.orig Sun May 25 01:00:48 2008
|
|
+++ libavcodec/ppc/check_altivec.c Thu Aug 14 23:00:30 2008
|
|
@@ -24,6 +24,10 @@
|
|
|
|
#ifdef __APPLE__
|
|
#include <sys/sysctl.h>
|
|
+#elif __OpenBSD__
|
|
+#include <sys/param.h>
|
|
+#include <sys/sysctl.h>
|
|
+#include <machine/cpu.h>
|
|
#elif __AMIGAOS4__
|
|
#include <exec/exec.h>
|
|
#include <interfaces/exec.h>
|
|
@@ -44,15 +48,22 @@ int has_altivec(void)
|
|
IExec->GetCPUInfoTags(GCIT_VectorUnit, &result, TAG_DONE);
|
|
if (result == VECTORTYPE_ALTIVEC) return 1;
|
|
return 0;
|
|
-#elif __APPLE__
|
|
- int sels[2] = {CTL_HW, HW_VECTORUNIT};
|
|
- int has_vu = 0;
|
|
+#elif defined(__APPLE__) || defined(__OpenBSD__)
|
|
+ int sels[2];
|
|
+ int has_vu = 0, err;
|
|
size_t len = sizeof(has_vu);
|
|
- int err;
|
|
|
|
- err = sysctl(sels, 2, &has_vu, &len, NULL, 0);
|
|
+#ifdef __OpenBSD__
|
|
+ sels[0] = CTL_MACHDEP;
|
|
+ sels[1] = CPU_ALTIVEC;
|
|
+#else
|
|
+ sels[0] = CTL_HW;
|
|
+ sels[1] = HW_VECTORUNIT;
|
|
+#endif
|
|
|
|
- if (err == 0) return has_vu != 0;
|
|
+ err = sysctl(sels, 2, &has_vu, &len, NULL, 0);
|
|
+ if (err == 0)
|
|
+ return has_vu != 0;
|
|
return 0;
|
|
#elif defined(RUNTIME_CPUDETECT)
|
|
int proc_ver;
|